diff options
author | Gerald Carter <jerry@samba.org> | 2005-01-05 16:20:35 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:53:46 -0500 |
commit | d097ea490525e7a35739dae6a295fd03ba52cfc0 (patch) | |
tree | 131dc7af2e2e944283c70d255d8ad5d6bbef0726 /source3/smbd/server.c | |
parent | 846b8d4cfdee815cd22d7e00b7f120668f9758a9 (diff) | |
download | samba-d097ea490525e7a35739dae6a295fd03ba52cfc0.tar.gz samba-d097ea490525e7a35739dae6a295fd03ba52cfc0.tar.bz2 samba-d097ea490525e7a35739dae6a295fd03ba52cfc0.zip |
r4539: patch from Rob -- adding real printcap name cache function to speed up printcap reloads
(This used to be commit 1cad5250932b963c2eb9b775221b13db386d601b)
Diffstat (limited to 'source3/smbd/server.c')
-rw-r--r-- | source3/smbd/server.c | 36 |
1 files changed, 34 insertions, 2 deletions
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 @@ -464,6 +464,39 @@ static BOOL open_sockets_smbd(BOOL is_daemon, BOOL interactive, const char *smb_ } /**************************************************************************** + 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) |