]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
printing: Avoid a few references to background_lpq_updater_pid
authorVolker Lendecke <vl@samba.org>
Fri, 30 Apr 2021 19:52:00 +0000 (21:52 +0200)
committerJeremy Allison <jra@samba.org>
Tue, 11 May 2021 23:45:21 +0000 (23:45 +0000)
We have the bgqd in the pidfile now

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue May 11 23:45:21 UTC 2021 on sn-devel-184

source3/printing/nt_printing.c
source3/printing/printing.c
source3/printing/queue_process.c
source3/printing/queue_process.h
source3/printing/spoolssd.c

index 65b66130a9b34e8b5df746fd84cd59b5aa236247..b172ed92c6e6fc2b0095b149eeb9f1a2bd916337 100644 (file)
@@ -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);
 }
 
 /****************************************************************************
index 219e9050eb6e14cf2c35e98a5bc9ffa4057bf0c9..982eb4f9cddaf699ea27517a22bdc26c4256ec70 100644 (file)
@@ -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 );
 
index 0867784bf8989e7b69858423e741d1e20ef4d21a..9e1d21469ffb774157902cff8d9f34bb0a7c554e 100644 (file)
@@ -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);
+}
index 9e87d86216683d2bc4906b2ecb7f920aebfa8df5..a414f7d7edca693df6deaf2cfa58ab7c31e05a71 100644 (file)
@@ -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(
index 67cd20684fdc29b93e1bc643b7eae59d4dfc1703..6eb1a82627ff707b13a22067202128a54c8f7013 100644 (file)
@@ -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)