File: 06_509015_better_delays.dpatch

package info (click to toggle)
ifplugd 0.28-19
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 1,152 kB
  • ctags: 772
  • sloc: sh: 2,535; ansic: 2,023; makefile: 176
file content (34 lines) | stat: -rw-r--r-- 1,061 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#! /bin/sh /usr/share/dpatch/dpatch-run
## 06_509015_better_delays.dpatch by Michel Lespinasse <walken@zoy.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Don't wait for more than specified delays, fix for #509015

@DPATCH@
diff -urNad ifplugd-0.28~/src/ifplugd.c ifplugd-0.28/src/ifplugd.c
--- ifplugd-0.28~/src/ifplugd.c	2008-09-30 17:48:51.000000000 +0530
+++ ifplugd-0.28/src/ifplugd.c	2009-03-02 12:05:11.000000000 +0530
@@ -468,6 +468,14 @@
         tv.tv_sec = polltime;
         tv.tv_usec = 0;
         
+        if (t) {
+            int delay = t - time(NULL);
+            if (delay < 0)
+                tv.tv_sec = 0;
+            else if (delay < tv.tv_sec)
+                tv.tv_sec = delay;
+        }
+
         if (select(FD_SETSIZE, &qfds, NULL, NULL, &tv) < 0) {
             if (errno == EINTR)
                 continue;
@@ -573,7 +581,7 @@
             }
         }
 
-        if (t && t < time(NULL)) {
+        if (t && t <= time(NULL)) {
             t = 0;
 
             if (action(status) < 0)