lwresd.c revision 1eee03d8cfb7f54c3c57d12365fba530795806cf
/*
* Copyright (C) 2000 Internet Software Consortium.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
* ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
* CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
* DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
* PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
* ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
* SOFTWARE.
*/
/*
* Main program for the Lightweight Resolver Daemon.
*
* To paraphrase the old saying about X11, "It's not a lightweight deamon
* for resolvers, it's a deamon for lightweight resolvers".
*/
#include <config.h>
#include <stdlib.h>
#include <dns/dispatch.h>
#include <dns/resolver.h>
#include <named/lwdclient.h>
/*
* The goal number of clients we can handle will be NTASKS * NRECVS.
*/
static void
ISC_LOG_CRITICAL, "exiting (due to fatal error)");
exit(1);
}
/*
* Wrappers around our memory management stuff, for the lwres functions.
*/
static void *
}
static void
}
static void
unsigned int i;
/*
* Wait for everything to die off by waiting for the sockets
* to be detached.
*/
/*
* Kill off the view.
*/
}
static void
int lwresult;
int i;
if (lwresult != LWRES_R_SUCCESS)
return;
if (lwresult != LWRES_R_SUCCESS)
goto out;
#if 1
#endif
/*
* Run through the list of nameservers, and set them to be our
* forwarders.
*/
case AF_INET:
break;
case AF_INET6:
break;
default:
break;
}
}
out:
}
unsigned int attrs;
/*
* View.
*/
if (result != ISC_R_SUCCESS)
return (result);
/*
* Cache.
*/
if (result != ISC_R_SUCCESS)
goto out;
/*
* Resolver.
*
* XXXMLG hardwired number of tasks.
*/
if (isc_net_probeipv6() == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto out;
}
if (isc_net_probeipv4() == ISC_R_SUCCESS) {
if (result != ISC_R_SUCCESS)
goto out;
}
if (result != ISC_R_SUCCESS)
goto out;
if (result != ISC_R_SUCCESS)
goto out;
/*
* If we have forwarders, set them here.
*/
}
}
return (ISC_R_SUCCESS);
out:
return (result);
}
void
unsigned int i, j;
&sock);
if (result != ISC_R_SUCCESS)
if (ns_g_port != 0)
if (result != ISC_R_SUCCESS) {
}
if (result != ISC_R_SUCCESS)
if (result != ISC_R_SUCCESS)
sizeof(ns_lwdclientmgr_t) * NTASKS);
/*
* Create one task for each client manager.
*/
for (i = 0 ; i < NTASKS ; i++) {
char name[16];
if (result != ISC_R_SUCCESS)
break;
if (result != ISC_R_SUCCESS)
break;
if (result != ISC_R_SUCCESS) {
break;
}
}
INSIST(i > 0);
/*
* Now, run through each client manager and populate it with
* client structures. Do this by creating one receive for each
* task, in a loop, so each task has a chance of getting at least
* one client structure.
*/
for (i = 0 ; i < NRECVS ; i++) {
break;
}
INSIST(i > 0);
/*
* Issue one read request for each task we have.
*/
}
}
void
/*
* Free up memory allocated. This is somewhat magical. We allocated
* the ns_lwdclient_t's in blocks, but the first task always has the
* first pointer. Just loop here, freeing them.
*/
}
}