summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-01-05 16:20:35 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:53:46 -0500
commitd097ea490525e7a35739dae6a295fd03ba52cfc0 (patch)
tree131dc7af2e2e944283c70d255d8ad5d6bbef0726 /source3/smbd
parent846b8d4cfdee815cd22d7e00b7f120668f9758a9 (diff)
downloadsamba-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')
-rw-r--r--source3/smbd/process.c15
-rw-r--r--source3/smbd/server.c36
-rw-r--r--source3/smbd/service.c37
3 files changed, 42 insertions, 46 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c
index 1372ebbf45..54837c3b9a 100644
--- a/source3/smbd/process.c
+++ b/source3/smbd/process.c
@@ -1282,7 +1282,7 @@ static int setup_select_timeout(void)
void check_reload(int t)
{
static time_t last_smb_conf_reload_time = 0;
- static time_t last_load_printers_reload_time = 0;
+ static time_t last_printer_reload_time = 0;
time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
if(last_smb_conf_reload_time == 0) {
@@ -1291,9 +1291,9 @@ void check_reload(int t)
Then no printer is available till the first printers check
is performed. A lower initial interval circumvents this. */
if ( printcap_cache_time > 60 )
- last_load_printers_reload_time = t - printcap_cache_time + 60;
+ last_printer_reload_time = t - printcap_cache_time + 60;
else
- last_load_printers_reload_time = t;
+ last_printer_reload_time = t;
}
if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) {
@@ -1308,13 +1308,12 @@ void check_reload(int t)
{
/* see if it's time to reload or if the clock has been set back */
- if ( (t >= last_load_printers_reload_time+printcap_cache_time)
- || (t-last_load_printers_reload_time < 0) )
+ if ( (t >= last_printer_reload_time+printcap_cache_time)
+ || (t-last_printer_reload_time < 0) )
{
DEBUG( 3,( "Printcap cache time expired.\n"));
- remove_stale_printers();
- load_printers();
- last_load_printers_reload_time = t;
+ reload_printers();
+ last_printer_reload_time = t;
}
}
}
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)
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index 3dcd803a7c..2e60adc636 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -152,10 +152,8 @@ int find_service(fstring service)
int iPrinterService;
if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) >= 0) {
- const char *pszTemp = lp_printcapname();
-
DEBUG(3,("checking whether %s is a valid printer name...\n", service));
- if ((pszTemp != NULL) && pcap_printername_ok(service, pszTemp)) {
+ if (pcap_printername_ok(service)) {
DEBUG(3,("%s is a valid printer name\n", service));
DEBUG(3,("adding %s as a printer service\n", service));
lp_add_printer(service, iPrinterService);
@@ -863,36 +861,3 @@ void close_cnum(connection_struct *conn, uint16 vuid)
conn_free(conn);
}
-
-/****************************************************************************
- Remove stale printers
-****************************************************************************/
-
-void remove_stale_printers( void )
-{
- int snum, iNumServices, printersServiceNum;
- const char *pname;
-
- iNumServices = lp_numservices();
- printersServiceNum = lp_servicenumber( PRINTERS_NAME);
- for( snum = 0; snum < iNumServices; snum++) {
-
- /* Never remove PRINTERS_NAME */
-
- if ( snum == printersServiceNum)
- continue;
- pname = lp_printername( snum);
-
- /* Is snum an autoloaded print service and still
- in the printing subsystem? */
-
- if ( lp_snum_ok(snum)
- && lp_print_ok(snum)
- && lp_autoloaded(snum)
- && !pcap_printername_ok( pname, NULL))
- {
- DEBUG( 3, ( "Removing printer: %s\n", pname));
- lp_killservice( snum);
- }
- }
-}