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>
This commit is contained in:
Rajesh Joseph 2016-08-02 15:30:27 +00:00 committed by Jeff Darcy
parent 020c39e8ab
commit 79e006b31a

View File

@ -686,6 +686,25 @@ __socket_shutdown (rpc_transport_t *this)
return ret;
}
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)
{
@ -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;