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
10533a56
Commit
10533a56
authored
Jul 14, 2010
by
Martin Hurton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pipe: check_read() should check for message delimiter
parent
e1c596b3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
5 deletions
+36
-5
pipe.cpp
src/pipe.cpp
+22
-5
pipe.hpp
src/pipe.hpp
+3
-0
ypipe.hpp
src/ypipe.hpp
+11
-0
No files found.
src/pipe.cpp
View file @
10533a56
...
...
@@ -44,15 +44,32 @@ void zmq::reader_t::set_pipe (pipe_t *pipe_)
register_pipe
(
pipe
);
}
bool
zmq
::
reader_t
::
is_delimiter
(
zmq_msg_t
&
msg_
)
{
unsigned
char
*
offset
=
0
;
return
msg_
.
content
==
(
void
*
)
(
offset
+
ZMQ_DELIMITER
);
}
bool
zmq
::
reader_t
::
check_read
()
{
// Check if there's an item in the pipe.
if
(
pipe
->
check_read
())
return
true
;
// If not, deactivate the pipe.
endpoint
->
kill
(
this
);
return
false
;
if
(
!
pipe
->
check_read
())
{
endpoint
->
kill
(
this
);
return
false
;
}
// If the next item in the pipe is message delimiter,
// initiate its termination.
if
(
pipe
->
probe
(
is_delimiter
))
{
if
(
endpoint
)
endpoint
->
detach_inpipe
(
this
);
term
();
return
false
;
}
return
true
;
}
bool
zmq
::
reader_t
::
read
(
zmq_msg_t
*
msg_
)
...
...
src/pipe.hpp
View file @
10533a56
...
...
@@ -58,6 +58,9 @@ namespace zmq
void
process_revive
();
void
process_pipe_term_ack
();
// Returns true if the message is delimiter; false otherwise.
static
bool
is_delimiter
(
zmq_msg_t
&
msg_
);
// The underlying pipe.
class
pipe_t
*
pipe
;
...
...
src/ypipe.hpp
View file @
10533a56
...
...
@@ -162,6 +162,17 @@ namespace zmq
return
true
;
}
// Applies the function fn to the first elemenent in the pipe
// and returns the value returned by the fn.
// The pipe mustn't be empty or the function crashes.
inline
bool
probe
(
bool
(
*
fn
)(
T
&
))
{
bool
rc
=
check_read
();
zmq_assert
(
rc
);
return
(
*
fn
)
(
queue
.
front
());
}
protected
:
// Allocation-efficient queue to store pipe items.
...
...
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