Commit b3507a72 authored by Per Cederqvist's avatar Per Cederqvist

Connection->kill_me deleted. add_to_kill_list() added and used instead.

parent c2424283
Fri Apr 10 13:46:41 1992 Per Cederqvist (ceder@lysator)
* Since lyskomd spended 25% of the time in check_kill_flag it was
rewritten. Instead of having a flag in the Connection that is
checked once after every atomic call a linked list of connections
that shall be killed is created.
* connections.h (Connection): The field kill_me deleted.
* connections.[hc] (add_to_kill_list): New function.
* connections.c (kill_list_size): New variables.
* connections.c (check_kill_flg): Rewritten to use the kill_list.
* internal-connections.c (EMPTY_CONNECTION, new_client): Don't try
to initialize kill_me.
* session.c (disconnect): Use add_to_kill_list() instead of kill_me.
Thu Apr 9 00:15:33 1992 Per Cederqvist (ceder@lysator)
* Version 1.1.1 (not released).
......
/*
* $Id: connections.c,v 0.14 1992/04/04 17:26:09 ceder Exp $
* $Id: connections.c,v 0.15 1992/04/10 11:56:30 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -30,7 +30,7 @@
* Created by Willf|r 31/3-90. Mostly written by ceder.
*/
static char *rcsid = "$Id: connections.c,v 0.14 1992/04/04 17:26:09 ceder Exp $";
static char *rcsid = "$Id: connections.c,v 0.15 1992/04/10 11:56:30 ceder Exp $";
#include <errno.h>
......@@ -328,7 +328,7 @@ parse_unparsed(Connection *client)
break;
case ISC_LOGOUT:
client->kill_me = TRUE;
add_to_kill_list(client);
break;
}
......@@ -422,12 +422,7 @@ mux_handle_packet(Mux *mux)
mux->scb->info.tcp.hostname));
BUG((" is logging out by request]\n"));
#if 0
logout_client(cp);
end_of_atomic(FALSE); /* ??? */
#else
cp->kill_me = TRUE;
#endif
add_to_kill_list(cp);
break;
case 3: /* msg */
......@@ -635,6 +630,31 @@ dump_statistics(void)
last_dump = now;
}
/* List of connections to kill. */
Session_no *kill_list = NULL;
int kill_list_size = 0;
/* Schedule this client for termination. */
void
add_to_kill_list(Connection *conn)
{
if (kill_list == NULL)
{
if (kill_list_size != 0)
restart_kom("add_to_kill_list(): size = %d\n", kill_list_size);
kill_list_size = 1;
kill_list = smalloc(sizeof(Session_no));
}
else
{
kill_list_size++;
kill_list = srealloc(kill_list, kill_list_size * sizeof(Session_no));
}
kill_list[kill_list_size-1] = conn->session_no;
}
/*
* check_kill_flg must NEVER be called inside an atomic call!
......@@ -642,7 +662,6 @@ dump_statistics(void)
static void
check_kill_flg(void)
{
Session_no i = 0;
Connection *conn;
if ( active_connection != NULL )
......@@ -651,16 +670,24 @@ check_kill_flg(void)
active_connection->session_no);
}
while ( (i = traverse_connections (i)) != 0 )
while (kill_list_size > 0)
{
conn = get_conn_by_number(i);
if ( conn->kill_me == TRUE )
--kill_list_size;
conn = get_conn_by_number (kill_list[kill_list_size]);
if (conn == NULL)
{
logout_client(conn);
end_of_atomic(FALSE);
log("check_kill_flg(): Connection %d doesn't exist.\n",
kill_list[kill_list_size]);
}
else
{
logout_client (conn);
end_of_atomic (FALSE);
}
}
sfree (kill_list);
kill_list = NULL;
}
static void
......@@ -753,7 +780,7 @@ logout_request(ISCECB *event)
event->session->info.tcp.hostname));
BUG((" is logging out]\n"));
cp->kill_me = TRUE;
add_to_kill_list(cp);
}
}
......
/*
* $Id: connections.h,v 0.9 1992/04/04 17:26:49 ceder Exp $
* $Id: connections.h,v 0.10 1992/04/10 11:56:32 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -23,7 +23,7 @@
* Please mail bug reports to bug-lyskom@lysator.liu.se.
*/
/*
* $Id: connections.h,v 0.9 1992/04/04 17:26:49 ceder Exp $
* $Id: connections.h,v 0.10 1992/04/10 11:56:32 ceder Exp $
*
* connections.h -- The top level of the communication packet.
*
......@@ -101,7 +101,6 @@ typedef struct connection {
received from the client. */
Session_no session_no; /* A unique number. */
Bool kill_me; /* Yeah! */
} Connection;
/*
* It is guaranteed that in the Connection struct the pers_no and person
......@@ -217,3 +216,7 @@ dump_statistics(void);
extern void
logout_all_clients(void);
extern void
add_to_kill_list(Connection *conn);
/*
* $Id: internal-connections.c,v 0.8 1992/04/01 20:50:42 ceder Exp $
* $Id: internal-connections.c,v 0.9 1992/04/10 11:56:34 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Abstract routines on the data type Connection.
*/
static char *rcsid = "$Id: internal-connections.c,v 0.8 1992/04/01 20:50:42 ceder Exp $";
static char *rcsid = "$Id: internal-connections.c,v 0.9 1992/04/10 11:56:34 ceder Exp $";
#include "exp.h"
......@@ -64,8 +64,7 @@ INTERNAL const Connection EMPTY_CONNECTION =
NULL_CONF_TYPE_i, EMPTY_tm_i,
/* Protocol independent... */
EMPTY_STRING_i, 0, FALSE,
NO_TIME,
0, FALSE});
NO_TIME, 0});
static int no_of_allocated_connections = 0;
......@@ -119,7 +118,6 @@ new_client(void)
c->username = EMPTY_STRING;
c->ident_user = EMPTY_STRING;
c->invisible = FALSE;
c->kill_me = FALSE;
return c;
}
......
/*
* $Id: session.c,v 0.9 1992/04/07 14:53:31 ceder Exp $
* $Id: session.c,v 0.10 1992/04/10 11:56:36 ceder Exp $
* Copyright (C) 1991 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -28,7 +28,7 @@
* Session control and miscellaneous.
*/
static char *rcsid = "$Id: session.c,v 0.9 1992/04/07 14:53:31 ceder Exp $";
static char *rcsid = "$Id: session.c,v 0.10 1992/04/10 11:56:36 ceder Exp $";
#include <time.h>
......@@ -564,7 +564,7 @@ disconnect (Session_no session_no)
if ( is_supervisor(cptr->pers_no, NULL, ACTPERS, ACT_P)
|| session_no == active_connection->session_no )
{
cptr->kill_me = TRUE;
add_to_kill_list(cptr);
return OK;
}
else
......
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