svn commit: samba r7961 - in branches/SAMBA_3_0/source/smbd: .

idra at samba.org idra at samba.org
Mon Jun 27 22:44:58 GMT 2005


Author: idra
Date: 2005-06-27 22:44:57 +0000 (Mon, 27 Jun 2005)
New Revision: 7961

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7961

Log:

randomize reloading so that smbds do not pverload cupsd
by reloading printers all at the same time.
						sss


Modified:
   branches/SAMBA_3_0/source/smbd/process.c


Changeset:
Modified: branches/SAMBA_3_0/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_0/source/smbd/process.c	2005-06-27 22:39:09 UTC (rev 7960)
+++ branches/SAMBA_3_0/source/smbd/process.c	2005-06-27 22:44:57 UTC (rev 7961)
@@ -1299,6 +1299,7 @@
 
 void check_reload(int t)
 {
+	static pid_t mypid = 0;
 	static time_t last_smb_conf_reload_time = 0;
 	static time_t last_printer_reload_time = 0;
 	time_t printcap_cache_time = (time_t)lp_printcap_cache_time();
@@ -1314,6 +1315,15 @@
 			last_printer_reload_time = t;
 	}
 
+	if (mypid != getpid()) { /* First time or fork happened meanwhile */
+		/* randomize over 60 second the printcap reload to avoid all
+		 * process hitting cupsd at the same time */
+		int time_range = 60;
+
+		last_printer_reload_time += random() % time_range;
+		mypid = getpid();
+	}
+
 	if (reload_after_sighup || (t >= last_smb_conf_reload_time+SMBD_RELOAD_CHECK)) {
 		reload_services(True);
 		reload_after_sighup = False;



More information about the samba-cvs mailing list