From 0de09289ae20040c7c535f18ed7146b1513c5b7d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Thu, 4 Aug 2011 08:56:01 -0400 Subject: [PATCH] s3-printing: Force pcap reload when all ready This way we are sure the cache is primed properly and messages can be sent to processes if necessary as all messaging has been set up. Signed-off-by: Andreas Schneider --- source3/printing/queue_process.c | 12 ++++++++++-- source3/printing/queue_process.h | 3 ++- source3/smbd/process.c | 2 +- source3/smbd/server.c | 6 +++++- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index 5d18a08d63e..82fd70d36d6 100644 --- a/source3/printing/queue_process.c +++ b/source3/printing/queue_process.c @@ -295,9 +295,17 @@ bool printing_subsystem_init(struct tevent_context *ev_ctx, } void printing_subsystem_update(struct tevent_context *ev_ctx, - struct messaging_context *msg_ctx) + struct messaging_context *msg_ctx, + bool force) { - if (background_lpq_updater_pid != -1) return; + if (background_lpq_updater_pid != -1) { + if (force) { + /* Send a sighup to the background process. + * this will force it to reload printers */ + kill(background_lpq_updater_pid, SIGHUP); + } + return; + } pcap_cache_reload(ev_ctx, msg_ctx, &reload_pcap_change_notify); } diff --git a/source3/printing/queue_process.h b/source3/printing/queue_process.h index f0da726058d..5f282c44629 100644 --- a/source3/printing/queue_process.h +++ b/source3/printing/queue_process.h @@ -25,6 +25,7 @@ bool printing_subsystem_init(struct tevent_context *ev_ctx, bool start_daemons, bool background_queue); void printing_subsystem_update(struct tevent_context *ev_ctx, - struct messaging_context *msg_ctx); + struct messaging_context *msg_ctx, + bool force); pid_t start_background_queue(struct tevent_context *ev, struct messaging_context *msg); diff --git a/source3/smbd/process.c b/source3/smbd/process.c index d96d5fb7e01..f542dcd84f3 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -887,7 +887,7 @@ static void smbd_sig_hup_handler(struct tevent_context *ev, DEBUG(1,("Reloading services after SIGHUP\n")); reload_services(msg_ctx, smbd_server_conn->sock, False); if (am_parent) { - printing_subsystem_update(ev, msg_ctx); + printing_subsystem_update(ev, msg_ctx, true); } } diff --git a/source3/smbd/server.c b/source3/smbd/server.c index ee406fdfafb..24d61483e25 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -64,7 +64,7 @@ static void smb_conf_updated(struct messaging_context *msg, change_to_root_user(); reload_services(msg, smbd_server_conn->sock, False); if (am_parent) { - printing_subsystem_update(ev_ctx, msg); + printing_subsystem_update(ev_ctx, msg, false); } } @@ -1260,6 +1260,10 @@ extern void build_options(bool screen); if (!open_sockets_smbd(parent, ev_ctx, msg_ctx, ports)) exit_server("open_sockets_smbd() failed"); + /* force a printer update now that all messaging has been set up, + * before we allow clients to start connecting */ + printing_subsystem_update(ev_ctx, msg_ctx, true); + TALLOC_FREE(frame); /* make sure we always have a valid stackframe */ frame = talloc_stackframe(); -- 2.11.4.GIT