summaryrefslogtreecommitdiff
path: root/source3/smbd/close.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2004-06-08 16:14:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:51:54 -0500
commit2fc57c9a2ce3a266534dd20e6fed4883e052c557 (patch)
tree0b26f97c713129487ffcf34494119bc3dbe9176a /source3/smbd/close.c
parent386a11f49eff2ec60d75b9966ecdc5627b259f0d (diff)
downloadsamba-2fc57c9a2ce3a266534dd20e6fed4883e052c557.tar.gz
samba-2fc57c9a2ce3a266534dd20e6fed4883e052c557.tar.bz2
samba-2fc57c9a2ce3a266534dd20e6fed4883e052c557.zip
r1085: Now it's had some proper user testing, merge in the deferred open fix. I'm
still doing more testing, but it fixes a behaviour that we've been wrong on ever since the start of Samba. Jeremy. (This used to be commit 894cc6d16296b934c112786eec896846156aee5d)
Diffstat (limited to 'source3/smbd/close.c')
-rw-r--r--source3/smbd/close.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 8b3010c1b2..305377dfc6 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -2,6 +2,7 @@
Unix SMB/CIFS implementation.
file closing
Copyright (C) Andrew Tridgell 1992-1998
+ Copyright (C) Jeremy Allison 1992-2004.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -105,6 +106,32 @@ static int close_filestruct(files_struct *fsp)
}
/****************************************************************************
+ If any deferred opens are waiting on this close, notify them.
+****************************************************************************/
+
+static void notify_deferred_opens(files_struct *fsp)
+{
+ deferred_open_entry *de_array = NULL;
+ int num_de_entries, i;
+ pid_t mypid = sys_getpid();
+
+ num_de_entries = get_deferred_opens(fsp->conn, fsp->dev, fsp->inode, &de_array);
+ for (i = 0; i < num_de_entries; i++) {
+ deferred_open_entry *entry = &de_array[i];
+ if (entry->pid == mypid) {
+ /*
+ * We need to notify ourself to retry the open.
+ * Do this by finding the queued SMB record, moving it
+ * to the head of the queue and changing the wait time to zero.
+ */
+ schedule_sharing_violation_open_smb_message(entry->mid);
+ } else {
+ send_deferred_open_retry_message(entry);
+ }
+ }
+}
+
+/****************************************************************************
Close a file.
If normal_close is 1 then this came from a normal SMBclose (or equivalent)
@@ -177,6 +204,9 @@ static int close_normal_file(files_struct *fsp, BOOL normal_close)
SAFE_FREE(share_entry);
+ /* Notify any deferred opens waiting on this close. */
+ notify_deferred_opens(fsp);
+
/*
* NT can set delete_on_close of the last open
* reference to a file.