From: Anton Ivanov <[email protected]> Make persistent dead connections immeditely return an EPIPE to upper layers.
Signed-off-by: Anton Ivanov <[email protected]> --- lib/stream-fd.c | 11 ++++++++++- lib/stream-ssl.c | 8 +++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/stream-fd.c b/lib/stream-fd.c index 791bb96f6..3ac01e2dd 100644 --- a/lib/stream-fd.c +++ b/lib/stream-fd.c @@ -110,12 +110,17 @@ fd_recv(struct stream *stream, void *buffer, size_t n) ssize_t retval; int error; + if (stream->persist && stream->hint) { /* poll-loop is providing us with hints for IO. If we got a HUP/NVAL we skip straight * to the read which should return 0 if the HUP is a real one, if not we clear it * for all other cases we belive what (e)poll has fed us. */ - if ((!(stream->hint->revents & (POLLHUP|POLLNVAL))) && (!stream->rx_ready)) { + if (stream->hint->revents & (POLLHUP|POLLNVAL)) { + return -EPIPE; + } + + if (!stream->rx_ready) { if (!(stream->hint->revents & POLLIN)) { return -EAGAIN; } else { @@ -153,7 +158,11 @@ fd_send(struct stream *stream, const void *buffer, size_t n) ssize_t retval; int error; + if (stream->persist && stream->hint) { + if (stream->hint->revents & (POLLHUP|POLLNVAL)) { + return -EPIPE; + } /* poll-loop is providing us with hints for IO */ if (!stream->tx_ready) { if (!(stream->hint->revents & POLLOUT)) { diff --git a/lib/stream-ssl.c b/lib/stream-ssl.c index 14abacf4a..b3ae46047 100644 --- a/lib/stream-ssl.c +++ b/lib/stream-ssl.c @@ -707,7 +707,10 @@ ssl_recv(struct stream *stream, void *buffer, size_t n) * to the read which should return 0 if the HUP is a real one, if not we clear it * for all other cases we belive what (e)poll has fed us. */ - if ((!(stream->hint->revents & (POLLHUP|POLLNVAL))) && (sslv->rx_want == SSL_READING)) { + if (stream->hint->revents & (POLLHUP|POLLNVAL)) { + return -EPIPE; + } + if (sslv->rx_want == SSL_READING) { if (!(stream->hint->revents & POLLIN)) { return -EAGAIN; } else { @@ -755,6 +758,9 @@ ssl_do_tx(struct stream *stream) struct ssl_stream *sslv = ssl_stream_cast(stream); if (stream->persist && stream->hint) { + if (stream->hint->revents & (POLLHUP|POLLNVAL)) { + return -EPIPE; + } /* poll-loop is providing us with hints for IO */ if (sslv->tx_want == SSL_WRITING) { if (!(stream->hint->revents & POLLOUT)) { -- 2.20.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
