Package: dhcdbd
Version: 2.0-4
Severity: normal
Tags: patch
Hi,
dhcdbd wakes up every now and then, which makes it show up in the
PowerTOP graphs as one of the culprits in keeping the CPU awake. The
included patch (nicked from Ubuntu) should fix the issues; I believe it
is originally by Keith Packard.
-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1,
'experimental')
Architecture: i386 (i686)
Kernel: Linux 2.6.21.1 (SMP w/2 CPU cores; PREEMPT)
Locale: LANG=nb_NO.UTF-8, LC_CTYPE=nb_NO.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages dhcdbd depends on:
ii dbus 1.0.2-5 simple interprocess messaging syst
ii dhcp3-client 3.0.4-14 DHCP Client
ii libc6 2.5-7 GNU C Library: Shared libraries
ii libdbus-1-3 1.0.2-5 simple interprocess messaging syst
ii lsb-base 3.1-23.1 Linux Standard Base 3.1 init scrip
dhcdbd recommends no packages.
-- no debconf information
diff -ur dhcdbd-2.0.bak/src/dbus_service.c dhcdbd-2.0/src/dbus_service.c
--- dhcdbd-2.0.bak/src/dbus_service.c 2007-05-14 20:02:41.000000000 +0100
+++ dhcdbd-2.0/src/dbus_service.c 2007-05-14 20:05:23.000000000 +0100
@@ -976,6 +976,51 @@
twalk(cs->timeouts, process_timeout);
}
+static float next_timeout;
+
+static void find_timeout (const void *p, const VISIT which, const int level) {
+ DBusConnectionState *cs;
+ const void *const *tpp = p;
+ DBusConnectionTimeout *to;
+ struct timeval tv;
+ float now, then, interval, timeout;
+
+ gettimeofday(&tv, 0L);
+
+ if ((tpp != 0L) && (*tpp != 0L) && ((which == postorder) || (which == leaf))) {
+ to = (DBusConnectionTimeout *) * tpp;
+ cs = to->cs;
+
+ if (!dbus_timeout_get_enabled(to->to))
+ return;
+
+ cs = dbus_timeout_get_data(to->to);
+ then = ((float) to->tv.tv_sec) + (((float) to->tv.tv_usec) / 1000000.0);
+
+ if (then != 0.0) {
+ interval = ((float) dbus_timeout_get_interval(to->to)) / 1000.0;
+ now = ((float) tv.tv_sec) + (((float) tv.tv_usec) / 1000000.0);
+
+ timeout = then + interval - now;
+ if (timeout < 0)
+ timeout = 0;
+ if (next_timeout < 0 || timeout < next_timeout)
+ next_timeout = timeout;
+ }
+ }
+}
+
+static struct timeval *find_next_timeout (DBusConnectionState * cs, struct timeval *tv) {
+ next_timeout = 1;
+ twalk(cs->timeouts, find_timeout);
+ printf ("next timeout %f\n", next_timeout);
+ if (next_timeout == -1)
+ return NULL;
+ tv->tv_sec = next_timeout;
+ tv->tv_usec = (next_timeout - tv->tv_sec) * 1000000;
+ return tv;
+}
+
static void set_watch_fds(DBusWatch * watch, DBusConnectionState * cs) {
uint8_t flags = dbus_watch_get_flags(watch);
int fd = dbus_watch_get_fd(watch);
@@ -1147,10 +1192,8 @@
cs->s_w_fds = cs->w_fds;
cs->s_e_fds = cs->e_fds;
- timeout.tv_sec = 0;
- timeout.tv_usec = 200000;
-
- if ((n_fds = select(cs->n, &(cs->s_r_fds), &(cs->s_w_fds), &(cs->s_e_fds), &timeout)) < 0) {
+ if ((n_fds = select(cs->n, &(cs->s_r_fds), &(cs->s_w_fds),
+ &(cs->s_e_fds), find_next_timeout (cs, &timeout))) < 0) {
if (errno != EINTR) {
if (cs->eh != 0L)
(*(cs->eh)) ("select failed: %d : %s", errno, strerror(errno));
Only in dhcdbd-2.0/src: dbus_service.c.orig