mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-26 10:32:58 +01:00
LIBZMQ-497 there could be unsent bytes in encoder
When we send a large message, the message can be splitted into two chunks. One is in the encoder buffer and the other is the zero-copy pointer. The session could get the term before the last chunk is sent.
This commit is contained in:
@@ -65,6 +65,7 @@ zmq::stream_engine_t::stream_engine_t (fd_t fd_, const options_t &options_, cons
|
||||
options (options_),
|
||||
endpoint (endpoint_),
|
||||
plugged (false),
|
||||
terminating (false),
|
||||
socket (NULL)
|
||||
{
|
||||
// Put the socket into non-blocking mode.
|
||||
@@ -188,6 +189,11 @@ void zmq::stream_engine_t::unplug ()
|
||||
|
||||
void zmq::stream_engine_t::terminate ()
|
||||
{
|
||||
if (!terminating && encoder && encoder->has_data ()) {
|
||||
// Give io_thread a chance to send in the buffer
|
||||
terminating = true;
|
||||
return;
|
||||
}
|
||||
unplug ();
|
||||
delete this;
|
||||
}
|
||||
@@ -298,6 +304,8 @@ void zmq::stream_engine_t::out_event ()
|
||||
// this is necessary to prevent losing incomming messages.
|
||||
if (nbytes == -1) {
|
||||
reset_pollout (handle);
|
||||
if (unlikely (terminating))
|
||||
terminate ();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -309,6 +317,10 @@ void zmq::stream_engine_t::out_event ()
|
||||
if (unlikely (handshaking))
|
||||
if (outsize == 0)
|
||||
reset_pollout (handle);
|
||||
|
||||
if (unlikely (terminating))
|
||||
if (outsize == 0)
|
||||
terminate ();
|
||||
}
|
||||
|
||||
void zmq::stream_engine_t::activate_out ()
|
||||
|
||||
Reference in New Issue
Block a user