diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rep.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/rep.cpp b/src/rep.cpp index b7b03c8..eeef81f 100644 --- a/src/rep.cpp +++ b/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 (); |