diff options
author | Gerald Carter <jerry@samba.org> | 2004-05-20 16:23:17 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:51:46 -0500 |
commit | 67d474861d34490f6a8064d3eadc716d5a3a6020 (patch) | |
tree | 1421d875ed0ac58cb686d5a938b8fe226a7692a8 /source3/smbd | |
parent | 96c6bf93d52c562dfabe25a2901ecb4e54f5a06f (diff) | |
download | samba-67d474861d34490f6a8064d3eadc716d5a3a6020.tar.gz samba-67d474861d34490f6a8064d3eadc716d5a3a6020.tar.bz2 samba-67d474861d34490f6a8064d3eadc716d5a3a6020.zip |
r799: BUG 1259 -- add 'printcap cache time' patch from Lars
(This used to be commit fac90741139b953d0e88d050dd457657f0b9c9f3)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/process.c | 28 | ||||
-rw-r--r-- | source3/smbd/service.c | 24 |
2 files changed, 51 insertions, 1 deletions
diff --git a/source3/smbd/process.c b/source3/smbd/process.c index d0dfc6dd7d..283b791afd 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -1078,15 +1078,41 @@ 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; + time_t printcap_cache_time = (time_t)lp_printcap_cache_time(); - if(last_smb_conf_reload_time == 0) + if(last_smb_conf_reload_time == 0) { last_smb_conf_reload_time = t; + /* Our printing subsystem might not be ready at smbd start up. + 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; + else + last_load_printers_reload_time = t; + } if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) { reload_services(True); reload_after_sighup = False; last_smb_conf_reload_time = t; } + + /* 'printcap cache time = 0' disable the feature */ + + if ( printcap_cache_time != 0 ) + { + /* 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) ) + { + DEBUG( 3,( "Printcap cache time expired.\n")); + remove_stale_printers(); + load_printers(); + last_load_printers_reload_time = t; + } + } } /**************************************************************************** diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 04cade9577..c74537c299 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -826,3 +826,27 @@ 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 a print service and still in the printing subsystem? */ + if ( lp_print_ok( snum) && !pcap_printername_ok( pname, NULL)) { + DEBUG( 3, ( "Removing printer: %s\n", pname)); + lp_killservice( snum); + } + } +} |