]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Update the fsync batching patch to work with the isc libraries - 21044
authorShawn Routhier <sar@isc.org>
Fri, 12 Mar 2010 01:36:57 +0000 (01:36 +0000)
committerShawn Routhier <sar@isc.org>
Fri, 12 Mar 2010 01:36:57 +0000 (01:36 +0000)
RELNOTES
includes/dhcpd.h
server/dhcp.c
server/dhcpd.c

index 23fbddbe6f74e1971d9854ec817efdea26624e0f..4a6fceea478305dad36477f317d584b930ff5092 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -40,6 +40,11 @@ work on other platforms. Please report any problems and suggested fixes to
 <dhcp-users@isc.org>.
 
 
+                       Changes since 4.2.0a2
+
+- Update the fsync code to work with the changes to the DDNS code.  It now
+  uses a timer instead of noticing if there are no more packets to process.
+
                        Changes since 4.2.0a1
 
 - When using 'ignore client-updates;', the FQDN returned to the client
index 0c7037d7a0ea5903b63083b8c1fefb2e2dfa4d3d..4ceb22bae17bac92c3cfb35f5871ba9ba6c9797d 100644 (file)
@@ -3,7 +3,7 @@
    Definitions for dhcpd... */
 
 /*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -667,6 +667,10 @@ struct lease_state {
 # define DEFAULT_ACK_DELAY_USECS 250000 /* 1/4 of a second */
 #endif
 
+#if !defined (DEFAULT_MIN_ACK_DELAY_USECS)
+# define DEFAULT_MIN_ACK_DELAY_USECS 10000 /* 1/100 second */
+#endif
+
 #if !defined (DEFAULT_DEFAULT_LEASE_TIME)
 # define DEFAULT_DEFAULT_LEASE_TIME 43200
 #endif
index 0a970725943ed41771f62a73cd46cfa18653e257..7a01c3c9be68516482f01755e62e0c17a4d8f23f 100644 (file)
@@ -3,7 +3,7 @@
    DHCP Protocol engine. */
 
 /*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1995-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -45,11 +45,13 @@ int outstanding_pings;
 
 struct leasequeue *ackqueue_head, *ackqueue_tail;
 static struct leasequeue *free_ackqueue;
-static struct timeval next_fsync;
+static struct timeval max_fsync;
+
 int outstanding_acks;
 int max_outstanding_acks = DEFAULT_DELAYED_ACK;
 int max_ack_delay_secs = DEFAULT_ACK_DELAY_SECS;
 int max_ack_delay_usecs = DEFAULT_ACK_DELAY_USECS;
+int min_ack_delay_usecs = DEFAULT_MIN_ACK_DELAY_USECS;
 
 static char dhcp_message [256];
 static int site_code_min;
@@ -2836,11 +2838,13 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
        }
 }
 
-/* CC: queue single ACK:
-   - write the lease (but do not fsync it yet)
-   - add to double linked list
-   - commit if more than xx ACKs pending
-   - Not yet: schedule a fsync at the next interval (1 second?)
+/*
+ * CC: queue single ACK:
+ * - write the lease (but do not fsync it yet)
+ * - add to double linked list
+ * - commit if more than xx ACKs pending
+ * - if necessary set the max timer and bump the next timer
+ *   but only up to the max timer value.
  */
 
 void
@@ -2870,43 +2874,54 @@ delayed_ack_enqueue(struct lease *lease)
                q->next->prev = q;
 
        outstanding_acks++;
-       if (outstanding_acks > max_outstanding_acks) 
+       if (outstanding_acks > max_outstanding_acks) {
                commit_leases();
 
-       /* If next_fsync is not set, schedule an fsync. */
-       if (next_fsync.tv_sec == 0 && next_fsync.tv_usec == 0) {
-               next_fsync.tv_sec = cur_tv.tv_sec + max_ack_delay_secs;
-               next_fsync.tv_usec = cur_tv.tv_usec + max_ack_delay_usecs;
+               /* Reset max_fsync and cancel any pending timeout. */
+               memset(&max_fsync, 0, sizeof(max_fsync));
+               cancel_timeout(commit_leases_ackout, NULL);
+       } else {
+               struct timeval next_fsync;
+
+               if (max_fsync.tv_sec == 0 && max_fsync.tv_usec == 0) {
+                       /* set the maximum time we'll wait */
+                       max_fsync.tv_sec = cur_tv.tv_sec + max_ack_delay_secs;
+                       max_fsync.tv_usec = cur_tv.tv_usec +
+                               max_ack_delay_usecs;
 
+                       if (max_fsync.tv_usec >= 1000000) {
+                               max_fsync.tv_sec++;
+                               max_fsync.tv_usec -= 1000000;
+                       }
+               }
+
+               /* Set the timeout */
+               next_fsync.tv_sec = cur_tv.tv_sec;
+               next_fsync.tv_usec = cur_tv.tv_usec + min_ack_delay_usecs;
                if (next_fsync.tv_usec >= 1000000) {
                        next_fsync.tv_sec++;
                        next_fsync.tv_usec -= 1000000;
                }
+               /* but not more than the max */
+               if ((next_fsync.tv_sec > max_fsync.tv_sec) ||
+                   ((next_fsync.tv_sec == max_fsync.tv_sec) &&
+                    (next_fsync.tv_usec > max_fsync.tv_usec))) {
+                       next_fsync.tv_sec = max_fsync.tv_sec;
+                       next_fsync.tv_usec = max_fsync.tv_usec;
+               }
 
                add_timeout(&next_fsync, commit_leases_ackout, NULL,
                            (tvref_t) NULL, (tvunref_t) NULL);
        }
 }
 
-void
-commit_leases_readerdry(void *foo) 
-{
-       if (outstanding_acks) {
-               commit_leases();
-
-               /* Reset next_fsync and cancel any pending timeout. */
-               memset(&next_fsync, 0, sizeof(next_fsync));
-               cancel_timeout(commit_leases_ackout, NULL);
-       }
-}
-
 static void
 commit_leases_ackout(void *foo)
 {
        if (outstanding_acks) {
                commit_leases();
 
-               memset(&next_fsync, 0, sizeof(next_fsync));
+               memset(&max_fsync, 0, sizeof(max_fsync));
        }
 }
 
index 198436933900d5cf00ae43d4cec9c1cf69b5a40d..399e65b0bd3d6bc3d4360056df502a64fd88daab 100644 (file)
@@ -836,8 +836,6 @@ main(int argc, char **argv) {
        omapi_set_int_value ((omapi_object_t *)dhcp_control_object,
                             (omapi_object_t *)0, "state", server_running);
 
-       register_eventhandler(&rw_queue_empty,commit_leases_readerdry);
-       
        /* Receive packets and dispatch them... */
        dispatch ();