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

(write_err_cb): Increase the penalty, so we don't process anything

	more from this
(read_from_connection): isc_disable() can fail.  Handle that case.
(check_idle_callback): Make sure the same connection is never
	processed more than once during a call to this function.
parent c20f0685
/*
* $Id: connections.c,v 0.106 2003/07/28 07:52:06 ceder Exp $
* $Id: connections.c,v 0.107 2003/07/30 17:58:37 ceder Exp $
* Copyright (C) 1991-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -709,6 +709,7 @@ write_err_cb(struct isc_mcb *UNUSED(cb_mcb),
if (saved_errno != ECONNRESET && saved_errno != EPIPE)
kom_log("Failed to write to client %lu from %s: %s\n",
cp->session_no, cp->peer, strerror(saved_errno));
cp->penalty += param.max_penalty;
add_to_kill_list(cp);
}
......@@ -865,8 +866,11 @@ read_from_connection(Connection *conn)
if (conn->penalty >= param.max_penalty)
{
isc_disable(conn->isc_session);
queue_add(conn);
/* isc_disable() will fail if we have received EPIPE on
this socket. In that case will soon close it, since
write_err_cb() has added it to the kill list. */
if (isc_disable(conn->isc_session) == 0)
queue_add(conn);
}
}
......@@ -920,6 +924,8 @@ check_idle_callback(oop_source *UNUSED(source),
{
Connection *c;
Connection *next;
Connection *head = NULL;
Connection *tail = NULL;
set_time();
is_idle = !work_done;
......@@ -930,7 +936,7 @@ check_idle_callback(oop_source *UNUSED(source),
is_idle = FALSE;
++penalty_generation;
for (next = queue_first; next != NULL && !go_and_die; )
for (next = queue_first; next != NULL; )
{
c = next;
next = next->queue_next;
......@@ -938,12 +944,31 @@ check_idle_callback(oop_source *UNUSED(source),
if (c->penalty < param.low_penalty)
{
queue_remove(c);
isc_enable(c->isc_session);
read_from_connection(c);
if (head == NULL)
head = c;
else
tail->queue_next = c;
tail = c;
}
}
}
for (next = head; next != NULL; )
{
c = next;
next = next->queue_next;
c->queue_next = NULL;
if (isc_enable(c->isc_session) < 0)
restart_kom("failed to re-enable session\n");
/* The call to read_from_connection() might add the
connection to the queue. That's why we remove all entries
first, and use a private queue within this function. */
if (!go_and_die)
read_from_connection(c);
}
if (!is_idle)
enable_idle_check();
......@@ -978,6 +1003,7 @@ data_available_callback(oop_source *source,
assert(event == OOP_READ);
assert(conn->isc_session->fd == fd);
assert(conn->isc_session->master->event_source == source);
assert(conn->on_queue == FALSE);
/* Something arrived, so we are busy. */
if (is_idle)
......
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