Forms, print queues and tdb
Damian Ivereigh
damian at cisco.com
Wed Jan 24 02:37:29 GMT 2001
Here it is. I'm not very proud of it - it is one hell of a hack,
will only work under Linux etc etc.
Damian
Jeremy Allison wrote:
>
> Damian Ivereigh wrote:
> >
> > Right now I have dealt with it by turning off the queue display if the
> > load average rises above a pre-set level.
>
> Any chance of getting this patch ?
>
> Jeremy.
>
> --
> --------------------------------------------------------
> Buying an operating system without source is like buying
> a self-assembly Space Shuttle with no instructions.
> --------------------------------------------------------
--
Damian Ivereigh
CEPS Team Lead
http://wwwin-print.cisco.com
Desk: +61 2 8446 6344
Mob: +61 418 217 582
-------------- next part --------------
Index: printing.c
===================================================================
RCS file: /cvsroot/samba/source/printing/printing.c,v
retrieving revision 1.91
diff -c -r1.91 printing.c
*** printing.c 2001/01/04 19:27:07 1.91
--- printing.c 2001/01/24 03:34:10
***************
*** 66,71 ****
--- 66,108 ----
static int get_queue_status(int, print_status_struct *);
/****************************************************************************
+ Check the current load average. If it is above a preconfigured value
+ Then perform various load saving short cuts
+ Returns true if load average is low, false otherwise
+ ****************************************************************************/
+ BOOL low_lavg(void)
+ {
+ static int lafd=-1;
+ fstring lavgline;
+ int n=0;
+ BOOL ret;
+ double cla=-1;
+
+ if (lafd==-1) {
+ lafd=open("/proc/loadavg", O_RDONLY);
+ } else {
+ lseek(lafd, (off_t) 0, SEEK_SET);
+ }
+ if (lafd!=-1) {
+ n=read(lafd, lavgline, sizeof(lavgline)-1);
+ } else {
+ DEBUG(10,("CEPS low_lavg failed: return False\n"));
+ return(False);
+ }
+ if (n<0) n=0;
+ lavgline[n]='\0';
+
+ /* Get load average */
+ if (sscanf(lavgline, "%lf", &cla)!=1 || cla > 2.0) {
+ DEBUG(10,("CEPS low_lavg(%lf): return False\n", cla));
+ return(False);
+ } else {
+ DEBUG(10,("CEPS low_lavg(%lf): return True\n", cla));
+ return(True);
+ }
+ }
+
+ /****************************************************************************
initialise the printing backend. Called once at startup.
Does not survive a fork
****************************************************************************/
***************
*** 719,724 ****
--- 756,764 ----
fstring key;
time_t t2, t = time(NULL);
+ /* If the load is too high - extend the expired time */
+ if (low_lavg()==False)
+ return(False);
slprintf(key, sizeof(key), "CACHE/%s", lp_servicename(snum));
t2 = tdb_fetch_int(tdb, key);
if (t2 == ((time_t)-1) || (t - t2) >= lp_lpqcachetime()) {
***************
*** 1072,1077 ****
--- 1112,1119 ----
}
free(data.dptr);
}
+ if (low_lavg()==False)
+ return(0);
/*
* Now, fetch the print queue information. We first count the number
More information about the samba-technical
mailing list