Module Name:    src
Committed By:   christos
Date:           Sat Apr 13 23:04:35 UTC 2013

Modified Files:
        src/external/bsd/dhcp/dist/server: dhcpd.c

Log Message:
How could this possibly ever have worked with threads? It forked *after*
it initialized the isc library and the parent having created the threads
exited with the worker threads?!?!? Only -d worked because it did not
fork!


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.2 -r1.2 src/external/bsd/dhcp/dist/server/dhcpd.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/dhcp/dist/server/dhcpd.c
diff -u src/external/bsd/dhcp/dist/server/dhcpd.c:1.1.1.2 src/external/bsd/dhcp/dist/server/dhcpd.c:1.2
--- src/external/bsd/dhcp/dist/server/dhcpd.c:1.1.1.2	Sun Mar 24 18:50:40 2013
+++ src/external/bsd/dhcp/dist/server/dhcpd.c	Sat Apr 13 19:04:35 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dhcpd.c,v 1.1.1.2 2013/03/24 22:50:40 christos Exp $	*/
+/*	$NetBSD: dhcpd.c,v 1.2 2013/04/13 23:04:35 christos Exp $	*/
 
 /* dhcpd.c
 
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: dhcpd.c,v 1.1.1.2 2013/03/24 22:50:40 christos Exp $");
+__RCSID("$NetBSD: dhcpd.c,v 1.2 2013/04/13 23:04:35 christos Exp $");
 
 static const char copyright[] =
 "Copyright 2004-2013 Internet Systems Consortium.";
@@ -287,27 +287,6 @@ main(int argc, char **argv) {
         else if (fd != -1)
                 close(fd);
 
-	/* Set up the isc and dns library managers */
-	status = dhcp_context_create();
-	if (status != ISC_R_SUCCESS)
-		log_fatal("Can't initialize context: %s",
-			  isc_result_totext(status));
-
-	/* Set up the client classification system. */
-	classification_setup ();
-
-	/* Initialize the omapi system. */
-	result = omapi_init ();
-	if (result != ISC_R_SUCCESS)
-		log_fatal ("Can't initialize OMAPI: %s",
-			   isc_result_totext (result));
-
-	/* Set up the OMAPI wrappers for common objects. */
-	dhcp_db_objects_setup ();
-	/* Set up the OMAPI wrappers for various server database internal
-	   objects. */
-	dhcp_common_objects_setup ();
-
 	/* Initially, log errors to stderr as well as to syslogd. */
 	openlog ("dhcpd", LOG_NDELAY, DHCPD_LOG_FACILITY);
 
@@ -488,6 +467,40 @@ main(int argc, char **argv) {
 		quiet = 0;
 		log_perror = 0;
 	}
+#ifndef DEBUG
+	/*
+	 * We need to fork before we call the context create
+	 * call that creates the worker threads!
+	 */
+	if (daemon) {
+		/* First part of becoming a daemon... */
+		if ((pid = fork ()) < 0)
+			log_fatal ("Can't fork daemon: %m");
+		else if (pid)
+			exit (0);
+	}
+#endif
+
+	/* Set up the isc and dns library managers */
+	status = dhcp_context_create();
+	if (status != ISC_R_SUCCESS)
+		log_fatal("Can't initialize context: %s",
+			  isc_result_totext(status));
+
+	/* Set up the client classification system. */
+	classification_setup ();
+
+	/* Initialize the omapi system. */
+	result = omapi_init ();
+	if (result != ISC_R_SUCCESS)
+		log_fatal ("Can't initialize OMAPI: %s",
+			   isc_result_totext (result));
+
+	/* Set up the OMAPI wrappers for common objects. */
+	dhcp_db_objects_setup ();
+	/* Set up the OMAPI wrappers for various server database internal
+	   objects. */
+	dhcp_common_objects_setup ();
 
 #if defined (TRACING)
 	trace_init (set_time, MDL);
@@ -770,13 +783,6 @@ main(int argc, char **argv) {
 #endif /* DHCPv6 */
 
 #ifndef DEBUG
-	if (daemon) {
-		/* First part of becoming a daemon... */
-		if ((pid = fork ()) < 0)
-			log_fatal ("Can't fork daemon: %m");
-		else if (pid)
-			exit (0);
-	}
  
 #if defined (PARANOIA)
 	/* change uid to the specified one */

Reply via email to