Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
L
libzmq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
libzmq
Commits
96ccc1c5
Commit
96ccc1c5
authored
Mar 09, 2010
by
Martin Sustrik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'flags' fields added to the wire format
parent
e04e2cdb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
15 deletions
+39
-15
zmq_decoder.cpp
src/zmq_decoder.cpp
+29
-11
zmq_decoder.hpp
src/zmq_decoder.hpp
+1
-0
zmq_encoder.cpp
src/zmq_encoder.cpp
+8
-3
zmq_encoder.hpp
src/zmq_encoder.hpp
+1
-1
No files found.
src/zmq_decoder.cpp
View file @
96ccc1c5
...
...
@@ -60,25 +60,24 @@ bool zmq::zmq_decoder_t::one_byte_size_ready ()
else
{
// TODO: Handle over-sized message decently.
// in_progress is initialised at this point so in theory we should
// close it before calling zmq_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...
if
(
prefix
.
empty
())
{
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
*
tmpbuf
);
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
*
tmpbuf
-
1
);
errno_assert
(
rc
==
0
);
next_step
(
zmq_msg_data
(
&
in_progress
),
*
tmpbuf
,
&
zmq_decoder_t
::
message_ready
);
}
else
{
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
*
tmpbuf
+
1
+
prefix
.
size
()
);
1
+
prefix
.
size
()
+
*
tmpbuf
-
1
);
errno_assert
(
rc
==
0
);
unsigned
char
*
data
=
(
unsigned
char
*
)
zmq_msg_data
(
&
in_progress
);
*
data
=
(
unsigned
char
)
prefix
.
size
();
memcpy
(
data
+
1
,
prefix
.
data
(),
*
data
);
next_step
(
data
+
*
data
+
1
,
*
tmpbuf
,
&
zmq_decoder_t
::
message_ready
);
}
next_step
(
tmpbuf
,
1
,
&
zmq_decoder_t
::
flags_ready
);
}
return
true
;
}
...
...
@@ -90,22 +89,41 @@ bool zmq::zmq_decoder_t::eight_byte_size_ready ()
size_t
size
=
(
size_t
)
get_uint64
(
tmpbuf
);
// TODO: Handle over-sized message decently.
// in_progress is initialised at this point so in theory we should
// close it before calling zmq_msg_init_size, however, it's a 0-byte
// message and thus we can treat it as uninitialised...
if
(
prefix
.
empty
())
{
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
size
);
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
size
-
1
);
errno_assert
(
rc
==
0
);
next_step
(
zmq_msg_data
(
&
in_progress
),
size
,
&
zmq_decoder_t
::
message_ready
);
}
else
{
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
size
+
1
+
prefix
.
size
());
int
rc
=
zmq_msg_init_size
(
&
in_progress
,
1
+
prefix
.
size
()
+
size
-
1
);
errno_assert
(
rc
==
0
);
unsigned
char
*
data
=
(
unsigned
char
*
)
zmq_msg_data
(
&
in_progress
);
*
data
=
(
unsigned
char
)
prefix
.
size
();
memcpy
(
data
+
1
,
prefix
.
data
(),
*
data
);
next_step
(
data
+
*
data
+
1
,
size
,
&
zmq_decoder_t
::
message_ready
);
}
next_step
(
tmpbuf
,
1
,
&
zmq_decoder_t
::
flags_ready
);
return
true
;
}
bool
zmq
::
zmq_decoder_t
::
flags_ready
()
{
// No flags are accepted at the moment.
zmq_assert
(
tmpbuf
[
0
]
==
0
);
if
(
prefix
.
empty
())
{
next_step
(
zmq_msg_data
(
&
in_progress
),
zmq_msg_size
(
&
in_progress
),
&
zmq_decoder_t
::
message_ready
);
}
else
{
next_step
((
unsigned
char
*
)
zmq_msg_data
(
&
in_progress
)
+
prefix
.
size
()
+
1
,
zmq_msg_size
(
&
in_progress
)
-
prefix
.
size
()
-
1
,
&
zmq_decoder_t
::
message_ready
);
}
return
true
;
...
...
src/zmq_decoder.hpp
View file @
96ccc1c5
...
...
@@ -48,6 +48,7 @@ namespace zmq
bool
one_byte_size_ready
();
bool
eight_byte_size_ready
();
bool
flags_ready
();
bool
message_ready
();
struct
i_inout
*
destination
;
...
...
src/zmq_encoder.cpp
View file @
96ccc1c5
...
...
@@ -89,17 +89,22 @@ bool zmq::zmq_encoder_t::message_ready ()
size
-=
prefix_size
;
}
// Account for the 'flags' byte.
size
++
;
// For messages less than 255 bytes long, write one byte of message size.
// For longer messages write 0xff escape character followed by 8-byte
// message size.
// message size.
In both cases empty 'flags' field follows.
if
(
size
<
255
)
{
tmpbuf
[
0
]
=
(
unsigned
char
)
size
;
next_step
(
tmpbuf
,
1
,
&
zmq_encoder_t
::
size_ready
,
true
);
tmpbuf
[
1
]
=
0
;
next_step
(
tmpbuf
,
2
,
&
zmq_encoder_t
::
size_ready
,
true
);
}
else
{
tmpbuf
[
0
]
=
0xff
;
put_uint64
(
tmpbuf
+
1
,
size
);
next_step
(
tmpbuf
,
9
,
&
zmq_encoder_t
::
size_ready
,
true
);
tmpbuf
[
9
]
=
0
;
next_step
(
tmpbuf
,
10
,
&
zmq_encoder_t
::
size_ready
,
true
);
}
return
true
;
}
src/zmq_encoder.hpp
View file @
96ccc1c5
...
...
@@ -48,7 +48,7 @@ namespace zmq
struct
i_inout
*
source
;
::
zmq_msg_t
in_progress
;
unsigned
char
tmpbuf
[
9
];
unsigned
char
tmpbuf
[
10
];
bool
trim
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment