Blame SOURCES/krb5-1.15-krad-eof.patch

fbb066
From 7fd9fc07cbccef7a6e682057e1560e5b343cb9ff Mon Sep 17 00:00:00 2001
fbb066
From: Nathaniel McCallum <npmccallum@redhat.com>
fbb066
Date: Fri, 30 Sep 2016 10:03:33 -0400
fbb066
Subject: [PATCH] Properly handle EOF condition on libkrad sockets
fbb066
fbb066
In the previous code, when the remote peer performed an orderly shutdown
fbb066
on the socket, libkrad would enter a state in which all future requests
fbb066
timed out.  Instead, if the peer shuts down its socket, we need to
fbb066
attempt to reopen it.
fbb066
fbb066
ticket: 8504 (new)
fbb066
target_version: 1.14-next
fbb066
tags: pullup
fbb066
fbb066
(cherry picked from commit 248497427d5a45225817b6c22e9224e8ad969872)
fbb066
---
fbb066
 src/lib/krad/remote.c | 13 ++++++-------
fbb066
 1 file changed, 6 insertions(+), 7 deletions(-)
fbb066
fbb066
diff --git a/src/lib/krad/remote.c b/src/lib/krad/remote.c
fbb066
index df3de3a..68cd16f 100644
fbb066
--- a/src/lib/krad/remote.c
fbb066
+++ b/src/lib/krad/remote.c
fbb066
@@ -329,16 +329,15 @@ on_io_read(krad_remote *rr)
fbb066
     /* Read the packet. */
fbb066
     i = recv(verto_get_fd(rr->io), rr->buffer.data + rr->buffer.length,
fbb066
              pktlen, 0);
fbb066
-    if (i < 0) {
fbb066
-        /* Should we try again? */
fbb066
-        if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
fbb066
-            return;
fbb066
 
fbb066
-        /* The socket is unrecoverable. */
fbb066
+    /* On these errors, try again. */
fbb066
+    if (i < 0 && (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR))
fbb066
+        return;
fbb066
+
fbb066
+    /* On any other errors or on EOF, the socket is unrecoverable. */
fbb066
+    if (i <= 0) {
fbb066
         remote_shutdown(rr);
fbb066
         return;
fbb066
-    } else if (i == 0) {
fbb066
-        remote_del_flags(rr, FLAGS_READ);
fbb066
     }
fbb066
 
fbb066
     /* If we have a partial read or just the header, try again. */
fbb066
-- 
fbb066
2.10.1
fbb066