A few cosmetic patches

Volker Lendecke Volker.Lendecke at SerNet.DE
Fri Aug 16 07:13:08 MDT 2013


Hi!

Please review&push.

Thanks,

Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 4de81d5107d090468332bee5dff177a8467afb44 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 16 Aug 2013 11:32:08 +0000
Subject: [PATCH 1/4] tevent: Remove a pointless goto

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 lib/tevent/tevent_wakeup.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/lib/tevent/tevent_wakeup.c b/lib/tevent/tevent_wakeup.c
index 82c3942..e217f33 100644
--- a/lib/tevent/tevent_wakeup.c
+++ b/lib/tevent/tevent_wakeup.c
@@ -46,12 +46,9 @@ struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
 	state->wakeup_time = wakeup_time;
 
 	if (!tevent_req_set_endtime(req, ev, wakeup_time)) {
-		goto post;
+		return tevent_req_post(req, ev);
 	}
-
 	return req;
-post:
-	return tevent_req_post(req, ev);
 }
 
 bool tevent_wakeup_recv(struct tevent_req *req)
-- 
1.8.1.2


From 89dd7c3d1b7739b19aff2137519c1dc8d7cf3a7a Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 16 Aug 2013 11:40:38 +0000
Subject: [PATCH 2/4] smbd: Replace a 0-timeout wakeup_send

A tevent_immediate is simpler and is what we want here.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/oplock.c | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 05b0d0b..4f53ff4 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -632,7 +632,9 @@ struct break_to_none_state {
 	struct smbd_server_connection *sconn;
 	struct file_id id;
 };
-static void do_break_to_none(struct tevent_req *req);
+static void do_break_to_none(struct tevent_context *ctx,
+			     struct tevent_immediate *im,
+			     void *private_data);
 
 /****************************************************************************
  This function is called on any file modification or lock request. If a file
@@ -644,7 +646,7 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
 					      enum level2_contention_type type)
 {
 	struct smbd_server_connection *sconn = fsp->conn->sconn;
-	struct tevent_req *req;
+	struct tevent_immediate *im;
 	struct break_to_none_state *state;
 
 	/*
@@ -673,31 +675,25 @@ static void contend_level2_oplocks_begin_default(files_struct *fsp,
 	state->sconn = sconn;
 	state->id = fsp->file_id;
 
-	req = tevent_wakeup_send(state, sconn->ev_ctx, timeval_set(0, 0));
-	if (req == NULL) {
-		DEBUG(1, ("tevent_wakeup_send failed\n"));
+	im = tevent_create_immediate(state);
+	if (im == NULL) {
+		DEBUG(1, ("tevent_create_immediate failed\n"));
 		TALLOC_FREE(state);
 		return;
 	}
-	tevent_req_set_callback(req, do_break_to_none, state);
-	return;
+	tevent_schedule_immediate(im, sconn->ev_ctx, do_break_to_none, state);
 }
 
-static void do_break_to_none(struct tevent_req *req)
+static void do_break_to_none(struct tevent_context *ctx,
+			     struct tevent_immediate *im,
+			     void *private_data)
 {
-	struct break_to_none_state *state = tevent_req_callback_data(
-		req, struct break_to_none_state);
+	struct break_to_none_state *state = talloc_get_type_abort(
+		private_data, struct break_to_none_state);
 	struct server_id self = messaging_server_id(state->sconn->msg_ctx);
-	bool ret;
 	int i;
 	struct share_mode_lock *lck;
 
-	ret = tevent_wakeup_recv(req);
-	TALLOC_FREE(req);
-	if (!ret) {
-		DEBUG(1, ("tevent_wakeup_recv failed\n"));
-		goto done;
-	}
 	lck = get_existing_share_mode_lock(talloc_tos(), state->id);
 	if (lck == NULL) {
 		DEBUG(1, ("release_level_2_oplocks_on_change: failed to lock "
-- 
1.8.1.2


From 3ed99289b52307d6ddbb69046e9e1f557c5696a9 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 16 Aug 2013 12:47:10 +0000
Subject: [PATCH 3/4] smbd: Make break_level2_to_none_async static

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/oplock.c | 2 +-
 source3/smbd/proto.h  | 1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 4f53ff4..8cb5a76 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -388,7 +388,7 @@ static void send_break_message_smb1(files_struct *fsp, int level)
 	TALLOC_FREE(break_msg);
 }
 
-void break_level2_to_none_async(files_struct *fsp)
+static void break_level2_to_none_async(files_struct *fsp)
 {
 	struct smbd_server_connection *sconn = fsp->conn->sconn;
 
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 9c76609..f572c35 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -664,7 +664,6 @@ void release_file_oplock(files_struct *fsp);
 bool remove_oplock(files_struct *fsp);
 bool downgrade_oplock(files_struct *fsp);
 bool should_notify_deferred_opens(struct smbd_server_connection *sconn);
-void break_level2_to_none_async(files_struct *fsp);
 void contend_level2_oplocks_begin(files_struct *fsp,
 				  enum level2_contention_type type);
 void contend_level2_oplocks_end(files_struct *fsp,
-- 
1.8.1.2


From b744047bda797785375406b5d5d764aa37d97efd Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Fri, 16 Aug 2013 13:01:10 +0000
Subject: [PATCH 4/4] smbd: Do not wait unnecessarily

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/smbd/oplock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/source3/smbd/oplock.c b/source3/smbd/oplock.c
index 8cb5a76..fbdd6c8 100644
--- a/source3/smbd/oplock.c
+++ b/source3/smbd/oplock.c
@@ -760,8 +760,8 @@ static void do_break_to_none(struct tevent_context *ctx,
 				initial_break_processing(state->sconn,
 					share_entry->id,
 					share_entry->share_file_id);
-			wait_before_sending_break();
 			if (cur_fsp != NULL) {
+				wait_before_sending_break();
 				break_level2_to_none_async(cur_fsp);
 			} else {
 				DEBUG(3, ("release_level_2_oplocks_on_change: "
-- 
1.8.1.2



More information about the samba-technical mailing list