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
08be168d
Commit
08be168d
authored
Feb 15, 2013
by
Pieter Hintjens
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #514 from pijyoi/fixcs
release critical section on failure to create signaler fdpair
parents
7094a706
8c71ac47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
11 deletions
+37
-11
signaler.cpp
src/signaler.cpp
+37
-11
No files found.
src/signaler.cpp
View file @
08be168d
...
...
@@ -286,7 +286,7 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
(
char
*
)
&
tcp_nodelay
,
sizeof
(
tcp_nodelay
));
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Bind listening socket to
any free local
port.
// Bind listening socket to
signaler
port.
struct
sockaddr_in
addr
;
memset
(
&
addr
,
0
,
sizeof
(
addr
));
addr
.
sin_family
=
AF_INET
;
...
...
@@ -314,15 +314,19 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
// Connect writer to the listener.
rc
=
connect
(
*
w_
,
(
struct
sockaddr
*
)
&
addr
,
sizeof
(
addr
));
wsa_assert
(
rc
!=
SOCKET_ERROR
);
// Accept connection from writer.
*
r_
=
accept
(
listener
,
NULL
,
NULL
);
wsa_assert
(
*
r_
!=
INVALID_SOCKET
);
// On Windows, preventing sockets to be inherited by child processes.
brc
=
SetHandleInformation
((
HANDLE
)
*
r_
,
HANDLE_FLAG_INHERIT
,
0
);
win_assert
(
brc
);
// Save errno if connection fails
int
conn_errno
=
0
;
if
(
rc
==
SOCKET_ERROR
)
{
conn_errno
=
WSAGetLastError
();
}
else
{
// Accept connection from writer.
*
r_
=
accept
(
listener
,
NULL
,
NULL
);
if
(
*
r_
==
INVALID_SOCKET
)
{
conn_errno
=
WSAGetLastError
();
}
}
// We don't need the listening socket anymore. Close it.
rc
=
closesocket
(
listener
);
...
...
@@ -332,11 +336,33 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
brc
=
SetEvent
(
sync
);
win_assert
(
brc
!=
0
);
// Release the kernel object
//
Release the kernel object
brc
=
CloseHandle
(
sync
);
win_assert
(
brc
!=
0
);
return
0
;
if
(
*
r_
!=
INVALID_SOCKET
)
{
// On Windows, preventing sockets to be inherited by child processes.
brc
=
SetHandleInformation
((
HANDLE
)
*
r_
,
HANDLE_FLAG_INHERIT
,
0
);
win_assert
(
brc
);
return
0
;
}
else
{
// Cleanup writer if connection failed
rc
=
closesocket
(
*
w_
);
wsa_assert
(
rc
!=
SOCKET_ERROR
);
*
w_
=
INVALID_SOCKET
;
// Set errno from saved value
errno
=
wsa_error_to_errno
(
conn_errno
);
// Ideally, we would return errno to the caller signaler_t()
// Unfortunately, it uses errno_assert() which gives "Unknown error"
// We might as well assert here and print the actual error message
wsa_assert_no
(
conn_errno
);
return
-
1
;
}
#elif defined ZMQ_HAVE_OPENVMS
...
...
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