--- embedaddon/dhcp/server/db.c 2012/02/21 22:30:18 1.1 +++ embedaddon/dhcp/server/db.c 2012/10/09 09:06:54 1.1.1.1 @@ -3,7 +3,7 @@ Persistent database management routines for DHCPD... */ /* - * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC") + * Copyright (c) 2004-2010,2012 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 @@ -36,6 +36,8 @@ #include #include +#define LEASE_REWRITE_PERIOD 3600 + static isc_result_t write_binding_scope(FILE *db_file, struct binding *bnd, char *prepend); @@ -988,7 +990,7 @@ int commit_leases () /* If we haven't rewritten the lease database in over an hour, rewrite it now. (The length of time should probably be configurable. */ - if (count && cur_time - write_time > 3600) { + if (count && cur_time - write_time > LEASE_REWRITE_PERIOD) { count = 0; write_time = cur_time; new_lease_file (); @@ -996,6 +998,21 @@ int commit_leases () return 1; } +/* + * rewrite the lease file about once an hour + * This is meant as a quick patch for ticket 24887. It allows + * us to rotate the v6 lease file without adding too many fsync() + * calls. In the future wes should revisit this area and add + * something similar to the delayed ack code for v4. + */ +int commit_leases_timed() +{ + if ((count != 0) && (cur_time - write_time > LEASE_REWRITE_PERIOD)) { + return (commit_leases()); + } + return (1); +} + void db_startup (testp) int testp; { @@ -1007,7 +1024,11 @@ void db_startup (testp) /* Read in the existing lease file... */ status = read_conf_file (path_dhcpd_db, (struct group *)0, 0, 1); - /* XXX ignore status? */ + if (status != ISC_R_SUCCESS) { + /* XXX ignore status? */ + ; + } + #if defined (TRACING) } #endif