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
2533ffed
Commit
2533ffed
authored
Jun 01, 2018
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: memcpy code fragment is duplicated
Solution: unify between Windows and non-Windows code
parent
04dedfbc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
zmq.cpp
src/zmq.cpp
+9
-10
No files found.
src/zmq.cpp
View file @
2533ffed
...
...
@@ -840,13 +840,19 @@ static timeout_t compute_timeout (const bool first_pass_,
std
::
min
<
uint64_t
>
(
end_
-
now_
,
INT_MAX
));
}
#elif defined ZMQ_POLL_BASED_ON_SELECT
#if defined ZMQ_HAVE_WINDOWS
static
size_t
valid_pollset_bytes
(
const
fd_set
&
pollset_
)
{
#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.
return
reinterpret_cast
<
char
*>
(
pollset_
.
fd_array
+
pollset_
.
fd_count
)
-
reinterpret_cast
<
char
*>
(
&
pollset_
);
}
#else
return
sizeof
(
fd_set
);
#endif
}
#endif
#endif
...
...
@@ -1035,14 +1041,10 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
// Wait for events. Ignore interrupts if there's infinite timeout.
while
(
true
)
{
#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
,
valid_pollset_bytes
(
pollset_in
));
memcpy
(
&
outset
,
&
pollset_out
,
valid_pollset_bytes
(
pollset_out
));
memcpy
(
&
errset
,
&
pollset_err
,
valid_pollset_bytes
(
pollset_err
));
#if defined ZMQ_HAVE_WINDOWS
int
rc
=
select
(
0
,
&
inset
,
&
outset
,
&
errset
,
ptimeout
);
if
(
unlikely
(
rc
==
SOCKET_ERROR
))
{
errno
=
zmq
::
wsa_error_to_errno
(
WSAGetLastError
());
...
...
@@ -1050,9 +1052,6 @@ 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