[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Apr 26 18:07:02 MDT 2013


The branch, master has been updated
       via  8283fd0 smbd: Do not fetch the record in defer_open_done
       via  e13021e dbwrap: Allow dbwrap_record_watch_recv to not lock the record
       via  a7e8034 smbd: We don't use DEFERRED_OPEN_ENTRY anymore
       via  8da5a0f smbd: Remove unused smb2_deferred_open_timer
       via  78d4bdc smbd: Obsolete MSG_SMB_OPEN_RETRY
       via  f52a3c3 smbd: Remove the unused fsp->pending_break_messages array
       via  3e7923d smbd: Remove unused reply_to_oplock_break_requests
       via  234edb5 smbd: Obsolete MSG_SMB_BREAK_RESPONSE
       via  4e43761 smbd: Ignore OPEN_RETRY and BREAK_RESPONSE
       via  afe9446 smbd: Use dbwrap_record_watch_send for defer_open
      from  b1574eb bug 9830: fix panic in nt_printer_publish_ads

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 8283fd0e0090ed12b0b12d5acb550642d621b026
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 26 15:13:14 2013 +0200

    smbd: Do not fetch the record in defer_open_done
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Apr 27 02:06:10 CEST 2013 on sn-devel-104

commit e13021e3af7c95c59b5997a6728d2dbd5fd27b8f
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 26 15:12:05 2013 +0200

    dbwrap: Allow dbwrap_record_watch_recv to not lock the record
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a7e803485d0255fa7fa92970ee535e1e2c9a29a1
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 26 15:05:50 2013 +0200

    smbd: We don't use DEFERRED_OPEN_ENTRY anymore
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 8da5a0f1e33a85281610700b58b534bc985894f0
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 26 14:29:42 2013 +0200

    smbd: Remove unused smb2_deferred_open_timer
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 78d4bdc0b837340d39f7f99044ac12be919f8662
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 12 14:12:38 2013 +0200

    smbd: Obsolete MSG_SMB_OPEN_RETRY
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit f52a3c3cd1ef2d6373819a7ba8c724fa9ca374f5
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 12 14:09:12 2013 +0200

    smbd: Remove the unused fsp->pending_break_messages array
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3e7923d7afe7e47883dd7f7ec4e6a57490232105
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 12 14:06:59 2013 +0200

    smbd: Remove unused reply_to_oplock_break_requests
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 234edb525d95ff03d15b9b2db88b3e7479ca0290
Author: Volker Lendecke <vl at samba.org>
Date:   Fri Apr 12 14:03:08 2013 +0200

    smbd: Obsolete MSG_SMB_BREAK_RESPONSE
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 4e4376164bafbd3a883b6ce8033dcd714f971d51
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Apr 10 16:57:32 2013 +0200

    smbd: Ignore OPEN_RETRY and BREAK_RESPONSE
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit afe9446985663ac47036aa79d1b07de8b46cbd3e
Author: Volker Lendecke <vl at samba.org>
Date:   Thu Nov 29 16:10:22 2012 +0100

    smbd: Use dbwrap_record_watch_send for defer_open
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/include/smb.h             |    4 +-
 source3/include/vfs.h             |    5 +-
 source3/lib/dbwrap/dbwrap_watch.c |    3 +
 source3/librpc/idl/messaging.idl  |    4 +-
 source3/libsmb/smb_share_modes.c  |    5 --
 source3/locking/locking.c         |   61 -----------------
 source3/locking/proto.h           |    6 --
 source3/locking/share_mode_lock.c |    3 +
 source3/smbd/close.c              |   95 ---------------------------
 source3/smbd/durable.c            |    4 -
 source3/smbd/open.c               |  124 +++++++++++++++++------------------
 source3/smbd/oplock.c             |  130 +-----------------------------------
 source3/smbd/process.c            |    2 +
 source3/smbd/proto.h              |    3 -
 source3/smbd/reply.c              |    2 -
 source3/smbd/smb2_break.c         |    2 -
 source3/smbd/smb2_create.c        |   59 -----------------
 17 files changed, 78 insertions(+), 434 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/include/smb.h b/source3/include/smb.h
index 0d16e56..9dd8c58 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -673,12 +673,12 @@ enum remote_arch_types {RA_UNKNOWN, RA_WFWG, RA_OS2, RA_WIN95, RA_WINNT,
 #define FAKE_LEVEL_II_OPLOCK 		0x10	/* Client requested no_oplock, but we have to
 				 * inform potential level2 holders on
 				 * write. */
-#define DEFERRED_OPEN_ENTRY 		0x20
+/* #define DEFERRED_OPEN_ENTRY 		0x20 */   /* Not used anymore */
 /* #define UNUSED_SHARE_MODE_ENTRY 	0x40 */   /* Not used anymore */
 #define FORCE_OPLOCK_BREAK_TO_NONE 	0x80
 
 /* None of the following should ever appear in fsp->oplock_request. */
-#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|DEFERRED_OPEN_ENTRY|FORCE_OPLOCK_BREAK_TO_NONE)
+#define SAMBA_PRIVATE_OPLOCK_MASK (INTERNAL_OPEN_ONLY|FORCE_OPLOCK_BREAK_TO_NONE)
 
 #define EXCLUSIVE_OPLOCK_TYPE(lck) ((lck) & ((unsigned int)EXCLUSIVE_OPLOCK|(unsigned int)BATCH_OPLOCK))
 #define BATCH_OPLOCK_TYPE(lck) ((lck) & (unsigned int)BATCH_OPLOCK)
diff --git a/source3/include/vfs.h b/source3/include/vfs.h
index 6d9be77..0e5b074 100644
--- a/source3/include/vfs.h
+++ b/source3/include/vfs.h
@@ -152,6 +152,8 @@
 		connection_struct a pointer. */
 /* Leave at 31 - not yet released. Add share_access to vuid_cache_entry. */
 /* Leave at 31 - not yet released. add SMB_VFS_COPY_CHUNK() */
+/* Leave at 31 - not yet released. Remove the unused
+		fsp->pending_break_messages array */
 
 #define SMB_VFS_INTERFACE_VERSION 31
 
@@ -224,9 +226,6 @@ typedef struct files_struct {
 	struct lock_struct last_lock_failure;
 	int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
-	struct share_mode_entry *pending_break_messages;
-	int num_pending_break_messages;
-
 	bool can_lock;
 	bool can_read;
 	bool can_write;
diff --git a/source3/lib/dbwrap/dbwrap_watch.c b/source3/lib/dbwrap/dbwrap_watch.c
index d8f1b74..7bdcd99 100644
--- a/source3/lib/dbwrap/dbwrap_watch.c
+++ b/source3/lib/dbwrap/dbwrap_watch.c
@@ -401,6 +401,9 @@ NTSTATUS dbwrap_record_watch_recv(struct tevent_req *req,
 	if (tevent_req_is_nterror(req, &status)) {
 		return status;
 	}
+	if (prec == NULL) {
+		return NT_STATUS_OK;
+	}
 	rec = dbwrap_fetch_locked(state->db, mem_ctx, state->key);
 	if (rec == NULL) {
 		return NT_STATUS_INTERNAL_DB_ERROR;
diff --git a/source3/librpc/idl/messaging.idl b/source3/librpc/idl/messaging.idl
index c262889..ddcf0e3 100644
--- a/source3/librpc/idl/messaging.idl
+++ b/source3/librpc/idl/messaging.idl
@@ -66,9 +66,9 @@ interface messaging
 		/* MSG_SMB_SAM_REPL		= 0x0304,  Obsoleted */
 		MSG_SMB_UNLOCK			= 0x0305,
 		MSG_SMB_BREAK_REQUEST		= 0x0306,
-		MSG_SMB_BREAK_RESPONSE		= 0x0307,
+		/* MSG_SMB_BREAK_RESPONSE	= 0x0307,  Obsoleted */
 		MSG_SMB_ASYNC_LEVEL2_BREAK	= 0x0308,
-		MSG_SMB_OPEN_RETRY		= 0x0309,
+		/* MSG_SMB_OPEN_RETRY		= 0x0309,  Obsoleted */
 		MSG_SMB_KERNEL_BREAK		= 0x030A,
 		MSG_SMB_FILE_RENAME		= 0x030B,
 		MSG_SMB_INJECT_FAULT		= 0x030C,
diff --git a/source3/libsmb/smb_share_modes.c b/source3/libsmb/smb_share_modes.c
index f6f8bf9..c29721d 100644
--- a/source3/libsmb/smb_share_modes.c
+++ b/source3/libsmb/smb_share_modes.c
@@ -270,11 +270,6 @@ int smb_get_share_mode_entries(struct smbdb_ctx *db_ctx,
 			continue; /* No longer exists. */
 		}
 
-		/* Ignore deferred open entries. */
-		if (share->op_type == DEFERRED_OPEN_ENTRY) {
-			continue;
-		}
-
 		/* Copy into the external list. */
 		sme->dev = share->id.devid;
 		sme->ino = share->id.inode;
diff --git a/source3/locking/locking.c b/source3/locking/locking.c
index a7fc50c..7e65616 100644
--- a/source3/locking/locking.c
+++ b/source3/locking/locking.c
@@ -627,11 +627,6 @@ bool is_valid_share_mode_entry(const struct share_mode_entry *e)
 	return (num_props != 0);
 }
 
-bool is_deferred_open_entry(const struct share_mode_entry *e)
-{
-	return (e->op_type == DEFERRED_OPEN_ENTRY);
-}
-
 /*
  * In case d->share_modes[i] conflicts with something or otherwise is
  * being used, we need to make sure the corresponding process still
@@ -699,23 +694,6 @@ static void fill_share_mode_entry(struct share_mode_entry *e,
 	e->name_hash = fsp->name_hash;
 }
 
-static void fill_deferred_open_entry(struct share_mode_entry *e,
-				     const struct timeval request_time,
-				     struct file_id id,
-				     struct server_id pid,
-				     uint64_t mid)
-{
-	ZERO_STRUCTP(e);
-	e->pid = pid;
-	e->op_mid = mid;
-	e->op_type = DEFERRED_OPEN_ENTRY;
-	e->time.tv_sec = request_time.tv_sec;
-	e->time.tv_usec = request_time.tv_usec;
-	e->id = id;
-	e->uid = (uint32)-1;
-	e->flags = 0;
-}
-
 static void add_share_mode_entry(struct share_mode_data *d,
 				 const struct share_mode_entry *entry)
 {
@@ -732,15 +710,6 @@ void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
 	add_share_mode_entry(lck->data, &entry);
 }
 
-void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
-		       struct timeval request_time,
-		       struct server_id pid, struct file_id id)
-{
-	struct share_mode_entry entry;
-	fill_deferred_open_entry(&entry, request_time, id, pid, mid);
-	add_share_mode_entry(lck->data, &entry);
-}
-
 /*******************************************************************
  Check if two share mode entries are identical, ignoring oplock 
  and mid info and desired_access. (Removed paranoia test - it's
@@ -760,14 +729,6 @@ static bool share_modes_identical(struct share_mode_entry *e1,
 		e1->share_file_id == e2->share_file_id );
 }
 
-static bool deferred_open_identical(struct share_mode_entry *e1,
-				    struct share_mode_entry *e2)
-{
-	return (serverid_equal(&e1->pid, &e2->pid) &&
-		(e1->op_mid == e2->op_mid) &&
-		file_id_equal(&e1->id, &e2->id));
-}
-
 static struct share_mode_entry *find_share_mode_entry(struct share_mode_data *d,
 						      struct share_mode_entry *entry)
 {
@@ -780,11 +741,6 @@ static struct share_mode_entry *find_share_mode_entry(struct share_mode_data *d,
 		    share_modes_identical(e, entry)) {
 			return e;
 		}
-		if (is_deferred_open_entry(entry) &&
-		    is_deferred_open_entry(e) &&
-		    deferred_open_identical(e, entry)) {
-			return e;
-		}
 	}
 	return NULL;
 }
@@ -849,23 +805,6 @@ bool mark_share_mode_disconnected(struct share_mode_lock *lck,
 	return true;
 }
 
-void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
-			     struct server_id pid)
-{
-	struct share_mode_entry entry, *e;
-
-	fill_deferred_open_entry(&entry, timeval_zero(),
-				 lck->data->id, pid, mid);
-
-	e = find_share_mode_entry(lck->data, &entry);
-	if (e == NULL) {
-		return;
-	}
-	*e = lck->data->share_modes[lck->data->num_share_modes-1];
-	lck->data->num_share_modes -= 1;
-	lck->data->modified = True;
-}
-
 /*******************************************************************
  Remove an oplock mid and mode entry from a share mode.
 ********************************************************************/
diff --git a/source3/locking/proto.h b/source3/locking/proto.h
index bb7255d..adb30b7 100644
--- a/source3/locking/proto.h
+++ b/source3/locking/proto.h
@@ -170,18 +170,12 @@ void get_file_infos(struct file_id id,
 		    bool *delete_on_close,
 		    struct timespec *write_time);
 bool is_valid_share_mode_entry(const struct share_mode_entry *e);
-bool is_deferred_open_entry(const struct share_mode_entry *e);
 bool share_mode_stale_pid(struct share_mode_data *d, unsigned i);
 void set_share_mode(struct share_mode_lock *lck, files_struct *fsp,
 		    uid_t uid, uint64_t mid, uint16 op_type);
-void add_deferred_open(struct share_mode_lock *lck, uint64_t mid,
-		       struct timeval request_time,
-		       struct server_id pid, struct file_id id);
 bool del_share_mode(struct share_mode_lock *lck, files_struct *fsp);
 bool mark_share_mode_disconnected(struct share_mode_lock *lck,
 				  struct files_struct *fsp);
-void del_deferred_open_entry(struct share_mode_lock *lck, uint64_t mid,
-			     struct server_id pid);
 bool remove_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 bool downgrade_share_oplock(struct share_mode_lock *lck, files_struct *fsp);
 bool get_delete_on_close_token(struct share_mode_lock *lck,
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index d45b450..0693cf5 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -46,6 +46,7 @@
 #include "messages.h"
 #include "util_tdb.h"
 #include "../librpc/gen_ndr/ndr_open_files.h"
+#include "source3/lib/dbwrap/dbwrap_watch.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_LOCKING
@@ -76,6 +77,8 @@ static bool locking_init_internal(bool read_only)
 	if (!posix_locking_init(read_only))
 		return False;
 
+	dbwrap_watch_db(lock_db, server_messaging_context());
+
 	return True;
 }
 
diff --git a/source3/smbd/close.c b/source3/smbd/close.c
index 46aa356..94ec789 100644
--- a/source3/smbd/close.c
+++ b/source3/smbd/close.c
@@ -165,97 +165,6 @@ static int compare_share_mode_times(const void *p1, const void *p2)
 }
 
 /****************************************************************************
- If any deferred opens are waiting on this close, notify them.
-****************************************************************************/
-
-static void notify_deferred_opens(struct smbd_server_connection *sconn,
-				  struct share_mode_lock *lck)
-{
-	struct server_id self = messaging_server_id(sconn->msg_ctx);
-	uint32_t i, num_deferred;
-	struct share_mode_entry *deferred;
-
-	if (!should_notify_deferred_opens(sconn)) {
-		return;
-	}
-
-	num_deferred = 0;
-	for (i=0; i<lck->data->num_share_modes; i++) {
-		struct share_mode_entry *e = &lck->data->share_modes[i];
-
-		if (!is_deferred_open_entry(e)) {
-			continue;
-		}
-		if (share_mode_stale_pid(lck->data, i)) {
-			continue;
-		}
-		num_deferred += 1;
-	}
-	if (num_deferred == 0) {
-		return;
-	}
-
-	deferred = talloc_array(talloc_tos(), struct share_mode_entry,
-				num_deferred);
-	if (deferred == NULL) {
-		return;
-	}
-
-	num_deferred = 0;
-	for (i=0; i<lck->data->num_share_modes; i++) {
-		struct share_mode_entry *e = &lck->data->share_modes[i];
-		if (is_deferred_open_entry(e)) {
-			deferred[num_deferred] = *e;
-			num_deferred += 1;
-		}
-	}
-
-	/*
-	 * We need to sort the notifications by initial request time. Imagine
-	 * two opens come in asyncronously, both conflicting with the open we
-	 * just close here. If we don't sort the notifications, the one that
-	 * came in last might get the response before the one that came in
-	 * first. This is demonstrated with the smbtorture4 raw.mux test.
-	 *
-	 * As long as we had the UNUSED_SHARE_MODE_ENTRY, we happened to
-	 * survive this particular test. Without UNUSED_SHARE_MODE_ENTRY, we
-	 * shuffle the share mode entries around a bit, so that we do not
-	 * survive raw.mux anymore.
-	 *
-	 * We could have kept the ordering in del_share_mode, but as the
-	 * ordering was never formalized I think it is better to do it here
-	 * where it is necessary.
-	 */
-
-	qsort(deferred, num_deferred, sizeof(struct share_mode_entry),
-	      compare_share_mode_times);
-
-	for (i=0; i<num_deferred; i++) {
-		struct share_mode_entry *e = &deferred[i];
-
-		if (serverid_equal(&self, &e->pid)) {
- 			/*
- 			 * We need to notify ourself to retry the open.  Do
- 			 * this by finding the queued SMB record, moving it to
- 			 * the head of the queue and changing the wait time to
- 			 * zero.
- 			 */
-			schedule_deferred_open_message_smb(sconn, e->op_mid);
- 		} else {
-			char msg[MSG_SMB_SHARE_MODE_ENTRY_SIZE];
-
-			share_mode_entry_to_message(msg, e);
-
-			messaging_send_buf(sconn->msg_ctx, e->pid,
-					   MSG_SMB_OPEN_RETRY,
-					   (uint8 *)msg,
-					   MSG_SMB_SHARE_MODE_ENTRY_SIZE);
- 		}
- 	}
-	TALLOC_FREE(deferred);
-}
-
-/****************************************************************************
  Delete all streams
 ****************************************************************************/
 
@@ -440,10 +349,6 @@ static NTSTATUS close_remove_share_mode(files_struct *fsp,
 		}
 	}
 
-	/* Notify any deferred opens waiting on this close. */
-	notify_deferred_opens(conn->sconn, lck);
-	reply_to_oplock_break_requests(fsp);
-
 	/*
 	 * NT can set delete_on_close of the last open
 	 * reference to a file.
diff --git a/source3/smbd/durable.c b/source3/smbd/durable.c
index cf837aa..69ba109 100644
--- a/source3/smbd/durable.c
+++ b/source3/smbd/durable.c
@@ -173,10 +173,6 @@ NTSTATUS vfs_default_durable_disconnect(struct files_struct *fsp,
 		return NT_STATUS_NOT_SUPPORTED;
 	}
 
-	if (fsp->num_pending_break_messages > 0) {
-		return NT_STATUS_NOT_SUPPORTED;
-	}
-
 	/*
 	 * For now let it be simple and do not keep
 	 * delete on close files durable open
diff --git a/source3/smbd/open.c b/source3/smbd/open.c
index 0d9698a..7d02e52 100644
--- a/source3/smbd/open.c
+++ b/source3/smbd/open.c
@@ -33,6 +33,7 @@
 #include "auth.h"
 #include "serverid.h"
 #include "messages.h"
+#include "source3/lib/dbwrap/dbwrap_watch.h"
 
 extern const struct generic_mapping file_generic_mapping;
 
@@ -1024,16 +1025,6 @@ static void validate_my_share_entries(struct smbd_server_connection *sconn,
 		return;
 	}
 
-	if (is_deferred_open_entry(share_entry) &&
-	    !open_was_deferred(sconn, share_entry->op_mid))
-	{
-		char *str = talloc_asprintf(talloc_tos(),
-			"Got a deferred entry without a request: "
-			"PANIC: %s\n",
-			share_mode_str(talloc_tos(), num, share_entry));
-		smb_panic(str);
-	}
-
 	if (!is_valid_share_mode_entry(share_entry)) {
 		return;
 	}
@@ -1047,10 +1038,6 @@ static void validate_my_share_entries(struct smbd_server_connection *sconn,
 			  "share entry with an open file\n");
 	}
 
-	if (is_deferred_open_entry(share_entry)) {
-		goto panic;
-	}
-
 	if ((share_entry->op_type == NO_OPLOCK) &&
 	    (fsp->oplock_type == FAKE_LEVEL_II_OPLOCK))
 	{
@@ -1457,6 +1444,13 @@ static bool request_timed_out(struct timeval request_time,
 	return (timeval_compare(&end_time, &now) < 0);
 }
 
+struct defer_open_state {
+	struct smbd_server_connection *sconn;
+	uint64_t mid;
+};
+
+static void defer_open_done(struct tevent_req *req);
+
 /****************************************************************************
  Handle the 1 second delay in returning a SHARING_VIOLATION error.
 ****************************************************************************/
@@ -1467,30 +1461,6 @@ static void defer_open(struct share_mode_lock *lck,
 		       struct smb_request *req,
 		       struct deferred_open_record *state)
 {
-	struct server_id self = messaging_server_id(req->sconn->msg_ctx);
-
-	/* Paranoia check */
-
-	if (lck) {
-		int i;
-
-		for (i=0; i<lck->data->num_share_modes; i++) {
-			struct share_mode_entry *e = &lck->data->share_modes[i];
-
-			if (is_deferred_open_entry(e) &&
-			    serverid_equal(&self, &e->pid) &&
-			    (e->op_mid == req->mid)) {
-				DEBUG(0, ("Trying to defer an already deferred "
-					"request: mid=%llu, exiting\n",
-					(unsigned long long)req->mid));
-				TALLOC_FREE(lck);
-				exit_server("attempt to defer a deferred request");
-			}
-		}
-	}
-
-	/* End paranoia check */
-
 	DEBUG(10,("defer_open_sharing_error: time [%u.%06u] adding deferred "
 		  "open entry for mid %llu\n",
 		  (unsigned int)request_time.tv_sec,
@@ -1503,8 +1473,59 @@ static void defer_open(struct share_mode_lock *lck,
 		exit_server("push_deferred_open_message_smb failed");
 	}
 	if (lck) {
-		add_deferred_open(lck, req->mid, request_time, self, state->id);
+		struct defer_open_state *watch_state;
+		struct tevent_req *watch_req;
+		bool ret;
+
+		watch_state = talloc(req->sconn, struct defer_open_state);
+		if (watch_state == NULL) {
+			exit_server("talloc failed");
+		}
+		watch_state->sconn = req->sconn;
+		watch_state->mid = req->mid;
+
+		DEBUG(10, ("defering mid %llu\n",
+			   (unsigned long long)req->mid));
+
+		watch_req = dbwrap_record_watch_send(
+			watch_state, req->sconn->ev_ctx, lck->data->record,
+			req->sconn->msg_ctx);
+		if (watch_req == NULL) {
+			exit_server("Could not watch share mode record");
+		}
+		tevent_req_set_callback(watch_req, defer_open_done,
+					watch_state);
+
+		ret = tevent_req_set_endtime(
+			watch_req, req->sconn->ev_ctx,
+			timeval_sum(&request_time, &timeout));
+		SMB_ASSERT(ret);
+	}
+}
+
+static void defer_open_done(struct tevent_req *req)
+{
+	struct defer_open_state *state = tevent_req_callback_data(
+		req, struct defer_open_state);
+	NTSTATUS status;
+	bool ret;
+
+	status = dbwrap_record_watch_recv(req, talloc_tos(), NULL);
+	TALLOC_FREE(req);
+	if (!NT_STATUS_IS_OK(status)) {
+		DEBUG(5, ("dbwrap_record_watch_recv returned %s\n",
+			  nt_errstr(status)));
+		/*


-- 
Samba Shared Repository


More information about the samba-cvs mailing list