From abcd095847c7438c3be39f6c9200a04c90394ed6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Sat, 2 Jun 2012 14:06:29 +0200 Subject: s3:smbd/close: call del_share_mode() directly before TALLOC_FREE(lck) metze Autobuild-User: Stefan Metzmacher Autobuild-Date: Sun Jun 3 21:08:19 CEST 2012 on sn-devel-104 --- source3/smbd/close.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'source3') diff --git a/source3/smbd/close.c b/source3/smbd/close.c index adcd67a5f5..1fb7bdeb84 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -1047,6 +1047,7 @@ static NTSTATUS rmdir_internals(TALLOC_CTX *ctx, files_struct *fsp) static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, enum file_close_type close_type) { + struct server_id self = messaging_server_id(fsp->conn->sconn->msg_ctx); struct share_mode_lock *lck = NULL; bool delete_dir = False; NTSTATUS status = NT_STATUS_OK; @@ -1066,11 +1067,6 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, return NT_STATUS_INVALID_PARAMETER; } - if (!del_share_mode(lck, fsp)) { - DEBUG(0, ("close_directory: Could not delete share entry for " - "%s\n", fsp_str_dbg(fsp))); - } - if (fsp->initial_delete_on_close) { bool became_user = False; @@ -1107,6 +1103,10 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, if (fsp->posix_open && (e->flags & SHARE_MODE_FLAG_POSIX_OPEN)) { continue; } + if (procid_equal(&self, &e->pid) && + (e->share_file_id == fsp->fh->gen_id)) { + continue; + } if (share_mode_stale_pid(lck->data, i)) { continue; } @@ -1131,6 +1131,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, del_token->groups, del_nt_token); + if (!del_share_mode(lck, fsp)) { + DEBUG(0, ("close_directory: Could not delete share entry for " + "%s\n", fsp_str_dbg(fsp))); + } + TALLOC_FREE(lck); if ((fsp->conn->fs_capabilities & FILE_NAMED_STREAMS) @@ -1162,6 +1167,11 @@ static NTSTATUS close_directory(struct smb_request *req, files_struct *fsp, remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_DELETE_PENDING); } } else { + if (!del_share_mode(lck, fsp)) { + DEBUG(0, ("close_directory: Could not delete share entry for " + "%s\n", fsp_str_dbg(fsp))); + } + TALLOC_FREE(lck); remove_pending_change_notify_requests_by_fid( fsp, NT_STATUS_OK); -- cgit