/*
- * $Id: comm_select.cc,v 1.29 1999/01/18 22:23:33 wessels Exp $
+ * $Id: comm_select.cc,v 1.30 1999/04/16 01:00:49 wessels Exp $
*
* DEBUG: section 5 Socket Functions
*
#endif
static int fdIsHttp(int fd);
static int fdIsIcp(int fd);
+static int fdIsDns(int fd);
static int commDeferRead(int fd);
static void checkTimeouts(void);
static OBJH commIncomingStats;
#define INCOMING_FACTOR 5
#define MAX_INCOMING_INTERVAL (MAX_INCOMING_INTEGER << INCOMING_FACTOR)
static int icp_io_events = 0;
+static int dns_io_events = 0;
static int http_io_events = 0;
static int incoming_icp_interval = 16 << INCOMING_FACTOR;
+static int incoming_dns_interval = 16 << INCOMING_FACTOR;
static int incoming_http_interval = 16 << INCOMING_FACTOR;
#define commCheckICPIncoming (++icp_io_events > (incoming_icp_interval>> INCOMING_FACTOR))
+#define commCheckDNSIncoming (++dns_io_events > (incoming_dns_interval>> INCOMING_FACTOR))
#define commCheckHTTPIncoming (++http_io_events > (incoming_http_interval>> INCOMING_FACTOR))
static int
return 0;
}
+static int
+fdIsDns(int fd)
+{
+ if (fd == DnsSocket)
+ return 1;
+ return 0;
+}
+
static int
fdIsHttp(int fd)
{
statHistCount(&Counter.comm_icp_incoming, nevents);
}
+static void
+comm_poll_dns_incoming(void)
+{
+ int nfds = 0;
+ int fds[2];
+ int nevents;
+ dns_io_events = 0;
+ if (DnsSocket < 0)
+ return;
+ fds[nfds++] = DnsSocket;
+ nevents = comm_check_incoming_poll_handlers(nfds, fds);
+ incoming_dns_interval += Config.comm_incoming.dns_average - nevents;
+ if (incoming_dns_interval < Config.comm_incoming.dns_min_poll)
+ incoming_dns_interval = Config.comm_incoming.dns_min_poll;
+ if (incoming_dns_interval > MAX_INCOMING_INTERVAL)
+ incoming_dns_interval = MAX_INCOMING_INTERVAL;
+ if (nevents > INCOMING_DNS_MAX)
+ nevents = INCOMING_DNS_MAX;
+ statHistCount(&Counter.comm_dns_incoming, nevents);
+}
+
static void
comm_poll_http_incoming(void)
{
unsigned long nfds;
int num;
int callicp = 0, callhttp = 0;
+ int calldns = 0;
static time_t last_timeout = 0;
double timeout = current_dtime + (msec / 1000.0);
double start;
#endif
if (commCheckICPIncoming)
comm_poll_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_poll_dns_incoming();
if (commCheckHTTPIncoming)
comm_poll_http_incoming();
- callicp = callhttp = 0;
+ callicp = calldns = callhttp = 0;
nfds = 0;
maxfd = Biggest_FD + 1;
for (i = 0; i < maxfd; i++) {
callicp = 1;
continue;
}
+ if (fdIsDns(fd)) {
+ calldns = 1;
+ continue;
+ }
if (fdIsHttp(fd)) {
callhttp = 1;
continue;
}
if (commCheckICPIncoming)
comm_poll_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_poll_dns_incoming();
if (commCheckHTTPIncoming)
comm_poll_http_incoming();
}
}
if (commCheckICPIncoming)
comm_poll_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_poll_dns_incoming();
if (commCheckHTTPIncoming)
comm_poll_http_incoming();
}
}
if (callicp)
comm_poll_icp_incoming();
+ if (calldns)
+ comm_poll_dns_incoming();
if (callhttp)
comm_poll_http_incoming();
#if !ALARM_UPDATES_TIME
statHistCount(&Counter.comm_icp_incoming, nevents);
}
+static void
+comm_select_dns_incoming(void)
+{
+ int nfds = 0;
+ int fds[2];
+ int nevents;
+ dns_io_events = 0;
+ if (DnsSocket < 0)
+ return;
+ fds[nfds++] = DnsSocket;
+ nevents = comm_check_incoming_select_handlers(nfds, fds);
+ incoming_dns_interval += Config.comm_incoming.dns_average - nevents;
+ if (incoming_dns_interval < 0)
+ incoming_dns_interval = 0;
+ if (incoming_dns_interval > MAX_INCOMING_INTERVAL)
+ incoming_dns_interval = MAX_INCOMING_INTERVAL;
+ if (nevents > INCOMING_DNS_MAX)
+ nevents = INCOMING_DNS_MAX;
+ statHistCount(&Counter.comm_dns_incoming, nevents);
+}
+
static void
comm_select_http_incoming(void)
{
int maxfd;
int num;
int callicp = 0, callhttp = 0;
+ int calldns = 0;
int maxindex;
int k;
int j;
#endif
if (commCheckICPIncoming)
comm_select_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_select_dns_incoming();
if (commCheckHTTPIncoming)
comm_select_http_incoming();
- callicp = callhttp = 0;
+ callicp = calldns = callhttp = 0;
maxfd = Biggest_FD + 1;
xmemcpy(&readfds, &global_readfds,
howmany(maxfd, FD_MASK_BITS) * FD_MASK_BYTES);
callicp = 1;
continue;
}
+ if (fdIsDns(fd)) {
+ calldns = 1;
+ continue;
+ }
if (fdIsHttp(fd)) {
callhttp = 1;
continue;
}
if (commCheckICPIncoming)
comm_select_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_select_dns_incoming();
if (commCheckHTTPIncoming)
comm_select_http_incoming();
EBIT_CLR(tmask, k); /* this bit is done */
callicp = 1;
continue;
}
+ if (fdIsDns(fd)) {
+ calldns = 1;
+ continue;
+ }
if (fdIsHttp(fd)) {
callhttp = 1;
continue;
}
if (commCheckICPIncoming)
comm_select_icp_incoming();
+ if (commCheckDNSIncoming)
+ comm_select_dns_incoming();
if (commCheckHTTPIncoming)
comm_select_http_incoming();
EBIT_CLR(tmask, k); /* this bit is done */
}
if (callicp)
comm_select_icp_incoming();
+ if (calldns)
+ comm_select_dns_incoming();
if (callhttp)
comm_select_http_incoming();
return COMM_OK;
StatCounters *f = &Counter;
storeAppendPrintf(sentry, "Current incoming_icp_interval: %d\n",
incoming_icp_interval >> INCOMING_FACTOR);
+ storeAppendPrintf(sentry, "Current incoming_dns_interval: %d\n",
+ incoming_dns_interval >> INCOMING_FACTOR);
storeAppendPrintf(sentry, "Current incoming_http_interval: %d\n",
incoming_http_interval >> INCOMING_FACTOR);
storeAppendPrintf(sentry, "\n");
storeAppendPrintf(sentry, "ICP Messages handled per comm_select_icp_incoming() call:\n");
#endif
statHistDump(&f->comm_icp_incoming, sentry, statHistIntDumper);
+#ifdef HAVE_POLL
+ storeAppendPrintf(sentry, "DNS Messages handled per comm_poll_dns_incoming() call:\n");
+#else
+ storeAppendPrintf(sentry, "DNS Messages handled per comm_select_dns_incoming() call:\n");
+#endif
+ statHistDump(&f->comm_dns_incoming, sentry, statHistIntDumper);
#ifdef HAVE_POLL
storeAppendPrintf(sentry, "HTTP Messages handled per comm_poll_http_incoming() call:\n");
#else
/*
- * $Id: dns_internal.cc,v 1.3 1999/04/15 06:03:48 wessels Exp $
+ * $Id: dns_internal.cc,v 1.4 1999/04/16 01:00:51 wessels Exp $
*
* DEBUG: section 78 DNS lookups; interacts with lib/rfc1035.c
* AUTHOR: Duane Wessels
static ns *nameservers = NULL;
static int nns = 0;
static int nns_alloc = 0;
-static int domain_socket = -1;
static dlink_list lru_list;
static int event_queued = 0;
storeAppendPrintf(sentry, "------ ---- ----- --------\n");
for (n = lru_list.head; n; n = n->next) {
q = n->data;
- storeAppendPrintf(sentry, "%#06hx %4d %5d %8.3f\n",
- q->id, q->sz, q->nsends,
+ storeAppendPrintf(sentry, "%#06x %4d %5d %8.3f\n",
+ (int) q->id, q->sz, q->nsends,
tvSubDsec(q->start_t, current_time));
}
storeAppendPrintf(sentry, "\nNameservers:\n");
idnsSendQuery(idns_query * q)
{
int x;
- int ns = 0;
+ int ns;
/* XXX Select nameserver */
assert(nns > 0);
assert(q->lru.next == NULL);
assert(q->lru.prev == NULL);
- x = comm_udp_sendto(domain_socket,
+ ns = q->nsends % nns;
+ x = comm_udp_sendto(DnsSocket,
&nameservers[ns].S,
sizeof(nameservers[ns].S),
q->buf,
static void
idnsRead(int fd, void *data)
{
+ int *N = data;
ssize_t len;
struct sockaddr_in from;
socklen_t from_len;
fd, xstrerror());
break;
}
+ (*N)++;
debug(78, 3) ("idnsRead: FD %d: received %d bytes from %s.\n",
fd,
len,
idnsInit(void)
{
static int init = 0;
- if (domain_socket < 0) {
- domain_socket = comm_open(SOCK_DGRAM,
+ if (DnsSocket < 0) {
+ DnsSocket = comm_open(SOCK_DGRAM,
0,
Config.Addrs.udp_outgoing,
0,
COMM_NONBLOCKING,
"DNS Socket");
- if (domain_socket < 0)
+ if (DnsSocket < 0)
fatal("Could not create a DNS socket");
- debug(78, 1) ("DNS Socket created on FD %d\n", domain_socket);
- commSetSelect(domain_socket, COMM_SELECT_READ, idnsRead, NULL, 0);
+ debug(78, 1) ("DNS Socket created on FD %d\n", DnsSocket);
+ commSetSelect(DnsSocket, COMM_SELECT_READ, idnsRead, NULL, 0);
}
if (nns == 0)
idnsParseResolvConf();
void
idnsShutdown(void)
{
- if (domain_socket < 0)
+ if (DnsSocket < 0)
return;
- comm_close(domain_socket);
- domain_socket = -1;
+ comm_close(DnsSocket);
+ DnsSocket = -1;
}
void