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
e8be2e9d
Commit
e8be2e9d
authored
Apr 14, 2017
by
Luca Boccassi
Committed by
GitHub
Apr 14, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2533 from bjovke/my_work
Problem: FD set copying for Windows still not optimal in some places.
parents
a3ad12f7
dc7bbe35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
3 deletions
+30
-3
select.cpp
src/select.cpp
+20
-0
zmq.cpp
src/zmq.cpp
+10
-3
No files found.
src/select.cpp
View file @
e8be2e9d
...
...
@@ -401,16 +401,36 @@ zmq::select_t::fds_set_t::fds_set_t ()
zmq
::
select_t
::
fds_set_t
::
fds_set_t
(
const
fds_set_t
&
other_
)
{
#if defined ZMQ_HAVE_WINDOWS
// On Windows we don't need to copy the whole fd_set.
// SOCKETS are continuous from the beginning of fd_array in fd_set.
// We just need to copy fd_count elements of fd_array.
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
memcpy
(
&
read
,
&
other_
.
read
,
(
char
*
)
(
other_
.
read
.
fd_array
+
other_
.
read
.
fd_count
)
-
(
char
*
)
&
other_
.
read
);
memcpy
(
&
write
,
&
other_
.
write
,
(
char
*
)
(
other_
.
write
.
fd_array
+
other_
.
write
.
fd_count
)
-
(
char
*
)
&
other_
.
write
);
memcpy
(
&
error
,
&
other_
.
error
,
(
char
*
)
(
other_
.
error
.
fd_array
+
other_
.
error
.
fd_count
)
-
(
char
*
)
&
other_
.
error
);
#else
memcpy
(
&
read
,
&
other_
.
read
,
sizeof
other_
.
read
);
memcpy
(
&
write
,
&
other_
.
write
,
sizeof
other_
.
write
);
memcpy
(
&
error
,
&
other_
.
error
,
sizeof
other_
.
error
);
#endif
}
zmq
::
select_t
::
fds_set_t
&
zmq
::
select_t
::
fds_set_t
::
operator
=
(
const
fds_set_t
&
other_
)
{
#if defined ZMQ_HAVE_WINDOWS
// On Windows we don't need to copy the whole fd_set.
// SOCKETS are continuous from the beginning of fd_array in fd_set.
// We just need to copy fd_count elements of fd_array.
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
memcpy
(
&
read
,
&
other_
.
read
,
(
char
*
)
(
other_
.
read
.
fd_array
+
other_
.
read
.
fd_count
)
-
(
char
*
)
&
other_
.
read
);
memcpy
(
&
write
,
&
other_
.
write
,
(
char
*
)
(
other_
.
write
.
fd_array
+
other_
.
write
.
fd_count
)
-
(
char
*
)
&
other_
.
write
);
memcpy
(
&
error
,
&
other_
.
error
,
(
char
*
)
(
other_
.
error
.
fd_array
+
other_
.
error
.
fd_count
)
-
(
char
*
)
&
other_
.
error
);
#else
memcpy
(
&
read
,
&
other_
.
read
,
sizeof
other_
.
read
);
memcpy
(
&
write
,
&
other_
.
write
,
sizeof
other_
.
write
);
memcpy
(
&
error
,
&
other_
.
error
,
sizeof
other_
.
error
);
#endif
return
*
this
;
}
...
...
src/zmq.cpp
View file @
e8be2e9d
...
...
@@ -1110,10 +1110,14 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// Wait for events. Ignore interrupts if there's infinite timeout.
while
(
true
)
{
memcpy
(
&
inset
,
&
pollset_in
,
sizeof
(
fd_set
));
memcpy
(
&
outset
,
&
pollset_out
,
sizeof
(
fd_set
));
memcpy
(
&
errset
,
&
pollset_err
,
sizeof
(
fd_set
));
#if defined ZMQ_HAVE_WINDOWS
// On Windows we don't need to copy the whole fd_set.
// SOCKETS are continuous from the beginning of fd_array in fd_set.
// We just need to copy fd_count elements of fd_array.
// We gain huge memcpy() improvement if number of used SOCKETs is much lower than FD_SETSIZE.
memcpy
(
&
inset
,
&
pollset_in
,
(
char
*
)
(
pollset_in
.
fd_array
+
pollset_in
.
fd_count
)
-
(
char
*
)
&
pollset_in
);
memcpy
(
&
outset
,
&
pollset_out
,
(
char
*
)
(
pollset_out
.
fd_array
+
pollset_out
.
fd_count
)
-
(
char
*
)
&
pollset_out
);
memcpy
(
&
errset
,
&
pollset_err
,
(
char
*
)
(
pollset_err
.
fd_array
+
pollset_err
.
fd_count
)
-
(
char
*
)
&
pollset_err
);
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
errno
=
zmq
::
wsa_error_to_errno
(
WSAGetLastError
());
...
...
@@ -1121,6 +1125,9 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
return
-
1
;
}
#else
memcpy
(
&
inset
,
&
pollset_in
,
sizeof
(
fd_set
));
memcpy
(
&
outset
,
&
pollset_out
,
sizeof
(
fd_set
));
memcpy
(
&
errset
,
&
pollset_err
,
sizeof
(
fd_set
));
int
rc
=
select
(
maxfd
+
1
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
-
1
))
{
errno_assert
(
errno
==
EINTR
||
errno
==
EBADF
);
...
...
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