summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-01-19 21:46:12 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:17:19 -0500
commitaacd16e7c4bea5018560eea09d55f2a6473be84d (patch)
treed78e8f338eddd47bb458cbc4f0f7e0b7091dd461 /source3/smbd
parentcce97a9b50e6c022cc9eba3d97969c27ae7d106d (diff)
downloadsamba-aacd16e7c4bea5018560eea09d55f2a6473be84d.tar.gz
samba-aacd16e7c4bea5018560eea09d55f2a6473be84d.tar.bz2
samba-aacd16e7c4bea5018560eea09d55f2a6473be84d.zip
r20916: Add in the delete on close final fix - but only enabled
with -DDEVELOPER. Jeremy. (This used to be commit 7f817067a70930ee3502ea3373173e0c23733253)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/close.c1
-rw-r--r--source3/smbd/filename.c6
-rw-r--r--source3/smbd/server.c13
-rw-r--r--source3/smbd/statcache.c34
4 files changed, 54 insertions, 0 deletions
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 8958878433..07f81f988e 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -431,6 +431,7 @@ static int close_directory(files_struct *fsp, enum file_close_type close_type)
become_user(fsp->conn, fsp->vuid);
became_user = True;
}
+ send_stat_cache_delete_message(fsp->fsp_name);
set_delete_on_close_lck(lck, True, &current_user.ut);
if (became_user) {
unbecome_user();
diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c
index b69d2f3e5e..eb86a0efd1 100644
--- a/source3/smbd/filename.c
+++ b/source3/smbd/filename.c
@@ -462,6 +462,12 @@ NTSTATUS unix_convert(connection_struct *conn,
}
} /* end else */
+#ifdef DEVELOPER
+ if (VALID_STAT(st) && get_delete_on_close_flag(st.st_dev, st.st_ino)) {
+ return NT_STATUS_DELETE_PENDING;
+ }
+#endif
+
/*
* Add to the dirpath that we have resolved so far.
*/
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index 4a242488da..e2f73285b3 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -83,6 +83,18 @@ static void smb_conf_updated(int msg_type, struct process_id src,
}
+/*******************************************************************
+ Delete a statcache entry.
+ ********************************************************************/
+
+static void smb_stat_cache_delete(int msg_type, struct process_id src,
+ void *buf, size_t len)
+{
+ const char *name = (const char *)buf;
+ DEBUG(10,("smb_stat_cache_delete: delete name %s\n", name));
+ stat_cache_delete(name);
+}
+
/****************************************************************************
Terminate signal.
****************************************************************************/
@@ -422,6 +434,7 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_
message_register(MSG_SHUTDOWN, msg_exit_server);
message_register(MSG_SMB_FILE_RENAME, msg_file_was_renamed);
message_register(MSG_SMB_CONF_UPDATED, smb_conf_updated);
+ message_register(MSG_SMB_STAT_CACHE_DELETE, smb_stat_cache_delete);
#ifdef DEVELOPER
message_register(MSG_SMB_INJECT_FAULT, msg_inject_fault);
diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c
index b453fdd544..1a2b7a8237 100644
--- a/source3/smbd/statcache.c
+++ b/source3/smbd/statcache.c
@@ -285,6 +285,40 @@ BOOL stat_cache_lookup(connection_struct *conn, pstring name, pstring dirpath,
}
}
+/***************************************************************************
+ Tell all smbd's to delete an entry.
+**************************************************************************/
+
+void send_stat_cache_delete_message(const char *name)
+{
+#ifdef DEVELOPER
+ message_send_all(conn_tdb_ctx(),
+ MSG_SMB_STAT_CACHE_DELETE,
+ name,
+ strlen(name)+1,
+ True,
+ NULL);
+#endif
+}
+
+/***************************************************************************
+ Delete an entry.
+**************************************************************************/
+
+void stat_cache_delete(const char *name)
+{
+ char *lname = strdup_upper(name);
+
+ if (!lname) {
+ return;
+ }
+ DEBUG(10,("stat_cache_delete: deleting name [%s] -> %s\n",
+ lname, name ));
+
+ tdb_delete_bystring(tdb_stat_cache, lname);
+ SAFE_FREE(lname);
+}
+
/***************************************************************
Compute a hash value based on a string key value.
The function returns the bucket index number for the hashed key.