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