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:
parent
2f219d7c28
commit
37fd1a77a6
14
src/rep.cpp
14
src/rep.cpp
@ -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 ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user