From b3507a728740078b1ff1f0b9b654bcb62242d21a Mon Sep 17 00:00:00 2001 From: Per Cederqvist <ceder@lysator.liu.se> Date: Fri, 10 Apr 1992 11:56:36 +0000 Subject: [PATCH] Connection->kill_me deleted. add_to_kill_list() added and used instead. --- src/server/ChangeLog | 14 +++++++ src/server/connections.c | 61 ++++++++++++++++++++++--------- src/server/connections.h | 9 +++-- src/server/internal-connections.c | 8 ++-- src/server/session.c | 6 +-- 5 files changed, 70 insertions(+), 28 deletions(-) diff --git a/src/server/ChangeLog b/src/server/ChangeLog index 3768ccc5d..87abc5430 100644 --- a/src/server/ChangeLog +++ b/src/server/ChangeLog @@ -1,3 +1,17 @@ +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). diff --git a/src/server/connections.c b/src/server/connections.c index d32a520f0..6dc5c745d 100644 --- a/src/server/connections.c +++ b/src/server/connections.c @@ -1,5 +1,5 @@ /* - * $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); } } diff --git a/src/server/connections.h b/src/server/connections.h index a282389a1..180c5d4b0 100644 --- a/src/server/connections.h +++ b/src/server/connections.h @@ -1,5 +1,5 @@ /* - * $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); + diff --git a/src/server/internal-connections.c b/src/server/internal-connections.c index 68325f0d7..b3c7e9f76 100644 --- a/src/server/internal-connections.c +++ b/src/server/internal-connections.c @@ -1,5 +1,5 @@ /* - * $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; } diff --git a/src/server/session.c b/src/server/session.c index fd06a5ffd..56a9c898d 100644 --- a/src/server/session.c +++ b/src/server/session.c @@ -1,5 +1,5 @@ /* - * $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 -- GitLab