s3: printing: Fix problem with server taking too long to respond to a MSG_PRINTER_DRV...
[amitay/samba.git] / source3 / printing / nt_printing.c
index 376dcfafa82b4f3188d79877188660134e7f3ef9..6a5f2d744a19a8107f82dfb3233463555e205a6f 100644 (file)
@@ -131,6 +131,31 @@ static bool print_driver_directories_init(void)
        return true;
 }
 
+/****************************************************************************
+ Forward a MSG_PRINTER_DRVUPGRADE message from another smbd to the
+ background lpq updater.
+****************************************************************************/
+
+static void forward_drv_upgrade_printer_msg(struct messaging_context *msg,
+                               void *private_data,
+                               uint32_t msg_type,
+                               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);
+}
+
 /****************************************************************************
  Open the NT printing tdbs. Done once before fork().
 ****************************************************************************/
@@ -149,10 +174,10 @@ bool nt_printing_init(struct messaging_context *msg_ctx)
 
        /*
         * register callback to handle updating printers as new
-        * drivers are installed
+        * drivers are installed. Forwards to background lpq updater.
         */
        messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE,
-                          do_drv_upgrade_printer);
+                       forward_drv_upgrade_printer_msg);
 
        /* of course, none of the message callbacks matter if you don't
           tell messages.c that you interested in receiving PRINT_GENERAL