Commit 6d1ed066 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(get_host_name): New function.

(login_request): Use get_host_name.
(logout_request): Ditto.  (Bug 627).
parent 33c27ed0
/*
* $Id: connections.c,v 0.74 2002/03/29 22:29:48 ceder Exp $
* $Id: connections.c,v 0.75 2002/08/11 09:36:56 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -583,6 +583,45 @@ check_kill_flg(void)
}
}
static char *
get_host_name(IscAddress *addr)
{
char *res = NULL;
char *hostname = NULL;
struct timeval before;
struct timeval after;
double diff = -1.0;
if (param.use_dns)
{
if (gettimeofday(&before, NULL) < 0)
kom_log("gettimeofday failed: %s\n", strerror(errno));
res = hostname = isc_gethostname(addr, NULL, 0);
if (gettimeofday(&after, NULL) < 0)
kom_log("gettimeofday failed: %s\n", strerror(errno));
diff = (after.tv_sec - before.tv_sec
+ 1e-6 * (after.tv_usec - before.tv_usec));
}
if (res == NULL)
res = isc_getipnum(addr, NULL, 0);
if (param.use_dns && diff > param.dns_log_threshold)
{
if (hostname == NULL)
kom_log("Slow bad DNS: %s failed after %f seconds\n", res, diff);
else
kom_log("Slow DNS: got %s after %f seconds\n", res, diff);
}
return res;
}
static void
login_request(IscEvent *event)
{
......@@ -599,9 +638,7 @@ login_request(IscEvent *event)
return;
}
hostname = isc_gethostname(event->session->info.tcp.raddr, NULL, 0);
if (hostname == NULL)
hostname = isc_getipnum(event->session->info.tcp.raddr, NULL, 0);
hostname = get_host_name(event->session->info.tcp.raddr);
if (hostname == NULL)
kom_log("WNG: login_request(): unknown hostid.\n");
......@@ -645,7 +682,7 @@ logout_request(IscEvent *event)
cp = event->session->udg;
BUG(("\n[Client %lu from %s", cp->session_no,
isc_gethostname(event->session->info.tcp.raddr, NULL, 0)));
get_host_name(event->session->info.tcp.raddr)));
BUG((" is logging out]\n"));
add_to_kill_list(cp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment