From de0e6dfdb84cfe13b04d6ec7a09b18f001c61db4 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 4 Oct 2019 14:56:40 +0200 Subject: [PATCH] smb2_server: call smbXsrv_connection_disconnect_transport() early on network errors It's good to remember the first error we got and makes sure we don't try any further io on the connection. Signed-off-by: Stefan Metzmacher Reviewed-by: Guenther Deschner --- source3/smbd/smb2_server.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source3/smbd/smb2_server.c b/source3/smbd/smb2_server.c index c8affd2d148..e7b9d52c7e4 100644 --- a/source3/smbd/smb2_server.c +++ b/source3/smbd/smb2_server.c @@ -3835,6 +3835,8 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn) talloc_free(e->mem_ctx); if (!NT_STATUS_IS_OK(status)) { + smbXsrv_connection_disconnect_transport(xconn, + status); return status; } continue; @@ -3857,7 +3859,10 @@ static NTSTATUS smbd_smb2_flush_send_queue(struct smbXsrv_connection *xconn) return NT_STATUS_OK; } if (err != 0) { - return map_nt_error_from_unix_common(err); + status = map_nt_error_from_unix_common(err); + smbXsrv_connection_disconnect_transport(xconn, + status); + return status; } ok = iov_advance(&e->vector, &e->count, ret); @@ -3944,7 +3949,10 @@ again: ret = recvmsg(xconn->transport.sock, &msg, 0); if (ret == 0) { /* propagate end of file */ - return NT_STATUS_END_OF_FILE; + status = NT_STATUS_END_OF_FILE; + smbXsrv_connection_disconnect_transport(xconn, + status); + return status; } err = socket_error_from_errno(ret, errno, &retry); if (retry) { @@ -3953,7 +3961,10 @@ again: return NT_STATUS_OK; } if (err != 0) { - return map_nt_error_from_unix_common(err); + status = map_nt_error_from_unix_common(err); + smbXsrv_connection_disconnect_transport(xconn, + status); + return status; } if (ret < state->vector.iov_len) { -- 2.34.1