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
42e27b7d
Commit
42e27b7d
authored
Mar 26, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: socket returned by ZMQ_FD cannot be used with CreateIoCompletionPort
Solution: add WSA_FLAG_OVERLAPPED socket flag
parent
25bb43c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
2 deletions
+39
-2
ip.cpp
src/ip.cpp
+3
-2
test_pair_tcp.cpp
tests/test_pair_tcp.cpp
+36
-0
No files found.
src/ip.cpp
View file @
42e27b7d
...
...
@@ -84,8 +84,9 @@ zmq::fd_t zmq::open_socket (int domain_, int type_, int protocol_)
#if defined ZMQ_HAVE_WINDOWS && defined WSA_FLAG_NO_HANDLE_INHERIT
// if supported, create socket with WSA_FLAG_NO_HANDLE_INHERIT, such that
// the race condition in making it non-inheritable later is avoided
const
fd_t
s
=
WSASocket
(
domain_
,
type_
,
protocol_
,
NULL
,
0
,
WSA_FLAG_NO_HANDLE_INHERIT
);
const
fd_t
s
=
WSASocket
(
domain_
,
type_
,
protocol_
,
NULL
,
0
,
WSA_FLAG_OVERLAPPED
||
WSA_FLAG_NO_HANDLE_INHERIT
);
#else
const
fd_t
s
=
socket
(
domain_
,
type_
,
protocol_
);
#endif
...
...
tests/test_pair_tcp.cpp
View file @
42e27b7d
...
...
@@ -32,6 +32,10 @@
#include <string.h>
#if defined _WIN32
#include "../src/windows.hpp"
#endif
SETUP_TEARDOWN_TESTCONTEXT
typedef
void
(
*
extra_func_t
)
(
void
*
socket_
);
...
...
@@ -110,6 +114,35 @@ void test_pair_tcp_fastpath ()
}
#endif
#ifdef _WIN32
void
test_io_completion_port
()
{
void
*
const
s
=
test_context_socket
(
ZMQ_PAIR
);
SOCKET
fd
;
size_t
fd_size
=
sizeof
fd
;
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_getsockopt
(
s
,
ZMQ_FD
,
&
fd
,
&
fd_size
));
::
WSAPROTOCOL_INFO
pi
;
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
::
WSADuplicateSocket
(
fd
,
::
GetCurrentProcessId
(),
&
pi
));
const
SOCKET
socket
=
::
WSASocket
(
pi
.
iAddressFamily
/*AF_INET*/
,
pi
.
iSocketType
/*SOCK_STREAM*/
,
pi
.
iProtocol
/*IPPROTO_TCP*/
,
&
pi
,
0
,
0
);
const
HANDLE
iocp
=
::
CreateIoCompletionPort
(
INVALID_HANDLE_VALUE
,
NULL
,
0
,
0
);
TEST_ASSERT_NOT_EQUAL
(
NULL
,
iocp
);
const
HANDLE
res
=
::
CreateIoCompletionPort
(
reinterpret_cast
<
HANDLE
>
(
socket
),
iocp
,
0
,
0
);
TEST_ASSERT_NOT_EQUAL
(
NULL
,
res
);
TEST_ASSERT_SUCCESS_RAW_ERRNO
(
closesocket
(
socket
));
TEST_ASSERT_TRUE
(
CloseHandle
(
iocp
));
test_context_socket_close
(
s
);
}
#endif
int
main
()
{
setup_test_environment
();
...
...
@@ -120,6 +153,9 @@ int main ()
#ifdef ZMQ_BUILD_DRAFT
RUN_TEST
(
test_pair_tcp_fastpath
);
#endif
#ifdef _WIN32
RUN_TEST
(
test_io_completion_port
);
#endif
return
UNITY_END
();
}
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