philipp / rpms / dhcp

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