diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 65b66130a9b..b172ed92c6e 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -21,6 +21,7 @@ #include "includes.h" #include "printing/nt_printing_tdb.h" +#include "printing/queue_process.h" #include "../librpc/gen_ndr/ndr_spoolss.h" #include "rpc_server/spoolss/srv_spoolss_util.h" #include "nt_printing.h" @@ -29,7 +30,6 @@ #include "../libcli/security/security.h" #include "passdb/machine_sid.h" #include "smbd/smbd.h" -#include "smbd/globals.h" #include "auth.h" #include "messages.h" #include "rpc_server/spoolss/srv_spoolss_nt.h" @@ -201,18 +201,7 @@ static void forward_drv_upgrade_printer_msg(struct messaging_context *msg, struct server_id server_id, DATA_BLOB *data) { - extern pid_t background_lpq_updater_pid; - - if (background_lpq_updater_pid == -1) { - DEBUG(3,("no background lpq queue updater\n")); - return; - } - - messaging_send_buf(msg, - pid_to_procid(background_lpq_updater_pid), - MSG_PRINTER_DRVUPGRADE, - data->data, - data->length); + send_to_bgqd(msg, msg_type, data->data, data->length); } /**************************************************************************** diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 219e9050eb6..982eb4f9cdd 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -1553,8 +1553,6 @@ void print_queue_receive(struct messaging_context *msg, update the internal database from the system print queue for a queue ****************************************************************************/ -extern pid_t background_lpq_updater_pid; - static void print_queue_update(struct messaging_context *msg_ctx, int snum, bool force) { @@ -1679,8 +1677,7 @@ static void print_queue_update(struct messaging_context *msg_ctx, /* finally send the message */ - messaging_send_buf(msg_ctx, pid_to_procid(background_lpq_updater_pid), - MSG_PRINTER_UPDATE, (uint8_t *)buffer, len); + send_to_bgqd(msg_ctx, MSG_PRINTER_UPDATE, (uint8_t *)buffer, len); SAFE_FREE( buffer ); diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c index 0867784bf89..9e1d21469ff 100644 --- a/source3/printing/queue_process.c +++ b/source3/printing/queue_process.c @@ -41,6 +41,7 @@ #include "nt_printing.h" #include "util_event.h" #include "lib/global_contexts.h" +#include "lib/util/pidfile.h" /** * @brief Purge stale printers and reload from pre-populated pcap cache. @@ -483,3 +484,17 @@ void printing_subsystem_update(struct tevent_context *ev_ctx, pcap_cache_reload(ev_ctx, msg_ctx, delete_and_reload_printers_full); } + +void send_to_bgqd(struct messaging_context *msg_ctx, + uint32_t msg_type, + const uint8_t *buf, + size_t buflen) +{ + pid_t bgqd = pidfile_pid(lp_pid_directory(), "samba-bgqd"); + + if (bgqd == -1) { + return; + } + messaging_send_buf( + msg_ctx, pid_to_procid(bgqd), msg_type, buf, buflen); +} diff --git a/source3/printing/queue_process.h b/source3/printing/queue_process.h index 9e87d862166..a414f7d7edc 100644 --- a/source3/printing/queue_process.h +++ b/source3/printing/queue_process.h @@ -36,6 +36,10 @@ void printing_subsystem_update(struct tevent_context *ev_ctx, pid_t start_background_queue(struct tevent_context *ev, struct messaging_context *msg, char *logfile); +void send_to_bgqd(struct messaging_context *msg_ctx, + uint32_t msg_type, + const uint8_t *buf, + size_t buflen); struct bq_state; struct bq_state *register_printing_bq_handlers( diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c index 67cd20684fd..6eb1a82627f 100644 --- a/source3/printing/spoolssd.c +++ b/source3/printing/spoolssd.c @@ -554,8 +554,7 @@ static void print_queue_forward(struct messaging_context *msg, struct server_id server_id, DATA_BLOB *data) { - messaging_send_buf(msg, pid_to_procid(background_lpq_updater_pid), - MSG_PRINTER_UPDATE, data->data, data->length); + send_to_bgqd(msg, msg_type, data->data, data->length); } static char *get_bq_logfile(void)