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
bf22a9f3
Commit
bf22a9f3
authored
Apr 27, 2020
by
Gudmundur Adalsteinsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: Poller event fd unspecified
Solution: Specify an invalid file descriptor for socket events
parent
b56195e9
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
10 deletions
+16
-10
zmq_poller.txt
doc/zmq_poller.txt
+4
-5
socket_poller.cpp
src/socket_poller.cpp
+2
-2
zmq.cpp
src/zmq.cpp
+4
-3
test_poller.cpp
tests/test_poller.cpp
+6
-0
No files found.
doc/zmq_poller.txt
View file @
bf22a9f3
...
@@ -104,11 +104,7 @@ The *zmq_poller_event_t* structure is defined as follows:
...
@@ -104,11 +104,7 @@ The *zmq_poller_event_t* structure is defined as follows:
typedef struct
typedef struct
{
{
void *socket;
void *socket;
#if defined _WIN32
zmq_fd_t fd;
SOCKET fd;
#else
int fd;
#endif
void *user_data;
void *user_data;
short events;
short events;
} zmq_poller_event_t;
} zmq_poller_event_t;
...
@@ -142,6 +138,9 @@ _zmq_poller_size_.
...
@@ -142,6 +138,9 @@ _zmq_poller_size_.
_zmq_poller_wait_all_ returns the number of valid elements. The valid elements
_zmq_poller_wait_all_ returns the number of valid elements. The valid elements
are placed in positions '0' to 'n_events - 1' in the 'events' array. All
are placed in positions '0' to 'n_events - 1' in the 'events' array. All
members of a valid element are set to valid values by _zmq_poller_wait_all_.
members of a valid element are set to valid values by _zmq_poller_wait_all_.
For socket events 'socket' is non-null and 'fd' is an operating system
specific value for an invalid socket (-1 or INVALID_SOCKET). For fd events
'socket' is NULL and 'fd' is a valid file descriptor.
The client does therefore not need to initialize the contents of the events
The client does therefore not need to initialize the contents of the events
array before a call to _zmq_poller_wait_all_. It is unspecified whether the
array before a call to _zmq_poller_wait_all_. It is unspecified whether the
the remaining elements of 'events' are written to by _zmq_poller_wait_all_.
the remaining elements of 'events' are written to by _zmq_poller_wait_all_.
...
...
src/socket_poller.cpp
View file @
bf22a9f3
...
@@ -403,7 +403,7 @@ void zmq::socket_poller_t::zero_trail_events (
...
@@ -403,7 +403,7 @@ void zmq::socket_poller_t::zero_trail_events (
{
{
for
(
int
i
=
found_
;
i
<
n_events_
;
++
i
)
{
for
(
int
i
=
found_
;
i
<
n_events_
;
++
i
)
{
events_
[
i
].
socket
=
NULL
;
events_
[
i
].
socket
=
NULL
;
events_
[
i
].
fd
=
0
;
events_
[
i
].
fd
=
zmq
::
retired_fd
;
events_
[
i
].
user_data
=
NULL
;
events_
[
i
].
user_data
=
NULL
;
events_
[
i
].
events
=
0
;
events_
[
i
].
events
=
0
;
}
}
...
@@ -435,7 +435,7 @@ int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
...
@@ -435,7 +435,7 @@ int zmq::socket_poller_t::check_events (zmq::socket_poller_t::event_t *events_,
if
(
it
->
events
&
events
)
{
if
(
it
->
events
&
events
)
{
events_
[
found
].
socket
=
it
->
socket
;
events_
[
found
].
socket
=
it
->
socket
;
events_
[
found
].
fd
=
0
;
events_
[
found
].
fd
=
zmq
::
retired_fd
;
events_
[
found
].
user_data
=
it
->
user_data
;
events_
[
found
].
user_data
=
it
->
user_data
;
events_
[
found
].
events
=
it
->
events
&
events
;
events_
[
found
].
events
=
it
->
events
&
events
;
++
found
;
++
found
;
...
...
src/zmq.cpp
View file @
bf22a9f3
...
@@ -1299,9 +1299,10 @@ int zmq_poller_wait (void *poller_, zmq_poller_event_t *event_, long timeout_)
...
@@ -1299,9 +1299,10 @@ int zmq_poller_wait (void *poller_, zmq_poller_event_t *event_, long timeout_)
const
int
rc
=
zmq_poller_wait_all
(
poller_
,
event_
,
1
,
timeout_
);
const
int
rc
=
zmq_poller_wait_all
(
poller_
,
event_
,
1
,
timeout_
);
if
(
rc
<
0
&&
event_
)
{
if
(
rc
<
0
&&
event_
)
{
// TODO this is not portable... zmq_poller_event_t contains pointers,
event_
->
socket
=
NULL
;
// for which nullptr does not need to be represented by all-zeroes
event_
->
fd
=
zmq
::
retired_fd
;
memset
(
event_
,
0
,
sizeof
(
zmq_poller_event_t
));
event_
->
user_data
=
NULL
;
event_
->
events
=
0
;
}
}
// wait_all returns number of events, but we return 0 for any success
// wait_all returns number of events, but we return 0 for any success
return
rc
>=
0
?
0
:
rc
;
return
rc
>=
0
?
0
:
rc
;
...
...
tests/test_poller.cpp
View file @
bf22a9f3
...
@@ -686,6 +686,9 @@ void test_poll_client_server ()
...
@@ -686,6 +686,9 @@ void test_poll_client_server ()
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_poller_wait
(
poller
,
&
event
,
500
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_poller_wait
(
poller
,
&
event
,
500
));
TEST_ASSERT_EQUAL_PTR
(
server
,
event
.
socket
);
TEST_ASSERT_EQUAL_PTR
(
server
,
event
.
socket
);
TEST_ASSERT_NULL
(
event
.
user_data
);
TEST_ASSERT_NULL
(
event
.
user_data
);
#ifndef _WIN32
TEST_ASSERT
(
event
.
fd
==
-
1
);
#endif
recv_string_expect_success
(
server
,
client_server_msg
,
0
);
recv_string_expect_success
(
server
,
client_server_msg
,
0
);
// Polling on pollout
// Polling on pollout
...
@@ -694,6 +697,9 @@ void test_poll_client_server ()
...
@@ -694,6 +697,9 @@ void test_poll_client_server ()
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_poller_wait
(
poller
,
&
event
,
0
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_poller_wait
(
poller
,
&
event
,
0
));
TEST_ASSERT_EQUAL_PTR
(
server
,
event
.
socket
);
TEST_ASSERT_EQUAL_PTR
(
server
,
event
.
socket
);
TEST_ASSERT_NULL
(
event
.
user_data
);
TEST_ASSERT_NULL
(
event
.
user_data
);
#ifndef _WIN32
TEST_ASSERT
(
event
.
fd
==
-
1
);
#endif
TEST_ASSERT_EQUAL_INT
(
ZMQ_POLLOUT
,
event
.
events
);
TEST_ASSERT_EQUAL_INT
(
ZMQ_POLLOUT
,
event
.
events
);
// Stop polling server
// Stop polling server
...
...
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