fix race and do a normal close
authorStefan Metzmacher <metze@samba.org>
Thu, 23 Feb 2012 13:45:46 +0000 (14:45 +0100)
committerStefan Metzmacher <metze@samba.org>
Thu, 10 May 2012 16:41:59 +0000 (18:41 +0200)
source3/smbd/close.c

index 03ee59bc4f40032010e7dc0960b1e0e121a85fef..e96d0f31144cd6f134e03711788d3adc3d2ef048 100644 (file)
@@ -683,19 +683,50 @@ static NTSTATUS close_normal_file(struct smb_request *req, files_struct *fsp,
                struct share_mode_lock *lck;
 
                lck = get_existing_share_mode_lock(talloc_tos(), fsp->file_id);
-               if (lck != NULL) {
+               if (lck != NULL && lck->data->num_share_modes == 1) {
                        lck->data->share_modes[0].pid.pid = UINT64_MAX;
                        lck->data->share_modes[0].pid.task_id = UINT32_MAX;
                        lck->data->share_modes[0].pid.vnn = UINT32_MAX;
                        lck->data->share_modes[0].pid.unique_id = UINT64_MAX; //todo place NTTIME expire timer here
                        lck->data->modified = true;
+#if 0
+               } else if (lck != NULL) {
+                       uint32_t i;
+
+                       for (i=0; i < lck->data->num_share_modes; i++) {
+                               struct share_mode_entry *e = &lck->data->share_modes[i];
+                               char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
+
+                               if (procid_is_me(&e->pid)) {
+                                       continue;
+                               }
+
+                               share_mode_entry_to_message(msg, e);
+
+                               messaging_send_buf(fsp->conn->sconn->msg_ctx,
+                                                  e->pid,
+                                                  MSG_SMB_BREAK_RESPONSE,
+                                                  (uint8 *)msg,
+                                                  MSG_SMB_SHARE_MODE_ENTRY_SIZE);
+                       }
+               }
+#endif
+
+                       TALLOC_FREE(lck);
+
+                       tmp = fd_close(fsp);
+                       status = ntstatus_keeperror(status, tmp);
+                       file_free(req, fsp);
+                       return status;
                }
+#if 0
                TALLOC_FREE(lck);
 
                tmp = fd_close(fsp);
                status = ntstatus_keeperror(status, tmp);
                file_free(req, fsp);
                return status;
+#endif
        }
 
        /*