main.c revision 738b9aa3ded1ef724922d6695cb04ec2e721bdd1
/*
* 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.
*/
#include <config.h>
#include <isc/assertions.h>
#include <isc/sockaddr.h>
#include <dns/resolver.h>
#include "client.h"
/*
* The goal number of clients we can handle will be NTASKS * NRECVS.
*/
/*
* Array of client managers. Each of these will have a task associated
* with it.
*/
unsigned int ntasks; /* number of tasks actually created */
static isc_result_t
{
/*
* View.
*/
if (result != ISC_R_SUCCESS)
goto out;
/*
* Cache.
*/
if (result != ISC_R_SUCCESS)
goto out;
/*
* Resolver.
*
* XXXMLG hardwired number of tasks.
*/
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);
}
/*
* Wrappers around our memory management stuff, for the lwres functions.
*/
static void *
{
}
static void
{
}
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:
}
int
{
unsigned int i, j;
result = isc_app_start();
/*
* Set up logging.
*/
/*
* Set the initial debug level.
*/
/*
* Create a task manager.
*/
/*
* Create a socket manager.
*/
/*
* Create a timer manager.
*/
/*
* Read resolv.conf to get our forwarders.
*/
/*
* Initialize the DNS bits. Start by loading our built-in
* root hints.
*/
/*
* We'll need a socket. It will be a UDP socket, and bound to
* 127.0.0.1 port LWRES_UDP_PORT.
*/
&sock);
/*
* Create one task for each client manager.
*/
for (i = 0 ; i < NTASKS ; i++) {
0, LWRD_SHUTDOWN,
if (result != ISC_R_SUCCESS)
break;
if (result != ISC_R_SUCCESS) {
break;
}
}
INSIST(i > 0);
ntasks = i; /* remember how many we managed to create */
/*
* 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;
for (j = 0 ; j < ntasks ; j++)
}
INSIST(i > 0);
/*
* Issue one read request for each task we have.
*/
for (j = 0 ; j < ntasks ; j++) {
}
/*
* Wait for ^c or kill.
*/
isc_app_run();
/*
* Send a shutdown event to every task.
*/
for (j = 0 ; j < ntasks ; j++) {
}
/*
* Kill off the view.
*/
/*
* Wait for the tasks to all die.
*/
printf("Waiting for task manager to die...\n");
/*
* Wait for everything to die off by waiting for the sockets
* to be detached.
*/
printf("Waiting for socket manager to die...\n");
/*
* Free up memory allocated. This is somewhat magical. We allocated
* the client_t's in blocks, but the first task always has the
* first pointer. Just loop here, freeing them.
*/
}
/*
* Now, kill off the client manager structures.
*/
/*
* Kill the memory system.
*/
return (0);
}