mirror of
https://github.com/samba-team/samba.git
synced 2025-02-04 17:47:26 +03:00
r799: BUG 1259 -- add 'printcap cache time' patch from Lars
(This used to be commit fac90741139b953d0e88d050dd457657f0b9c9f3)
This commit is contained in:
parent
96c6bf93d5
commit
67d474861d
@ -249,6 +249,7 @@ typedef struct
|
|||||||
BOOL bNullPasswords;
|
BOOL bNullPasswords;
|
||||||
BOOL bObeyPamRestrictions;
|
BOOL bObeyPamRestrictions;
|
||||||
BOOL bLoadPrinters;
|
BOOL bLoadPrinters;
|
||||||
|
int PrintcapCacheTime;
|
||||||
BOOL bLargeReadwrite;
|
BOOL bLargeReadwrite;
|
||||||
BOOL bReadRaw;
|
BOOL bReadRaw;
|
||||||
BOOL bWriteRaw;
|
BOOL bWriteRaw;
|
||||||
@ -945,6 +946,7 @@ static struct parm_struct parm_table[] = {
|
|||||||
{"max reported print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxReportedPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
{"max reported print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxReportedPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
{"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
{"max print jobs", P_INTEGER, P_LOCAL, &sDefault.iMaxPrintJobs, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
{"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
{"load printers", P_BOOL, P_GLOBAL, &Globals.bLoadPrinters, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
|
{"printcap cache time", P_INTEGER, P_GLOBAL, &Globals.PrintcapCacheTime, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
{"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
{"printcap name", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
{"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_HIDE},
|
{"printcap", P_STRING, P_GLOBAL, &Globals.szPrintcapname, NULL, NULL, FLAG_HIDE},
|
||||||
{"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
{"printable", P_BOOL, P_LOCAL, &sDefault.bPrint_ok, NULL, NULL, FLAG_ADVANCED | FLAG_PRINT},
|
||||||
@ -1362,6 +1364,7 @@ static void init_globals(void)
|
|||||||
Globals.AlgorithmicRidBase = BASE_RID;
|
Globals.AlgorithmicRidBase = BASE_RID;
|
||||||
|
|
||||||
Globals.bLoadPrinters = True;
|
Globals.bLoadPrinters = True;
|
||||||
|
Globals.PrintcapCacheTime = 0;
|
||||||
/* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
|
/* Was 65535 (0xFFFF). 0x4101 matches W2K and causes major speed improvements... */
|
||||||
/* Discovered by 2 days of pain by Don McCall @ HP :-). */
|
/* Discovered by 2 days of pain by Don McCall @ HP :-). */
|
||||||
Globals.max_xmit = 0x4104;
|
Globals.max_xmit = 0x4104;
|
||||||
@ -1614,6 +1617,7 @@ FN_GLOBAL_STRING(lp_configfile, &Globals.szConfigFile)
|
|||||||
FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
|
FN_GLOBAL_STRING(lp_smb_passwd_file, &Globals.szSMBPasswdFile)
|
||||||
FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
|
FN_GLOBAL_STRING(lp_private_dir, &Globals.szPrivateDir)
|
||||||
FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
|
FN_GLOBAL_STRING(lp_serverstring, &Globals.szServerString)
|
||||||
|
FN_GLOBAL_INTEGER(lp_printcap_cache_time, &Globals.PrintcapCacheTime)
|
||||||
FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
|
FN_GLOBAL_STRING(lp_printcapname, &Globals.szPrintcapname)
|
||||||
FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
|
FN_GLOBAL_STRING(lp_enumports_cmd, &Globals.szEnumPortsCommand)
|
||||||
FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
|
FN_GLOBAL_STRING(lp_addprinter_cmd, &Globals.szAddPrinterCommand)
|
||||||
|
@ -1078,15 +1078,41 @@ static int setup_select_timeout(void)
|
|||||||
void check_reload(int t)
|
void check_reload(int t)
|
||||||
{
|
{
|
||||||
static time_t last_smb_conf_reload_time = 0;
|
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;
|
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)) {
|
if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) {
|
||||||
reload_services(True);
|
reload_services(True);
|
||||||
reload_after_sighup = False;
|
reload_after_sighup = False;
|
||||||
last_smb_conf_reload_time = t;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -826,3 +826,27 @@ void close_cnum(connection_struct *conn, uint16 vuid)
|
|||||||
|
|
||||||
conn_free(conn);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user