This one breaks tests 1720 and 1721, I will revisit it later.

1 and 2 are OK.

A.

On 26/02/2020 11:52, anton.iva...@cambridgegreys.com wrote:
From: Anton Ivanov <anton.iva...@cambridgegreys.com>

Make persistent dead connections immeditely return an
EPIPE to upper layers.

Signed-off-by: Anton Ivanov <anton.iva...@cambridgegreys.com>
---
  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)) {

--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to