Blob Blame History Raw
From e823c2f8f4b53aedc2bd69408966ca2df5869bfa Mon Sep 17 00:00:00 2001
From: moagrawa <moagrawa@redhat.com>
Date: Thu, 2 Feb 2017 09:26:25 +0530
Subject: [PATCH 281/285] rpc/socket.c : Bonnie++ hangs during rewrites in
 ganesha + SSL

Problem: Bonnie++ rewrite operation hangs in ganesha + SSL environment

Solution: Bonnie++ hangs during execution of rewrite operation in
          ganesha + SSL environment.It was hanged due to blocking on poll
          call in ssl_do because no POLLOUT event was getting on socket.
          Socket is not getting POLLOUT event because all other threads
          are waiting to get lock and lock is not released ssl_do
          because it is not getting any event on poll.To correct it
          update the condition in ssl_do as same in getting error
          SSL_ERROR_WANT_READ.

Test:     To test the patch followed below procedure
          1) Setup 2X2 Ganesha + SSL environment.
          2) Run bonnie from 3 nfs client parallely
          3) After run "Rewwrite operation" by bonnie it is hanged.
          4) After apply the patch it is not hanged.

> BUG: 1418213
> Change-Id: I5985cbbc4cfdac5d287268d791e31c274abc3c8d
> Signed-off-by: Mohit Agrawal <moagrawa@redhat.com>
> Reviewed-on: https://review.gluster.org/16501
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
> cherry picked from commit d7077bca4b372a056d23416294e729637e9af94e

BUG: 1408576
Change-Id: Ida63faaf07f090f2e433fc19630bbb18f6b4619b
Signed-off-by: moagrawa <moagrawa@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/96684
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 rpc/rpc-transport/socket/src/socket.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index da2f97f..7314047 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -263,6 +263,11 @@ ssl_do (rpc_transport_t *this, void *buf, size_t len, SSL_trinary_func *func)
 			}
 			break;
 		case SSL_ERROR_WANT_WRITE:
+                        if ((func == (SSL_trinary_func *)SSL_read)
+                            || (func == (SSL_trinary_func *) SSL_write)) {
+                                errno = EAGAIN;
+                                return r;
+                        }
 			pfd.fd = priv->sock;
 			pfd.events = POLLOUT;
 			if (poll(&pfd,1,-1) < 0) {
-- 
2.9.3