Commit 439a654a authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(init_connection): Set the new kill_status field of Connection instead

	of the old kill_pending field.
(new_client): Ditto.
(check_conn_exists): Dead code removed.
(get_conn_by_number): Don't crash if no connections exist.  It isn't
	abnormal if the supplied connection number doesn't exist, so
	remove code inside NDEFENSIVE_CHECKS that assumed it was.
	Whitespace fixes.
parent aec73f28
/*
* $Id: internal-connections.c,v 0.64 2003/08/20 17:40:27 ceder Exp $
* $Id: internal-connections.c,v 0.65 2003/08/22 20:33:32 ceder Exp $
* Copyright (C) 1991-1994, 1996-2002 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -56,10 +56,6 @@
#include "timeval-util.h"
#include "stats.h"
/* We don't need the defensive checks in this file. They have been
tested enough the last few years. They also consume a lot of CPU. */
#define NDEFENSIVE_CHECKS 1
INTERNAL Connection *all_connections = NULL;
INTERNAL Session_no no_of_connection_attempts = 0;
......@@ -155,7 +151,7 @@ init_connection(Connection *conn)
conn->unparsed = EMPTY_STRING;
conn->first_to_parse = 0;
conn->more_to_parse = FALSE;
conn->kill_pending = FALSE;
conn->kill_status = ks_none;
conn->penalty = 0;
conn->penalty_generation = 0;
......@@ -215,7 +211,7 @@ new_client(void)
c->protocol = '\0'; /* Reserved to mean 'no protocol specified yet' */
c->unparsed = EMPTY_STRING;
c->first_to_parse = 0;
c->kill_pending = FALSE;
c->kill_status = ks_none;
c->more_to_parse = TRUE;
c->active_time = current_time;
c->pers_no = 0;
......@@ -323,33 +319,6 @@ kill_client(Connection *cp)
--no_of_allocated_connections;
}
#ifndef NDEFENSIVE_CHECKS
INTERNAL void
check_conn_exists(Connection *foo)
{
/* Check that foo really is active. */
Connection *c = all_connections;
Bool found = FALSE;
do
{
if ( c == foo )
found = TRUE;
c = c->next;
}
while ( c != all_connections && found == FALSE );
if ( found == FALSE )
restart_kom("%s: foo == %ld not found in all_connections.\n",
"get_conn_by_number",
last_conn->session_no);
}
#endif
/*
* Session_nos must NOT be recycled, or this code might break!
*/
......@@ -358,39 +327,30 @@ get_conn_by_number (Session_no session_no)
{
Connection *end;
if ( last_conn == NULL )
if (all_connections == NULL)
return NULL;
if (last_conn == NULL)
last_conn = all_connections;
else if ( all_connections == NULL )
{
restart_kom("get_conn_by_number(%ld): last_conn = %ld %s",
session_no,
last_conn->session_no,
"and all_connections == NULL");
}
#ifndef NDEFENSIVE_CHECKS
else
check_conn_exists(last_conn);
#endif
end = last_conn;
if (session_no == 0)
{
if (active_connection == NULL)
{
restart_kom("get_conn_by_number: No session-no and no active connection");
}
restart_kom("get_conn_by_number:"
" No session-no and no active connection");
session_no = active_connection->session_no;
}
do
{
if ( last_conn->session_no == session_no )
if (last_conn->session_no == session_no)
return last_conn;
last_conn = last_conn->next;
}
while ( last_conn != end);
while (last_conn != end);
return 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