s3: Prune the printername cache when a printer is deleted
authorVolker Lendecke <vl@samba.org>
Tue, 7 Sep 2010 03:58:45 +0000 (20:58 -0700)
committerAndreas Schneider <asn@samba.org>
Tue, 7 Sep 2010 07:40:26 +0000 (09:40 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
source3/rpc_server/srv_spoolss_nt.c

index 281de00511a617589be874028d936da0e9c1b20f..34f96434832cd4042874ffb084e4ee7194437141 100644 (file)
@@ -98,6 +98,8 @@ struct xcv_api_table {
        WERROR(*fn) (TALLOC_CTX *mem_ctx, NT_USER_TOKEN *token, DATA_BLOB *in, DATA_BLOB *out, uint32_t *needed);
 };
 
+static void prune_printername_cache(void);
+
 /********************************************************************
  * Canonicalize servername.
  ********************************************************************/
@@ -388,8 +390,13 @@ static WERROR delete_printer_handle(struct pipes_struct *p, struct policy_handle
                return WERR_BADFID;
        }
 
-       return delete_printer_hook(p->mem_ctx, p->server_info->ptok,
-                                  Printer->sharename, p->msg_ctx);
+       result = delete_printer_hook(p->mem_ctx, p->server_info->ptok,
+                                    Printer->sharename, p->msg_ctx);
+       if (!W_ERROR_IS_OK(result)) {
+               return result;
+       }
+       prune_printername_cache();
+       return WERR_OK;
 }
 
 /****************************************************************************
@@ -447,6 +454,17 @@ static bool set_printer_hnd_printertype(Printer_entry *Printer, const char *hand
        return true;
 }
 
+static void prune_printername_cache_fn(const char *key, const char *value,
+                                      time_t timeout, void *private_data)
+{
+       gencache_del(key);
+}
+
+static void prune_printername_cache(void)
+{
+       gencache_iterate(prune_printername_cache_fn, NULL, "PRINTERNAME/*");
+}
+
 /****************************************************************************
  Set printer handle name..  Accept names like \\server, \\server\printer,
  \\server\SHARE, & "\\server\,XcvMonitor Standard TCP/IP Port"    See