Blame SOURCES/dhcp-4.2.5-ddns_port_lazy_init.patch

a512de
--- a/common/dns.c	
a512de
+++ a/common/dns.c	
a512de
@@ -1381,6 +1381,24 @@ void ddns_interlude(isc_task_t  *taskp,
a512de
 }
a512de
 
a512de
 /*
a512de
+ * Moved here from omapip/isclib.c, function dhcp_context_create.
a512de
+ * Create dnsclient only before the first use.
a512de
+ */
a512de
+static isc_result_t
a512de
+dns_client_lazy() {
a512de
+	if (dhcp_gbl_ctx.dnsclient == NULL)
a512de
+		return dns_client_createx(dhcp_gbl_ctx.mctx,
a512de
+				    dhcp_gbl_ctx.actx,
a512de
+				    dhcp_gbl_ctx.taskmgr,
a512de
+				    dhcp_gbl_ctx.socketmgr,
a512de
+				    dhcp_gbl_ctx.timermgr,
a512de
+				    0,
a512de
+				    &dhcp_gbl_ctx.dnsclient);
a512de
+	else
a512de
+		return ISC_R_SUCCESS;
a512de
+}
a512de
+
a512de
+/*
a512de
  * This routine does the generic work for sending a ddns message to
a512de
  * modify the forward record (A or AAAA) and calls one of a set of
a512de
  * routines to build the specific message.
a512de
@@ -1403,6 +1421,10 @@ ddns_modify_fwd(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
a512de
 	/* Get a pointer to the clientname to make things easier. */
a512de
 	clientname = (unsigned char *)ddns_cb->fwd_name.data;
a512de
 
a512de
+	result = dns_client_lazy();
a512de
+	if (result != ISC_R_SUCCESS)
a512de
+		return result;
a512de
+
a512de
 	/* Extract and validate the type of the address. */
a512de
 	if (ddns_cb->address.len == 4) {
a512de
 		ddns_cb->address_type = dns_rdatatype_a;
a512de
@@ -1586,6 +1608,10 @@ ddns_modify_ptr(dhcp_ddns_cb_t *ddns_cb, const char *file, int line)
a512de
 	unsigned char buf[256];
a512de
 	int buflen;
a512de
 
a512de
+	result = dns_client_lazy();
a512de
+	if (result != ISC_R_SUCCESS)
a512de
+		return result;
a512de
+
a512de
 	/*
a512de
 	 * Try to lookup the zone in the zone cache.  As with the forward
a512de
 	 * case it's okay if we don't have one, the DNS code will try to
a512de
--- a/omapip/isclib.c	
a512de
+++ a/omapip/isclib.c	
a512de
@@ -130,17 +130,7 @@ dhcp_context_create(void) {
a512de
 	if (result != ISC_R_SUCCESS)
a512de
 		goto cleanup;
a512de
 
a512de
-#if defined (NSUPDATE)
a512de
-	result = dns_client_createx(dhcp_gbl_ctx.mctx,
a512de
-				    dhcp_gbl_ctx.actx,
a512de
-				    dhcp_gbl_ctx.taskmgr,
a512de
-				    dhcp_gbl_ctx.socketmgr,
a512de
-				    dhcp_gbl_ctx.timermgr,
a512de
-				    0,
a512de
-				    &dhcp_gbl_ctx.dnsclient);
a512de
-	if (result != ISC_R_SUCCESS)
a512de
-		goto cleanup;
a512de
-#else
a512de
+#if !defined (NSUPDATE)
a512de
 	/* The dst library is inited as part of dns_lib_init, we don't
a512de
 	 * need it if NSUPDATE is enabled */
a512de
 	result = dst_lib_init(dhcp_gbl_ctx.mctx, NULL, 0);