e7a346
From ce2c9ea016ffa20bf291264a012cc14102040900 Mon Sep 17 00:00:00 2001
e7a346
From: Milind Changire <mchangir@redhat.com>
e7a346
Date: Mon, 10 Sep 2018 13:48:18 +0530
e7a346
Subject: [PATCH 421/444] rpc: handle EAGAIN when SSL_ERROR_SYSCALL is returned
e7a346
e7a346
Problem:
e7a346
A return value of ENODATA was forcibly returned in the case where
e7a346
SSL_get_error(r) returned SSL_ERROR_SYSCALL. Sometimes SSL_ERROR_SYSCALL
e7a346
is a transient error which is identified by setting errno to EAGAIN.
e7a346
EAGAIN is not a fatal error and indicates that the syscall needs to be
e7a346
retried.
e7a346
e7a346
Solution:
e7a346
Bubble up the errno in case SSL_get_error(r) returns SSL_ERROR_SYSCALL
e7a346
and let the upper layers handle it appropriately.
e7a346
e7a346
mainline:
e7a346
> Reviewed-on: https://review.gluster.org/c/glusterfs/+/20993
e7a346
> fixes: bz#1622405
e7a346
> Change-Id: I76eff278378930ee79abbf9fa267a7e77356eed6
e7a346
> BUG: 1622405
e7a346
e7a346
Change-Id: I76eff278378930ee79abbf9fa267a7e77356eed6
e7a346
BUG: 1622308
e7a346
Signed-off-by: Milind Changire <mchangir@redhat.com>
e7a346
Reviewed-on: https://code.engineering.redhat.com/gerrit/154868
e7a346
Tested-by: RHGS Build Bot <nigelb@redhat.com>
e7a346
Reviewed-by: Sunil Kumar Heggodu Gopala Acharya <sheggodu@redhat.com>
e7a346
---
e7a346
 rpc/rpc-transport/socket/src/socket.c | 11 +++++++++--
e7a346
 1 file changed, 9 insertions(+), 2 deletions(-)
e7a346
e7a346
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
e7a346
index 8a08177..34a937f 100644
e7a346
--- a/rpc/rpc-transport/socket/src/socket.c
e7a346
+++ b/rpc/rpc-transport/socket/src/socket.c
e7a346
@@ -209,6 +209,7 @@ ssl_do (rpc_transport_t *this, void *buf, size_t len, SSL_trinary_func *func)
e7a346
 	int               r = (-1);
e7a346
 	struct pollfd     pfd = {-1,};
e7a346
 	socket_private_t *priv = NULL;
e7a346
+        int               myerrno = -1;
e7a346
 
e7a346
 	GF_VALIDATE_OR_GOTO(this->name,this->private,out);
e7a346
 	priv = this->private;
e7a346
@@ -276,10 +277,16 @@ ssl_do (rpc_transport_t *this, void *buf, size_t len, SSL_trinary_func *func)
e7a346
 			}
e7a346
 			break;
e7a346
 		case SSL_ERROR_SYSCALL:
e7a346
+                        myerrno = errno;
e7a346
 			/* This is what we get when remote disconnects. */
e7a346
 			gf_log(this->name,GF_LOG_DEBUG,
e7a346
-			       "syscall error (probably remote disconnect)");
e7a346
-			errno = ENODATA;
e7a346
+			       "syscall error (probably remote disconnect)"
e7a346
+                               " errno:%d(%s)", errno, strerror(errno));
e7a346
+                        /* sometimes, errno is set to EAGAIN in this case
e7a346
+                         * so let the upper layers do what they need to do
e7a346
+                         * with it
e7a346
+                         */
e7a346
+			errno = myerrno;
e7a346
 			goto out;
e7a346
 		default:
e7a346
 			errno = EIO;
e7a346
-- 
e7a346
1.8.3.1
e7a346