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: Konrad Sztyber <konrad.sztyber@intel.com>
Change-Id: I111a0cc3ced13dbf3e6d18d004bbec6cac96576c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15824
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@nvidia.com>
This commit is contained in:
Konrad Sztyber 2022-12-08 15:22:44 +01:00 committed by Tomasz Zawadzki
parent e189949f38
commit 17395e315f

View File

@ -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. */