diff --git a/source3/include/printing.h b/source3/include/printing.h index c511fa2..8e91028 100644 --- a/source3/include/printing.h +++ b/source3/include/printing.h @@ -242,6 +242,11 @@ void rap_jobid_delete(const char* sharename, uint32 jobid); bool print_backend_init(struct messaging_context *msg_ctx); void start_background_queue(struct tevent_context *ev, struct messaging_context *msg); +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); void printing_end(void); /* The following definitions come from printing/lpq_parse.c */ diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c index 05c53ec..dc620a8 100644 --- a/source3/printing/nt_printing.c +++ b/source3/printing/nt_printing.c @@ -33,6 +33,7 @@ #include "messages.h" #include "rpc_server/spoolss/srv_spoolss_nt.h" #include "rpc_client/cli_winreg_spoolss.h" +#include "printing.h" /* Map generic permissions to printer object specific permissions */ @@ -87,10 +88,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 diff --git a/source3/printing/printing.c b/source3/printing/printing.c index 16821ae..249d4cc 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -33,6 +33,7 @@ #include "auth.h" #include "messages.h" #include "util_tdb.h" +#include "rpc_server/spoolss/srv_spoolss_nt.h" extern struct current_user current_user; extern userdom_struct current_user_info; @@ -1810,6 +1811,11 @@ void start_background_queue(struct tevent_context *ev, print_queue_receive); messaging_register(msg_ctx, NULL, MSG_SMB_CONF_UPDATED, printing_conf_updated); + /* Remove previous forwarder message set in parent. */ + messaging_deregister(msg_ctx, MSG_PRINTER_DRVUPGRADE, NULL); + + messaging_register(msg_ctx, NULL, MSG_PRINTER_DRVUPGRADE, + do_drv_upgrade_printer); fde = tevent_add_fd(ev, ev, pause_pipe[1], TEVENT_FD_READ, printing_pause_fd_handler, @@ -1845,6 +1851,29 @@ void start_background_queue(struct tevent_context *ev, } /**************************************************************************** + Forward a MSG_PRINTER_DRVUPGRADE message from another smbd to the + background lpq updater. +****************************************************************************/ + +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) +{ + 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); +} + +/**************************************************************************** update the internal database from the system print queue for a queue ****************************************************************************/ diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 8372c43..ef2e1ce 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -1526,6 +1526,7 @@ void srv_spoolss_cleanup(void) /********************************************************************** callback to receive a MSG_PRINTER_DRVUPGRADE message and interate over all printers, upgrading ones as necessary + This is now *ONLY* called inside the background lpq updater. JRA. **********************************************************************/ void do_drv_upgrade_printer(struct messaging_context *msg,