• Sergey KHripchenko's avatar
    fixes for zmq_unbind() / zmq_disconnect() usage corner cases · 057fab09
    Sergey KHripchenko authored
    1. when we call zmq_bind()/zmq_connect() to create endpoint
    we send ourselfs(through launch_child()) command to process_own(endpoint)
    (and add it to own_t::owned)
    in the application thread we could call zmq_unbind() / zmq_disconnect() _BEFORE_
    we run process_own() in ZMQ thread and in this situation we will be unable to find it in
    own_t::owned. in other words own_t::owned.find(endpoint) will not be deleted but it will be deleted from
    socket_base_t::endpoints.
    
    2. when you zmq_unbind() the lisnening TCP/IPC socket was terminated only in destructor...
    so the whole ZMQ_LINGER time listening TCP/IPC socket was able to accept() new connections
    but unable to handle them.
    
    this all geting even worse since unfortunately zmq has a bug and '*_listener_t' object not terminated
    untill the socket's zmq_close().
    AT LEAST FOR PUSH SOCKETS.
    Everything is ok for SUB sockets.
    
    Easy to reproduce without my fix:
    
    zmq_socket(PUSH)
    zmq_bind(tcp);
    // connect to  it from PULL socket
    zmq_unbind(tcp);
    
    sleep(forever)
    
    // netstat -anp | grep 'tcp listening socket'
    
    With my fix you could see that after zmq_unbind(tcp) all previously connected tcp sessions
    will not be finished untill the zmq_close(socket) regardless of ZMQ_LINGER value.
    
    (*_listener_t terminates all owned session_base_t(connect=false) and they call pipe_t::terminate()
    which in turn should call session_base_t::terminated() but this never happens)
    057fab09
Name
Last commit
Last update
..
Makefile.am Loading commit data...
address.cpp Loading commit data...
address.hpp Loading commit data...
array.hpp Loading commit data...
atomic_counter.hpp Loading commit data...
atomic_ptr.hpp Loading commit data...
blob.hpp Loading commit data...
clock.cpp Loading commit data...
clock.hpp Loading commit data...
command.hpp Loading commit data...
config.hpp Loading commit data...
ctx.cpp Loading commit data...
ctx.hpp Loading commit data...
dealer.cpp Loading commit data...
dealer.hpp Loading commit data...
decoder.cpp Loading commit data...
decoder.hpp Loading commit data...
device.cpp Loading commit data...
device.hpp Loading commit data...
devpoll.cpp Loading commit data...
devpoll.hpp Loading commit data...
dist.cpp Loading commit data...
dist.hpp Loading commit data...
encoder.cpp Loading commit data...
encoder.hpp Loading commit data...
epoll.cpp Loading commit data...
epoll.hpp Loading commit data...
err.cpp Loading commit data...
err.hpp Loading commit data...
fd.hpp Loading commit data...
fq.cpp Loading commit data...
fq.hpp Loading commit data...
i_engine.hpp Loading commit data...
i_poll_events.hpp Loading commit data...
io_object.cpp Loading commit data...
io_object.hpp Loading commit data...
io_thread.cpp Loading commit data...
io_thread.hpp Loading commit data...
ip.cpp Loading commit data...
ip.hpp Loading commit data...
ipc_address.cpp Loading commit data...
ipc_address.hpp Loading commit data...
ipc_connecter.cpp Loading commit data...
ipc_connecter.hpp Loading commit data...
ipc_listener.cpp Loading commit data...
ipc_listener.hpp Loading commit data...
kqueue.cpp Loading commit data...
kqueue.hpp Loading commit data...
lb.cpp Loading commit data...
lb.hpp Loading commit data...
libzmq.pc.in Loading commit data...
likely.hpp Loading commit data...
mailbox.cpp Loading commit data...
mailbox.hpp Loading commit data...
msg.cpp Loading commit data...
msg.hpp Loading commit data...
mtrie.cpp Loading commit data...
mtrie.hpp Loading commit data...
mutex.hpp Loading commit data...
object.cpp Loading commit data...
object.hpp Loading commit data...
options.cpp Loading commit data...
options.hpp Loading commit data...
own.cpp Loading commit data...
own.hpp Loading commit data...
pair.cpp Loading commit data...
pair.hpp Loading commit data...
pgm_receiver.cpp Loading commit data...
pgm_receiver.hpp Loading commit data...
pgm_sender.cpp Loading commit data...
pgm_sender.hpp Loading commit data...
pgm_socket.cpp Loading commit data...
pgm_socket.hpp Loading commit data...
pipe.cpp Loading commit data...
pipe.hpp Loading commit data...
poll.cpp Loading commit data...
poll.hpp Loading commit data...
poller.hpp Loading commit data...
poller_base.cpp Loading commit data...
poller_base.hpp Loading commit data...
precompiled.cpp Loading commit data...
precompiled.hpp Loading commit data...
pub.cpp Loading commit data...
pub.hpp Loading commit data...
pull.cpp Loading commit data...
pull.hpp Loading commit data...
push.cpp Loading commit data...
push.hpp Loading commit data...
random.cpp Loading commit data...
random.hpp Loading commit data...
reaper.cpp Loading commit data...
reaper.hpp Loading commit data...
rep.cpp Loading commit data...
rep.hpp Loading commit data...
req.cpp Loading commit data...
req.hpp Loading commit data...
router.cpp Loading commit data...
router.hpp Loading commit data...
select.cpp Loading commit data...
select.hpp Loading commit data...
session_base.cpp Loading commit data...
session_base.hpp Loading commit data...
signaler.cpp Loading commit data...
signaler.hpp Loading commit data...
socket_base.cpp Loading commit data...
socket_base.hpp Loading commit data...
stdint.hpp Loading commit data...
stream_engine.cpp Loading commit data...
stream_engine.hpp Loading commit data...
sub.cpp Loading commit data...
sub.hpp Loading commit data...
tcp_address.cpp Loading commit data...
tcp_address.hpp Loading commit data...
tcp_connecter.cpp Loading commit data...
tcp_connecter.hpp Loading commit data...
tcp_listener.cpp Loading commit data...
tcp_listener.hpp Loading commit data...
thread.cpp Loading commit data...
thread.hpp Loading commit data...
trie.cpp Loading commit data...
trie.hpp Loading commit data...
windows.hpp Loading commit data...
wire.hpp Loading commit data...
xpub.cpp Loading commit data...
xpub.hpp Loading commit data...
xsub.cpp Loading commit data...
xsub.hpp Loading commit data...
ypipe.hpp Loading commit data...
yqueue.hpp Loading commit data...
zmq.cpp Loading commit data...
zmq_utils.cpp Loading commit data...