[LOW] STR #4040: backendWaitLoop never examines SNMP supplies

Tim Waugh <[email protected]>
Newsgroups gmane.comp.printing.cups.bugs
Message-ID <[email protected]>
DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

In backend/runloop.c, the backendWaitLoop function looks at first glance as
though it will check the SNMP supplies periodically while waiting for data.
 In fact this never happens: the select() is indefinite, so we'll only get
past that line if one of the file descriptors becomes readable.  But if
stdin is readable we break out of the loop, and if the side-channel is
readable we skip back to the beginning with 'continue'.

Here is a suggested patch to make SNMP updates happen periodically.  It
changes the select timeout to be initially 5 seconds.

Link: http://www.cups.org/str.php?L4040
Version: 1.5.2

_______________________________________________
cups-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/cups-bugs
cups-waitloop-snmp.patch (text/plain, 901 B)
diff -up cups-1.5.2/backend/runloop.c.waitloop-snmp cups-1.5.2/backend/runloop.c
--- cups-1.5.2/backend/runloop.c.waitloop-snmp	2012-03-09 11:42:45.907055236 +0000
+++ cups-1.5.2/backend/runloop.c	2012-03-09 11:44:53.106166733 +0000
@@ -437,6 +437,7 @@ backendWaitLoop(
   fd_set	input;			/* Input set for reading */
   time_t	curtime,		/* Current time */
 		snmp_update = 0;	/* Last SNMP status update */
+  struct timeval timeout;
 
 
   fprintf(stderr, "DEBUG: backendWaitLoop(snmp_fd=%d, addr=%p, side_cb=%p)\n",
@@ -457,7 +458,9 @@ backendWaitLoop(
     if (side_cb)
       FD_SET(CUPS_SC_FD, &input);
 
-    if (select(CUPS_SC_FD + 1, &input, NULL, NULL, NULL) < 0)
+    timeout.tv_sec = snmp_update ? (snmp_update - curtime) : 5;
+    timeout.tv_usec = 0;
+    if (select(CUPS_SC_FD + 1, &input, NULL, NULL, &timeout) < 0)
     {
      /*
       * Pause printing to clear any pending errors...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.