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
8d784f26
Commit
8d784f26
authored
Feb 04, 2019
by
Simon Giesecke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem: close always fails with wildcard bind, since directory is not empty
Solution: unlink the socket file first
parent
b14bb2d8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
23 deletions
+35
-23
ipc_listener.cpp
src/ipc_listener.cpp
+11
-5
test_rebind_ipc.cpp
tests/test_rebind_ipc.cpp
+2
-14
test_reconnect_ivl.cpp
tests/test_reconnect_ivl.cpp
+2
-4
testutil_unity.hpp
tests/testutil_unity.hpp
+20
-0
No files found.
src/ipc_listener.cpp
View file @
8d784f26
...
@@ -249,11 +249,17 @@ int zmq::ipc_listener_t::close ()
...
@@ -249,11 +249,17 @@ int zmq::ipc_listener_t::close ()
_s
=
retired_fd
;
_s
=
retired_fd
;
if
(
_has_file
&&
options
.
use_fd
==
-
1
)
{
if
(
_has_file
&&
options
.
use_fd
==
-
1
)
{
rc
=
0
;
if
(
!
_tmp_socket_dirname
.
empty
())
{
// TODO review this behaviour, it is inconsistent with the use of
if
(
rc
==
0
&&
!
_tmp_socket_dirname
.
empty
())
{
// unlink in open since 656cdb959a7482c45db979c1d08ede585d12e315;
rc
=
::
rmdir
(
_tmp_socket_dirname
.
c_str
());
// however, we must at least remove the file before removing the
_tmp_socket_dirname
.
clear
();
// directory, otherwise it will always fail
rc
=
::
unlink
(
_filename
.
c_str
());
if
(
rc
==
0
)
{
rc
=
::
rmdir
(
_tmp_socket_dirname
.
c_str
());
_tmp_socket_dirname
.
clear
();
}
}
}
if
(
rc
!=
0
)
{
if
(
rc
!=
0
)
{
...
...
tests/test_rebind_ipc.cpp
View file @
8d784f26
...
@@ -44,20 +44,8 @@ void tearDown ()
...
@@ -44,20 +44,8 @@ void tearDown ()
void
test_rebind_ipc
()
void
test_rebind_ipc
()
{
{
char
my_endpoint
[
32
],
random_file
[
16
];
char
my_endpoint
[
32
];
strcpy
(
random_file
,
"tmpXXXXXX"
);
make_random_ipc_endpoint
(
my_endpoint
);
#ifdef HAVE_MKDTEMP
TEST_ASSERT_TRUE
(
mkdtemp
(
random_file
));
strcat
(
random_file
,
"/ipc"
);
#else
int
fd
=
mkstemp
(
random_file
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
close
(
fd
);
#endif
strcpy
(
my_endpoint
,
"ipc://"
);
strcat
(
my_endpoint
,
random_file
);
void
*
sb0
=
test_context_socket
(
ZMQ_PUSH
);
void
*
sb0
=
test_context_socket
(
ZMQ_PUSH
);
void
*
sb1
=
test_context_socket
(
ZMQ_PUSH
);
void
*
sb1
=
test_context_socket
(
ZMQ_PUSH
);
...
...
tests/test_reconnect_ivl.cpp
View file @
8d784f26
...
@@ -72,12 +72,10 @@ void test_reconnect_ivl_against_pair_socket (const char *my_endpoint_,
...
@@ -72,12 +72,10 @@ void test_reconnect_ivl_against_pair_socket (const char *my_endpoint_,
void
test_reconnect_ivl_ipc
(
void
)
void
test_reconnect_ivl_ipc
(
void
)
{
{
char
my_endpoint
[
256
];
char
my_endpoint
[
256
];
size_t
len
=
sizeof
(
my_endpoint
);
make_random_ipc_endpoint
(
my_endpoint
);
void
*
sb
=
test_context_socket
(
ZMQ_PAIR
);
void
*
sb
=
test_context_socket
(
ZMQ_PAIR
);
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_bind
(
sb
,
"ipc://*"
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_bind
(
sb
,
my_endpoint
));
TEST_ASSERT_SUCCESS_ERRNO
(
zmq_getsockopt
(
sb
,
ZMQ_LAST_ENDPOINT
,
my_endpoint
,
&
len
));
test_reconnect_ivl_against_pair_socket
(
my_endpoint
,
sb
);
test_reconnect_ivl_against_pair_socket
(
my_endpoint
,
sb
);
test_context_socket_close
(
sb
);
test_context_socket_close
(
sb
);
...
...
tests/testutil_unity.hpp
View file @
8d784f26
...
@@ -326,3 +326,23 @@ void bind_loopback_ipv6 (void *socket_, char *my_endpoint_, size_t len_)
...
@@ -326,3 +326,23 @@ void bind_loopback_ipv6 (void *socket_, char *my_endpoint_, size_t len_)
{
{
bind_loopback
(
socket_
,
true
,
my_endpoint_
,
len_
);
bind_loopback
(
socket_
,
true
,
my_endpoint_
,
len_
);
}
}
// utility function to create a random IPC endpoint, similar to what a ipc://*
// wildcard binding does, but in a way it can be reused for multiple binds
void
make_random_ipc_endpoint
(
char
*
out_endpoint_
)
{
char
random_file
[
16
];
strcpy
(
random_file
,
"tmpXXXXXX"
);
#ifdef HAVE_MKDTEMP
TEST_ASSERT_TRUE
(
mkdtemp
(
random_file
));
strcat
(
random_file
,
"/ipc"
);
#else
int
fd
=
mkstemp
(
random_file
);
TEST_ASSERT_TRUE
(
fd
!=
-
1
);
close
(
fd
);
#endif
strcpy
(
out_endpoint_
,
"ipc://"
);
strcat
(
out_endpoint_
,
random_file
);
}
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