From d097ea490525e7a35739dae6a295fd03ba52cfc0 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Wed, 5 Jan 2005 16:20:35 +0000 Subject: r4539: patch from Rob -- adding real printcap name cache function to speed up printcap reloads (This used to be commit 1cad5250932b963c2eb9b775221b13db386d601b) --- source3/smbd/server.c | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-) (limited to 'source3/smbd/server.c') diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 724a49321a..7f7d55c7e3 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -463,6 +463,39 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_ /* NOTREACHED return True; */ } +/**************************************************************************** + Reload printers +**************************************************************************/ +void reload_printers(void) +{ + int snum; + int n_services = lp_numservices(); + int pnum = lp_servicenumber(PRINTERS_NAME); + const char *pname; + + pcap_cache_reload(); + + /* remove stale printers */ + for (snum = 0; snum < n_services; snum++) { + /* avoid removing PRINTERS_NAME or non-autoloaded printers */ + if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) && + lp_autoloaded(snum))) + continue; + + pname = lp_printername(snum); + if (!pcap_printername_ok(pname)) { + DEBUG(3, ("removing stale printer %s\n", pname)); + + if (is_printer_published(NULL, snum, NULL)) + nt_printer_publish(NULL, snum, SPOOL_DS_UNPUBLISH); + del_a_printer(pname); + lp_killservice(snum); + } + } + + load_printers(); +} + /**************************************************************************** Reload the services file. **************************************************************************/ @@ -490,8 +523,7 @@ BOOL reload_services(BOOL test) ret = lp_load(dyn_CONFIGFILE, False, False, True); - remove_stale_printers(); - load_printers(); + reload_printers(); /* perhaps the config filename is now set */ if (!test) -- cgit