Commit f80480bb authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(stale_cb): New static function.

(login_request): Pass stale_cb to isc_set_read_callback().
(setup_timer): Moved to timeval-util.h, and added a return value.
	All callers updated to check it.
parent 9e3e2cae
/*
* $Id: connections.c,v 0.108 2003/07/31 17:54:24 ceder Exp $
* $Id: connections.c,v 0.109 2003/07/31 23:02:59 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -714,6 +714,18 @@ write_err_cb(struct isc_mcb *UNUSED(cb_mcb),
}
static void
stale_cb(struct isc_mcb *UNUSED(cb_mcb),
struct isc_scb *UNUSED(cb_session),
void *user)
{
Connection *cp = user;
kom_log("Client %lu from %s has stalled. Killing it.\n",
cp->session_no, cp->peer);
cp->penalty += param.max_penalty;
add_to_kill_list(cp);
}
static void
login_request(struct isc_scb *session)
......@@ -792,7 +804,8 @@ login_request(struct isc_scb *session)
update_stat(STAT_CLIENTS, 1);
dump_connections();
isc_set_read_callback(session, data_available_callback, write_err_cb, cp);
isc_set_read_callback(session, data_available_callback, write_err_cb,
stale_cb, cp);
}
static void
......@@ -875,39 +888,6 @@ read_from_connection(Connection *conn)
}
void
setup_timer(struct timeval *tv,
struct timeval interval)
{
static int errcnt = 0;
if (gettimeofday(tv, NULL) < 0)
{
if (errcnt < 20)
{
kom_log("setup_timer(): gettimeofday failed: %s\n",
strerror(errno));
if (++errcnt == 20)
kom_log("setup_timer():"
" will not log any more gettimeofday failures\n");
}
*tv = OOP_TIME_NOW;
}
else
{
tv->tv_sec += interval.tv_sec;
tv->tv_usec += interval.tv_usec;
if (tv->tv_usec > 1000000)
{
tv->tv_usec -= 1000000;
tv->tv_sec++;
}
}
assert(tv->tv_usec >= 0);
assert(tv->tv_usec < 1000000);
}
static void
enable_idle_check(void)
{
......@@ -985,7 +965,8 @@ saver_callback(oop_source *source,
struct timeval *next_timer = user;
timeout = end_of_atomic();
setup_timer(next_timer, timeout);
if (setup_timer(next_timer, timeout) < 0)
kom_log("gettimeofday failed: %s\n", strerror(errno));
source->on_time(source, *next_timer, saver_callback, user);
return OOP_CONTINUE;
......
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