rpms/dhcdbd/F-7 dhcdbd-2.7-timeout.patch, NONE, 1.1 dhcdbd.spec, 1.45, 1.46

David Cantrell (dcantrel) fedora-extras-commits at redhat.com
Tue Jun 5 20:35:32 UTC 2007


Author: dcantrel

Update of /cvs/pkgs/rpms/dhcdbd/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv25574

Modified Files:
	dhcdbd.spec 
Added Files:
	dhcdbd-2.7-timeout.patch 
Log Message:
* Tue Jun 05 2007 David Cantrell <dcantrell at redhat.com> - 2.7-5
- Use dbus to avoid waking up so often (#218406)


dhcdbd-2.7-timeout.patch:

--- NEW FILE dhcdbd-2.7-timeout.patch ---
--- dhcdbd-2.7/src/dbus_service.c.timeout	2006-08-24 12:52:14.000000000 -0400
+++ dhcdbd-2.7/src/dbus_service.c	2007-06-05 16:31:13.000000000 -0400
@@ -976,6 +976,51 @@ static void process_timeouts(DBusConnect
     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 @@ void dbus_svc_main_loop(DBusConnectionSt
         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));


Index: dhcdbd.spec
===================================================================
RCS file: /cvs/pkgs/rpms/dhcdbd/F-7/dhcdbd.spec,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- dhcdbd.spec	3 May 2007 19:51:52 -0000	1.45
+++ dhcdbd.spec	5 Jun 2007 20:34:27 -0000	1.46
@@ -5,13 +5,14 @@
 Summary:   DHCP D-BUS daemon (dhcdbd) controls dhclient sessions with D-BUS
 Name:      dhcdbd
 Version:   2.7
-Release:   4%{?dist}
+Release:   5%{?dist}
 License:   GPL
 Group:     System Environment/Daemons
 URL:       http://people.redhat.com/dcantrel/%{name}/
 
 Source:    http://people.redhat.com/dcantrel/%{name}/%{name}-%{version}.tar.bz2
 Patch0:    %{name}-2.7-initscript.patch
+Patch1:    %{name}-2.7-timeout.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: dbus-devel >= 0.90, pkgconfig
@@ -31,6 +32,7 @@
 %prep
 %setup -q
 %patch0 -p1 -b .initscript
+%patch1 -p1 -b .timeout
 
 %build
 %{__make} %{?_smp_mflags}
@@ -67,6 +69,9 @@
 %attr(755,root,root) %{_initrddir}/dhcdbd
 
 %changelog
+* Tue Jun 05 2007 David Cantrell <dcantrell at redhat.com> - 2.7-5
+- Use dbus to avoid waking up so often (#218406)
+
 * Thu May 05 2007 David Cantrell <dcantrell at redhat.com> - 2.7-4
 - Make sure lockfile is removed when service is stopped (#238713)
 




More information about the fedora-extras-commits mailing list