]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:smbd/close: call del_share_mode() directly before TALLOC_FREE(lck)
authorStefan Metzmacher <metze@samba.org>
Sat, 2 Jun 2012 12:06:29 +0000 (14:06 +0200)
committerStefan Metzmacher <metze@samba.org>
Sun, 3 Jun 2012 19:08:19 +0000 (21:08 +0200)
metze

Autobuild-User: Stefan Metzmacher <metze@samba.org>
Autobuild-Date: Sun Jun  3 21:08:19 CEST 2012 on sn-devel-104

source3/smbd/close.c

index adcd67a5f501d125b4f7380782ecae8289aa411d..1fb7bdeb84da8ed4237b740cad5f50090f46bfa5 100644 (file)
@@ -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);