1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r20916: Add in the delete on close final fix - but only enabled

with -DDEVELOPER.
Jeremy.
(This used to be commit 7f817067a7)
This commit is contained in:
Jeremy Allison 2007-01-19 21:46:12 +00:00 committed by Gerald (Jerry) Carter
parent cce97a9b50
commit aacd16e7c4
7 changed files with 63 additions and 0 deletions

View File

@ -72,6 +72,7 @@
#define MSG_SMB_INJECT_FAULT 3012
#define MSG_SMB_BLOCKING_LOCK_CANCEL 3013
#define MSG_SMB_NOTIFY 3014
#define MSG_SMB_STAT_CACHE_DELETE 3015
/* winbind messages */
#define MSG_WINBIND_FINISHED 4001

View File

@ -53,3 +53,7 @@ const char *dptr_ReadDirName(struct dptr_struct *dptr, long *poffset, SMB_STRUCT
{
return NULL;
}
void send_stat_cache_delete_message(const char *name)
{
}

View File

@ -1281,6 +1281,10 @@ BOOL set_delete_on_close(files_struct *fsp, BOOL delete_on_close, UNIX_USER_TOKE
set_delete_on_close_lck(lck, delete_on_close, tok);
if (fsp->is_directory) {
send_stat_cache_delete_message(fsp->fsp_name);
}
TALLOC_FREE(lck);
return True;
}

View File

@ -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();

View File

@ -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.
*/

View File

@ -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);

View File

@ -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.