Commit 17395e31 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

sock/ssl: call SSL_shutdown() prior to closing fd



OpenSSL's docs state that SSL_shutdown() should be called prior to
closing an fd to notify the peer that we want to terminate the
connection.  Otherwise, the peer might see the connection as being
terminated abruptly and might report unexpected EOF errors. We've even
seen those errors in our test scripts:

*ERROR*: spdk_sock_recv() failed, errno 107: Transport endpoint is not connected

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I111a0cc3ced13dbf3e6d18d004bbec6cac96576c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15824


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
parent e189949f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -1103,6 +1103,10 @@ posix_sock_close(struct spdk_sock *_sock)

	assert(TAILQ_EMPTY(&_sock->pending_reqs));

	if (sock->ssl != NULL) {
		SSL_shutdown(sock->ssl);
	}

	/* If the socket fails to close, the best choice is to
	 * leak the fd but continue to free the rest of the sock
	 * memory. */