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
6eddbd98
Commit
6eddbd98
authored
Aug 16, 2015
by
somdoron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
polling on thread safe sockets
parent
1653d3c0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
8 deletions
+48
-8
zmq.cpp
src/zmq.cpp
+48
-8
No files found.
src/zmq.cpp
View file @
6eddbd98
...
...
@@ -779,14 +779,36 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// If the poll item is a 0MQ socket, we poll on the file descriptor
// retrieved by the ZMQ_FD socket option.
if
(
items_
[
i
].
socket
)
{
size_t
zmq_fd_size
=
sizeof
(
zmq
::
fd_t
);
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_FD
,
&
pollfds
[
i
].
fd
,
&
zmq_fd_size
)
==
-
1
)
{
int
thread_safe
;
size_t
thread_safe_size
=
sizeof
(
int
);
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
-
1
)
{
if
(
pollfds
!=
spollfds
)
free
(
pollfds
);
return
-
1
;
}
pollfds
[
i
].
events
=
items_
[
i
].
events
?
POLLIN
:
0
;
if
(
thread_safe
)
{
if
(
!
items_
[
i
].
poller
)
{
if
(
pollfds
!=
spollfds
)
free
(
pollfds
);
errno
=
EINVAL
;
return
-
1
;
}
pollfds
[
i
].
fd
=
zmq_poller_get_fd
(
items_
[
i
].
poller
);
}
else
{
size_t
zmq_fd_size
=
sizeof
(
zmq
::
fd_t
);
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_FD
,
&
pollfds
[
i
].
fd
,
&
zmq_fd_size
)
==
-
1
)
{
if
(
pollfds
!=
spollfds
)
free
(
pollfds
);
return
-
1
;
}
}
pollfds
[
i
].
events
=
items_
[
i
].
events
?
POLLIN
:
0
;
}
// Else, the poll item is a raw file descriptor. Just convert the
// events to normal POLLIN/POLLOUT for poll ().
...
...
@@ -942,11 +964,29 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// If the poll item is a 0MQ socket we are interested in input on the
// notification file descriptor retrieved by the ZMQ_FD socket option.
if
(
items_
[
i
].
socket
)
{
size_t
zmq_fd_size
=
sizeof
(
zmq
::
fd_t
);
zmq
::
fd_t
notify_fd
;
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_FD
,
&
notify_fd
,
&
zmq_fd_size
)
==
-
1
)
int
thread_safe
;
size_t
thread_safe_size
=
sizeof
(
int
);
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_THREAD_SAFE
,
&
thread_safe
,
&
thread_safe_size
)
==
-
1
)
return
-
1
;
zmq
::
fd_t
notify_fd
;
if
(
thread_safe
)
{
if
(
!
items_
[
i
].
poller
)
{
errno
=
EINVAL
;
return
-
1
;
}
notify_fd
=
zmq_poller_get_fd
(
items_
[
i
].
poller
);
}
else
{
size_t
zmq_fd_size
=
sizeof
(
zmq
::
fd_t
);
if
(
zmq_getsockopt
(
items_
[
i
].
socket
,
ZMQ_FD
,
&
notify_fd
,
&
zmq_fd_size
)
==
-
1
)
return
-
1
;
}
if
(
items_
[
i
].
events
)
{
FD_SET
(
notify_fd
,
&
pollset_in
);
if
(
maxfd
<
notify_fd
)
...
...
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