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
c54589da
Commit
c54589da
authored
Apr 12, 2016
by
Constantin Rack
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1891 from paddor/master
Fix return value of zmq_poller_wait when used on empty poller
parents
32f2b784
621c965f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
5 deletions
+20
-5
socket_poller.cpp
src/socket_poller.cpp
+10
-4
zmq.cpp
src/zmq.cpp
+2
-0
test_poller.cpp
tests/test_poller.cpp
+8
-1
No files found.
src/socket_poller.cpp
View file @
c54589da
...
...
@@ -393,16 +393,22 @@ int zmq::socket_poller_t::wait (zmq::socket_poller_t::event_t *event_, long time
#if defined ZMQ_POLL_BASED_ON_POLL
if
(
unlikely
(
poll_size
==
0
))
{
// We'll report an error (timed out) as if the list was non-empty and
// no event occured within the specified timeout. Otherwise the caller
// needs to check the return value AND the event to avoid using the
// nullified event data.
errno
=
ETIMEDOUT
;
if
(
timeout_
==
0
)
return
0
;
return
-
1
;
#if defined ZMQ_HAVE_WINDOWS
Sleep
(
timeout_
>
0
?
timeout_
:
INFINITE
);
return
0
;
return
-
1
;
#elif defined ZMQ_HAVE_ANDROID
usleep
(
timeout_
*
1000
);
return
0
;
return
-
1
;
#else
return
usleep
(
timeout_
*
1000
);
usleep
(
timeout_
*
1000
);
return
-
1
;
#endif
}
...
...
src/zmq.cpp
View file @
c54589da
...
...
@@ -1209,6 +1209,8 @@ int zmq_poller_wait (void *poller_, zmq_poller_event_t *event, long timeout_)
return
-
1
;
}
zmq_assert
(
event
!=
NULL
);
zmq
::
socket_poller_t
::
event_t
e
;
memset
(
&
e
,
0
,
sizeof
(
e
));
...
...
tests/test_poller.cpp
View file @
c54589da
...
...
@@ -60,6 +60,14 @@ int main (void)
// Set up poller
void
*
poller
=
zmq_poller_new
();
zmq_poller_event_t
event
;
// waiting on poller with no registered sockets should report error
rc
=
zmq_poller_wait
(
poller
,
&
event
,
0
);
assert
(
rc
==
-
1
);
assert
(
errno
==
ETIMEDOUT
);
// register sink
rc
=
zmq_poller_add
(
poller
,
sink
,
sink
,
ZMQ_POLLIN
);
assert
(
rc
==
0
);
...
...
@@ -69,7 +77,6 @@ int main (void)
assert
(
rc
==
1
);
// We expect a message only on the sink
zmq_poller_event_t
event
;
rc
=
zmq_poller_wait
(
poller
,
&
event
,
-
1
);
assert
(
rc
==
0
);
assert
(
event
.
socket
==
sink
);
...
...
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