mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 18:42:43 +01:00
Adds support for detecting ZMQ_STREAM disconnections.
When a ZMQ_STREAM socket connection is broken (intentionally, via `shutdown()` or accidentally via client crash or network failure), there is no way for the application to dertermine that it should drop per-connection data (such as buffers). This contribution makes sure the application receives a 0-length message to notify it that the connection has been broken. This is symmetric with the process of closing the connection from within the application (where the application sends a 0-length message to tell ZeroMQ to close the connection). Conflicts: CMakeLists.txt
This commit is contained in:
@@ -780,6 +780,14 @@ int zmq::stream_engine_t::write_subscription_msg (msg_t *msg_)
|
||||
|
||||
void zmq::stream_engine_t::error ()
|
||||
{
|
||||
if (options.raw_sock) {
|
||||
// For raw sockets, send a final 0-length message to the application
|
||||
// so that it knows the peer has been disconnected.
|
||||
msg_t terminator;
|
||||
terminator.init();
|
||||
(this->*write_msg) (&terminator);
|
||||
terminator.close();
|
||||
}
|
||||
zmq_assert (session);
|
||||
socket->event_disconnected (endpoint, s);
|
||||
session->flush ();
|
||||
|
||||
Reference in New Issue
Block a user