-/* $Id: ipcache.cc,v 1.25 1996/04/16 20:30:45 wessels Exp $ */
+/* $Id: ipcache.cc,v 1.26 1996/04/17 23:48:23 wessels Exp $ */
/*
* DEBUG: Section 14 ipcache: IP Cache
struct _line_entry *next;
} line_entry;
-#define TEST_SITE 5
-static char *test_site[TEST_SITE] =
-{
- "internic.net",
- "usc.edu",
- "cs.colorado.edu",
- "mit.edu",
- "yale.edu"
-};
-
static dnsserver_entry **dns_child_table = NULL;
static int last_dns_dispatched = 2;
static struct hostent *static_result = NULL;
static int dns_child_alive = 0;
-static int ipcache_initialized = 0;
char *dns_error_message = NULL; /* possible error message */
HashID ip_table = 0;
int ipcache_testname()
{
- int success, i;
+ wordlist *w = NULL;
debug(14, 1, "Performing DNS Tests...\n");
-
- for (success = i = 0; i < TEST_SITE; i++) {
- if (gethostbyname(test_site[i]) != NULL)
- ++success;
+ if ((w = getDnsTestnameList()) == NULL)
+ return 1;
+ for (; w; w = w->next) {
+ if (gethostbyname(w->key) != NULL)
+ return 1;
}
- return (success == 0) ? -1 : 0;
+ return 0;
}
-
-
/*
* open a UNIX domain socket for rendevouing with dnsservers
*/
void ipcache_add_to_hash(e)
ipcache_entry *e;
{
- if (!ipcache_initialized)
- ipcache_init();
if (hash_join(ip_table, (hash_link *) e)) {
debug(14, 1, "ipcache_add_to_hash: Cannot add %s (%p) to hash table %d.\n",
e->name, e, ip_table);
safe_free(dns_child_table);
dns_child_table = (dnsserver_entry **) xcalloc(N, sizeof(dnsserver_entry));
dns_child_alive = 0;
- debug(14, 1, "ipcache_init: Starting %d 'dns_server' processes\n", N);
+ debug(14, 1, "ipcacheOpenServers: Starting %d 'dns_server' processes\n", N);
for (i = 0; i < N; i++) {
dns_child_table[i] = (dnsserver_entry *) xcalloc(1, sizeof(dnsserver_entry));
if ((dnssocket = ipcache_create_dnsserver(prg)) < 0) {
- debug(14, 1, "ipcache_init: WARNING: Cannot run 'dnsserver' process.\n");
+ debug(14, 1, "ipcacheOpenServers: WARNING: Cannot run 'dnsserver' process.\n");
debug(14, 1, " Fallling back to the blocking version.\n");
dns_child_table[i]->alive = 0;
} else {
COMM_SELECT_READ,
(PF) ipcache_dnsHandleRead,
(void *) dns_child_table[i]);
- debug(14, 3, "ipcache_init: 'dns_server' %d started\n", i);
+ debug(14, 3, "ipcacheOpenServers: 'dns_server' %d started\n", i);
}
}
}
void ipcache_init()
{
- debug(14, 3, "ipcache_init: Called. ipcache_initialized=%d getDnsChildren()=%d\n", ipcache_initialized, getDnsChildren());
-
- if (ipcache_initialized)
- return;
+ debug(14, 3, "Initializing IP Cache...\n");
last_dns_dispatched = getDnsChildren() - 1;
if (!dns_error_message)
/* test naming lookup */
if (!do_dns_test) {
- debug(14, 4, "ipcache_init: Skipping DNS name lookup tests, -D flag given.\n");
- } else if (ipcache_testname() < 0) {
- fatal("ipcache_init: DNS name lookup appears to be broken on this machine.");
+ debug(14, 4, "ipcache_init: Skipping DNS name lookup tests.\n");
+ } else if (!ipcache_testname()) {
+ fatal("ipcache_init: DNS name lookup tests failed/");
} else {
debug(14, 1, "Successful DNS name lookup tests...\n");
}
(float) IP_HIGH_WATER) / (float) 100);
ipcache_low = (long) (((float) MAX_IP *
(float) IP_LOW_WATER) / (float) 100);
-
- ipcache_initialized = 1;
}
/* clean up the pending entries in dnsserver */
unsigned int a1, a2, a3, a4;
struct hostent *s_result = NULL;
- if (!ipcache_initialized)
- ipcache_init();
-
if (!name) {
debug(14, 5, "ipcache_gethostbyname: Invalid argument?\n");
return (NULL);