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

(add_to_kill_list): Check and update kill_pending.

(check_kill_flg): Ditto.
(read_from_connection): Ignore connections with a pending kill.
(toploop): Call check_kill_flg() during shutdown if any kill is
	pending, so that the kill list is freed.
parent 238078d9
/*
* $Id: connections.c,v 0.109 2003/07/31 23:02:59 ceder Exp $
* $Id: connections.c,v 0.110 2003/08/01 09:37:19 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -535,9 +535,17 @@ add_to_kill_list(Connection *conn)
oop_source *source;
int i;
if (conn->kill_pending)
{
for (i = 0; i < kill_list_size; i++)
if (kill_list[i] == conn->session_no)
return;
restart_kom("add_to_kill_list(): kill_pending set but not on list.\n");
}
for (i = 0; i < kill_list_size; i++)
if (kill_list[i] == conn->session_no)
return;
restart_kom("add_to_kill_list(): on list but not kill_pending.\n");
if (kill_list == NULL)
{
......@@ -554,6 +562,7 @@ add_to_kill_list(Connection *conn)
}
kill_list[kill_list_size-1] = conn->session_no;
conn->kill_pending = TRUE;
if (!kill_pending)
{
......@@ -639,6 +648,8 @@ check_kill_flg(oop_source *UNUSED(source),
}
else
{
assert(conn->kill_pending);
conn->kill_pending = FALSE;
logout_client(conn);
end_of_atomic();
changed = TRUE;
......@@ -830,13 +841,16 @@ read_from_connection(Connection *conn)
adjust_penalty(conn);
while (!would_block && !go_and_die && conn->penalty < param.max_penalty)
while (!would_block && !go_and_die && conn->penalty < param.max_penalty
&& !conn->kill_pending)
{
while (conn->more_to_parse
&& !go_and_die && conn->penalty < param.max_penalty)
&& !go_and_die && conn->penalty < param.max_penalty
&& !conn->kill_pending)
need_flush |= parse_unparsed(conn);
if (go_and_die || conn->penalty >= param.max_penalty)
if (go_and_die || conn->penalty >= param.max_penalty
|| conn->kill_pending)
break;
if (!conn->more_to_parse)
......@@ -869,7 +883,7 @@ read_from_connection(Connection *conn)
}
}
if (need_flush)
if (need_flush && !kill_pending)
isc_flush(conn->isc_session);
/* Delete the parsed part of 'unparsed' */
......@@ -1056,10 +1070,7 @@ toploop(void)
strerror(errno));
if (kill_pending)
{
source->cancel_time(source, OOP_TIME_NOW, check_kill_flg, NULL);
kill_pending = 0;
}
check_kill_flg(NULL, OOP_TIME_NOW, NULL);
if (is_idle == FALSE)
source->cancel_time(source, OOP_TIME_NOW, check_idle_callback, NULL);
......
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