[PATCH 6/6] s3-printing: call pcap cache callback unconditionally

David Disseldorp ddiss at suse.de
Fri Jun 17 05:39:21 MDT 2011


Previously the post printcap cache fill callback was only invoked if the
fill was successful. Such behaviour does not conform to common callback
semantics, and is undesirable for printcap reloads occurring on startup
prior to printing tdb migration.

This and the last four commits address:
https://bugzilla.samba.org/show_bug.cgi?id=8235
---
 source3/printing/pcap.c           |   16 +++++++++-------
 source3/printing/print_cups.c     |    4 +---
 source3/printing/spoolssd.c       |    9 +++++----
 source3/rpc_server/rpc_ep_setup.c |   10 ++++++----
 source3/smbd/server_reload.c      |    6 +++++-
 5 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/source3/printing/pcap.c b/source3/printing/pcap.c
index 0a5f7a9..a9e6586 100644
--- a/source3/printing/pcap.c
+++ b/source3/printing/pcap.c
@@ -189,13 +189,15 @@ void pcap_cache_reload(struct tevent_context *ev,
 done:
 	DEBUG(3, ("reload status: %s\n", (pcap_reloaded) ? "ok" : "error"));
 
-	if ((pcap_reloaded) && (post_cache_fill_fn_handled == false)) {
-		/* cleanup old entries only if the operation was successful,
-		 * otherwise keep around the old entries until we can
-		 * successfuly reaload */
-		status = printer_list_clean_old();
-		if (!NT_STATUS_IS_OK(status)) {
-			DEBUG(0, ("Failed to cleanup printer list!\n"));
+	if (post_cache_fill_fn_handled == false) {
+		if (pcap_reloaded) {
+			/* cleanup old entries only if the operation was successful,
+			 * otherwise keep around the old entries until we can
+			 * successfuly reaload */
+			status = printer_list_clean_old();
+			if (!NT_STATUS_IS_OK(status)) {
+				DEBUG(0, ("Failed to cleanup printer list!\n"));
+			}
 		}
 		if (post_cache_fill_fn != NULL) {
 			post_cache_fill_fn(ev, msg_ctx, pcap_reloaded);
diff --git a/source3/printing/print_cups.c b/source3/printing/print_cups.c
index 4453801..3304391 100644
--- a/source3/printing/print_cups.c
+++ b/source3/printing/print_cups.c
@@ -502,9 +502,7 @@ static void cups_async_callback(struct event_context *event_ctx,
 
 	/* replace the system-wide pcap cache with a (possibly empty) new one */
 	ret_ok = pcap_cache_replace(tmp_pcap_cache);
-	if (!ret_ok) {
-		DEBUG(0, ("failed to replace pcap cache\n"));
-	} else if (cb_args->post_cache_fill_fn != NULL) {
+	if (cb_args->post_cache_fill_fn != NULL) {
 		/* Caller requested post cache fill callback */
 		cb_args->post_cache_fill_fn(cb_args->event_ctx,
 					    cb_args->msg_ctx,
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index a32f229..4de4a11 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -138,6 +138,11 @@ static void spoolss_init_pcap_cb(struct tevent_context *ev,
 {
 	bool ok;
 
+	if (!reload_ok) {
+		DEBUG(0,("pcap reload failed, performing tdb migration with "
+			 "stale printer listing\n"));
+	}
+
 	load_printers(ev, msg_ctx);
 
 	ok = print_backend_init(msg_ctx);
@@ -157,10 +162,6 @@ static bool spoolss_init_cb(void *ptr)
 	struct messaging_context *msg_ctx = talloc_get_type_abort(
 		ptr, struct messaging_context);
 
-	/*
-	 * TODO pcap_cache_reload must be changed to call it's callback
-	 * unconditionally.
-	 */
 	pcap_cache_reload(server_event_context(), msg_ctx,
 			  &spoolss_init_pcap_cb);
 
diff --git a/source3/rpc_server/rpc_ep_setup.c b/source3/rpc_server/rpc_ep_setup.c
index 1a68451..2734f68 100644
--- a/source3/rpc_server/rpc_ep_setup.c
+++ b/source3/rpc_server/rpc_ep_setup.c
@@ -663,6 +663,11 @@ static void spoolss_init_pcap_cb(struct tevent_context *ev,
 {
 	bool ok;
 
+	if (!reload_ok) {
+		DEBUG(0,("pcap reload failed, performing tdb migration with "
+			 "stale printer listing\n"));
+	}
+
 	load_printers(ev, msg_ctx);
 
 	ok = print_backend_init(msg_ctx);
@@ -686,10 +691,7 @@ static bool spoolss_init_cb(void *ptr)
 					   "rpc_server",
 					   "epmapper",
 					   "none");
-	/*
-	 * TODO pcap_cache_reload must be changed to call it's callback
-	 * unconditionally.
-	 */
+
 	pcap_cache_reload(ep_ctx->ev_ctx, ep_ctx->msg_ctx,
 			  &spoolss_init_pcap_cb);
 
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index 9386eb1..8a50879 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -146,5 +146,9 @@ void reload_pcap_change_notify(struct tevent_context *ev,
 			       struct messaging_context *msg_ctx,
 			       bool reload_ok)
 {
-	message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
+	if (reload_ok) {
+		message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
+	} else {
+		DEBUG(0, ("pcap reload failed, not changing change notify\n"));
+	}
 }
-- 
1.7.1



More information about the samba-technical mailing list