From 333ae95db0040e894dc6abc59f992c5e3502abea Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 16 Jun 2020 15:01:49 -0700 Subject: [PATCH] s3: smbd: Allow a SHUTDOWN_CLOSE on a file with outstanding aio if there are no client connections alive. The process is exiting now so pthreads will never complete to cause problems. Signed-off-by: Jeremy Allison --- source3/smbd/close.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/source3/smbd/close.c b/source3/smbd/close.c index d5af62a277c..d20e0d258d8 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -645,6 +645,26 @@ static void assert_no_pending_aio(struct files_struct *fsp, return; } + if (close_type == SHUTDOWN_CLOSE) { + /* + * Check for an active client connection. + * If there is none we're shutting down + * (calling exit()) and can ignore all outstanding aio. + */ + struct smbXsrv_client *client = global_smbXsrv_client; + struct smbXsrv_connection *xconn = client->connections; + bool active_transport = false; + + for (; xconn != NULL; xconn = xconn->next) { + if (NT_STATUS_IS_OK(xconn->transport.status)) { + active_transport = true; + } + } + if (!active_transport) { + return; + } + } + DBG_ERR("fsp->num_aio_requests=%u\n", num_requests); smb_panic("can not close with outstanding aio requests"); return; -- 2.20.1