0
0
mirror of https://github.com/zeromq/libzmq.git synced 2025-01-14 09:47:56 +08:00

Handle full-pipe for REP sockets more gracefully

This commit is contained in:
Martin Hurton 2010-03-31 15:15:16 +02:00
parent 2f219d7c28
commit 37fd1a77a6

View File

@ -167,9 +167,6 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_)
return -1;
}
// Check whether it's last part of the reply.
more = msg_->flags & ZMQ_MSG_MORE;
if (reply_pipe) {
// Push message to the reply pipe.
@ -177,8 +174,14 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_)
zmq_assert (!more || written);
// The pipe is full...
// When this happens, we simply return an error.
// This makes REP sockets vulnerable to DoS attack when
// misbehaving requesters stop collecting replies.
// TODO: Tear down the underlying connection (?)
zmq_assert (written);
if (!written) {
errno = EAGAIN;
return -1;
}
}
else {
@ -186,6 +189,9 @@ int zmq::rep_t::xsend (zmq_msg_t *msg_, int flags_)
zmq_msg_close (msg_);
}
// Check whether it's last part of the reply.
more = msg_->flags & ZMQ_MSG_MORE;
// Flush the reply to the requester.
if (!more) {
reply_pipe->flush ();