smb2_server: call smbXsrv_connection_disconnect_transport() early on network errors
authorStefan Metzmacher <metze@samba.org>
Fri, 4 Oct 2019 12:56:40 +0000 (14:56 +0200)
committerGünther Deschner <gd@samba.org>
Fri, 15 May 2020 09:04:36 +0000 (09:04 +0000)
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 <metze@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
source3/smbd/smb2_server.c

index c8affd2d1485cd652b2b37742b4c992e429eb528..e7b9d52c7e439c9a81908c4aa03307bf1e0f69eb 100644 (file)
@@ -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)) {
                        talloc_free(e->mem_ctx);
 
                        if (!NT_STATUS_IS_OK(status)) {
+                               smbXsrv_connection_disconnect_transport(xconn,
+                                                                       status);
                                return status;
                        }
                        continue;
                                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 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);
                }
 
                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 */
        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) {
        }
        err = socket_error_from_errno(ret, errno, &retry);
        if (retry) {
@@ -3953,7 +3961,10 @@ again:
                return NT_STATUS_OK;
        }
        if (err != 0) {
                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) {
        }
 
        if (ret < state->vector.iov_len) {