Package: dpkg Version: 1.13.25 Severity: important Tags: patch
Lighttpd often dies when rotating the logs. Trying to reproduce the error manually I got the following error. [EMAIL PROTECTED]:~# /etc/init.d/lighttpd reload * Reloading web server configuration lighttpd start-stop-daemon: select() failed for pause: Invalid argument (Invalid argument) This may or may not be the cause of the logrotate problems. But it surely tells me that start-stop-daemon is broken. -- System Information: Debian Release: 4.0 APT prefers stable APT policy: (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.18-5-686 Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Versions of packages dpkg depends on: ii coreutils 5.97-5.3 The GNU core utilities ii libc6 2.3.6.ds1-13etch4 GNU C Library: Shared libraries dpkg recommends no packages. -- no debconf information
diff -ruN dpkg-1.13.11ubuntu7/utils/start-stop-daemon.c dpkg-1.13.11ubuntu7-ap/utils/start-stop-daemon.c --- dpkg-1.13.11ubuntu7/utils/start-stop-daemon.c 2005-06-06 06:07:12.000000000 +0200 +++ dpkg-1.13.11ubuntu7-ap/utils/start-stop-daemon.c 2008-01-21 10:43:02.000000000 +0100 @@ -189,37 +189,6 @@ static void badusage(const char *msg); #endif -/* This next part serves only to construct the TVCALC macro, which - * is used for doing arithmetic on struct timeval's. It works like this: - * TVCALC(result, expression); - * where result is a struct timeval (and must be an lvalue) and - * expression is the single expression for both components. In this - * expression you can use the special values TVELEM, which when fed a - * const struct timeval* gives you the relevant component, and - * TVADJUST. TVADJUST is necessary when subtracting timevals, to make - * it easier to renormalise. Whenver you subtract timeval elements, - * you must make sure that TVADJUST is added to the result of the - * subtraction (before any resulting multiplication or what have you). - * TVELEM must be linear in TVADJUST. - */ -typedef long tvselector(const struct timeval*); -static long tvselector_sec(const struct timeval *tv) { return tv->tv_sec; } -static long tvselector_usec(const struct timeval *tv) { return tv->tv_usec; } -#define TVCALC_ELEM(result, expr, sec, adj) \ -{ \ - const long TVADJUST = adj; \ - long (*const TVELEM)(const struct timeval*) = tvselector_##sec; \ - (result).tv_##sec = (expr); \ -} -#define TVCALC(result,expr) \ -do { \ - TVCALC_ELEM(result, expr, sec, (-1)); \ - TVCALC_ELEM(result, expr, usec, (+1000000)); \ - (result).tv_sec += (result).tv_usec / 1000000; \ - (result).tv_usec %= 1000000; \ -} while(0) - - static void fatal(const char *format, ...) { @@ -1034,6 +1003,7 @@ { int r, position, n_killed, n_notkilled, value, ratio, anykilled, retry_nr; struct timeval stopat, before, after, interval, maxinterval; + long utime; if (testmode) { if (schedule != NULL) { @@ -1125,8 +1095,16 @@ if (ratio < 10) ratio++; - TVCALC(interval, ratio * (TVELEM(&after) - TVELEM(&before) + TVADJUST)); - TVCALC(maxinterval, TVELEM(&stopat) - TVELEM(&after) + TVADJUST); + utime = ratio * ( (&after.tv_usec - &before.tv_sec) + 1000000 * (&after.tv_sec - &before.tv_sec) ); + + interval.tv_usec = utime / 1000000; + interval.tv_sec = utime % 1000000; + + timersub(&stopat, &after, &maxinterval); +// utime = (&stopat.usec - &after.sec) + 1000000 * (&stopat.sec - &after.sec); +// +// maxinterval.usec = utime / 1000000; +// maxinterval.sec = utime % 1000000; if (timercmp(&interval,&maxinterval,>)) interval = maxinterval; @@ -1135,6 +1113,12 @@ interval.tv_usec <= MIN_POLL_INTERVAL) interval.tv_usec = MIN_POLL_INTERVAL; + // Sanity check. interval should never be less than 0. select does not like that. + if (interval.tv_sec < 0 || interval.tv_usec < 0) { + interval.tv_sec = 0; + interval.tv_usec = 0; + } + r = select(0,0,0,0,&interval); if (r < 0 && errno != EINTR) fatal("select() failed for pause: %s",