Merge pull request #2769 from bluca/ipc_fixes

This commit is contained in:
Constantin Rack 2017-10-07 21:53:24 +02:00 committed by GitHub
commit 136431ebf7
2 changed files with 14 additions and 12 deletions

View File

@ -289,6 +289,7 @@ error:
int zmq::ipc_listener_t::close ()
{
zmq_assert (s != retired_fd);
int fd_for_event = s;
int rc = ::close (s);
errno_assert (rc == 0);
@ -308,7 +309,7 @@ int zmq::ipc_listener_t::close ()
}
}
socket->event_closed (endpoint, s);
socket->event_closed (endpoint, fd_for_event);
return 0;
}

View File

@ -29,7 +29,7 @@
#include "testutil.hpp"
static const char* SOCKET_ADDR = "ipc:///tmp/tester";
static const char* SOCKET_ADDR = "ipc:///tmp/test_rebind_ipc";
int main (void)
@ -39,9 +39,12 @@ int main (void)
void *ctx = zmq_ctx_new ();
assert (ctx);
void *sb = zmq_socket (ctx, ZMQ_PUSH);
assert (sb);
int rc = zmq_bind (sb, SOCKET_ADDR);
void *sb0 = zmq_socket (ctx, ZMQ_PUSH);
assert (sb0);
void *sb1 = zmq_socket (ctx, ZMQ_PUSH);
assert (sb1);
int rc = zmq_bind (sb0, SOCKET_ADDR);
assert (rc == 0);
void *sc = zmq_socket (ctx, ZMQ_PULL);
@ -49,22 +52,20 @@ int main (void)
rc = zmq_connect (sc, SOCKET_ADDR);
assert (rc == 0);
rc = zmq_send (sb, "42", 2, 0);
rc = zmq_send (sb0, "42", 2, 0);
assert (rc == 2);
char buffer [2];
rc = zmq_recv(sc, buffer, 2, 0);
assert (rc == 2);
rc = zmq_close (sb);
rc = zmq_close (sb0);
assert (rc == 0);
sb = zmq_socket (ctx, ZMQ_PUSH);
assert (sb);
rc = zmq_bind (sb, SOCKET_ADDR);
rc = zmq_bind (sb1, SOCKET_ADDR);
assert (rc == 0);
rc = zmq_send (sb, "42", 2, 0);
rc = zmq_send (sb1, "42", 2, 0);
assert (rc == 2);
rc = zmq_recv(sc, buffer, 2, 0);
@ -73,7 +74,7 @@ int main (void)
rc = zmq_close (sc);
assert (rc == 0);
rc = zmq_close (sb);
rc = zmq_close (sb1);
assert (rc == 0);
rc = zmq_ctx_term (ctx);