printing: only reload printer shares on client enum
[samba.git] / source3 / rpc_server / spoolss / srv_spoolss_nt.c
index 7359cb22b0d69b1c16b8abd105302bc20832c955..010d0dfc9e74d459c228ad2054421e5708981c99 100644 (file)
@@ -1513,6 +1513,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,
@@ -4306,7 +4307,7 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
                                           uint32_t *count_p)
 {
        int snum;
-       int n_services = lp_numservices();
+       int n_services;
        union spoolss_PrinterInfo *info = NULL;
        uint32_t count = 0;
        WERROR result = WERR_OK;
@@ -4318,6 +4319,15 @@ static WERROR enum_all_printers_info_level(TALLOC_CTX *mem_ctx,
                return WERR_NOMEM;
        }
 
+       /*
+        * printer shares are only updated on client enumeration. The background
+        * printer process updates printer_list.tdb at regular intervals.
+        */
+       become_root();
+       delete_and_reload_printers(server_event_context(), msg_ctx);
+       unbecome_root();
+
+       n_services = lp_numservices();
        *count_p = 0;
        *info_p = NULL;