summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-08-17 12:22:17 +0200
committerStefan Metzmacher <metze@samba.org>2012-09-08 01:27:34 +0200
commit4abccf0b65235d6a01c0dc194f06fac748ee4029 (patch)
tree832c57ba6cf9d0ff622830d41caf01485114e989 /source3/smbd
parent0f284beb67680a152a86e0bec70808ee40e471dc (diff)
downloadsamba-4abccf0b65235d6a01c0dc194f06fac748ee4029.tar.gz
samba-4abccf0b65235d6a01c0dc194f06fac748ee4029.tar.bz2
samba-4abccf0b65235d6a01c0dc194f06fac748ee4029.zip
s3: Fix a panic when shutting down
When a client disconnects while we have aio open, there is no close request that cleans up. We can't send out the replies anymore, so just drop the aio requests that are pending. Found using the new python lib writing multiple files simultaneously TODO: check tdis and logoff Signed-off-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Sat Sep 8 01:27:34 CEST 2012 on sn-devel-104
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index d4b9ad0223..51432320b0 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -708,18 +708,40 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
connection_struct *conn = fsp->conn;
if (fsp->num_aio_requests != 0) {
+
+ if (close_type != SHUTDOWN_CLOSE) {
+ /*
+ * reply_close and the smb2 close must have
+ * taken care of this. No other callers of
+ * close_file should ever have created async
+ * I/O.
+ *
+ * We need to panic here because if we close()
+ * the fd while we have outstanding async I/O
+ * requests, in the worst case we could end up
+ * writing to the wrong file.
+ */
+ DEBUG(0, ("fsp->num_aio_requests=%u\n",
+ fsp->num_aio_requests));
+ smb_panic("can not close with outstanding aio "
+ "requests");
+ }
+
/*
- * reply_close and the smb2 close must have taken care of
- * this. No other callers of close_file should ever have
- * created async I/O.
- *
- * We need to panic here because if we close() the fd while we
- * have outstanding async I/O requests, in the worst case we
- * could end up writing to the wrong file.
+ * For shutdown close, just drop the async requests
+ * including a potential close request pending for
+ * this fsp. Drop the close request first, the
+ * destructor for the aio_requests would execute it.
*/
- DEBUG(0, ("fsp->num_aio_requests=%u\n",
- fsp->num_aio_requests));
- smb_panic("can not close with outstanding aio requests");
+ TALLOC_FREE(fsp->deferred_close);
+
+ while (fsp->num_aio_requests != 0) {
+ /*
+ * The destructor of the req will remove
+ * itself from the fsp
+ */
+ TALLOC_FREE(fsp->aio_requests[0]);
+ }
}
/*