summaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorRajesh Joseph <rjoseph@redhat.com>2016-08-02 15:30:27 +0000
committerJeff Darcy <jdarcy@redhat.com>2016-08-16 12:46:45 -0700
commit79e006b31a1e6d71f1af02176f8e8acaed7f8cd2 (patch)
tree38b6c139c08f9685eafcc9e137cbfa3f20936e17 /rpc
parent020c39e8ab657fbf12c102186c14aca24239efd4 (diff)
socket: SSL_shutdown should be called before socket shutdown
SSL_shutdown shuts down an active SSL connection. But we are calling this after underlying socket is disconnected. Change-Id: Ia943179d23395f42b942450dbcf26336d4dfc813 BUG: 1362602 Signed-off-by: Rajesh Joseph <rjoseph@redhat.com> Reviewed-on: http://review.gluster.org/15072 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'rpc')
-rw-r--r--rpc/rpc-transport/socket/src/socket.c41
1 files changed, 28 insertions, 13 deletions
diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c
index af496ffc8e2..deec0cbc6f4 100644
--- a/rpc/rpc-transport/socket/src/socket.c
+++ b/rpc/rpc-transport/socket/src/socket.c
@@ -687,6 +687,25 @@ __socket_shutdown (rpc_transport_t *this)
}
static int
+__socket_teardown_connection (rpc_transport_t *this)
+{
+ int ret = -1;
+ socket_private_t *priv = NULL;
+
+ GF_VALIDATE_OR_GOTO ("socket", this, out);
+ GF_VALIDATE_OR_GOTO ("socket", this->private, out);
+
+ priv = this->private;
+
+ if (priv->use_ssl)
+ ssl_teardown_connection(priv);
+
+ ret = __socket_shutdown(this);
+out:
+ return ret;
+}
+
+static int
__socket_disconnect (rpc_transport_t *this)
{
int ret = -1;
@@ -702,7 +721,13 @@ __socket_disconnect (rpc_transport_t *this)
priv->ot_state, priv->ot_gen, priv->sock);
if (priv->sock != -1) {
- ret = __socket_shutdown(this);
+ ret = __socket_teardown_connection (this);
+ if (ret) {
+ gf_log (this->name, GF_LOG_DEBUG,
+ "__socket_teardown_connection () failed: %s",
+ strerror (errno));
+ }
+
if (priv->own_thread) {
/*
* Without this, reconnect (= disconnect + connect)
@@ -714,9 +739,6 @@ __socket_disconnect (rpc_transport_t *this)
"OT_PLEASE_DIE on %p", this);
priv->ot_state = OT_PLEASE_DIE;
}
- else if (priv->use_ssl) {
- ssl_teardown_connection(priv);
- }
}
out:
@@ -2521,15 +2543,8 @@ socket_poller (void *ctx)
err:
/* All (and only) I/O errors should come here. */
pthread_mutex_lock(&priv->lock);
- if (priv->ssl_ssl) {
- /*
- * We're always responsible for this part, but only actually
- * have to do it if we got far enough for ssl_ssl to be valid
- * (i.e. errors in ssl_setup_connection don't count).
- */
- ssl_teardown_connection(priv);
- }
- __socket_shutdown(this);
+
+ __socket_teardown_connection (this);
sys_close (priv->sock);
priv->sock = -1;
priv->ot_state = OT_IDLE;