$Log$
+ Revision 641.24 2005/03/10 03:11:07 ajc
+ * Altered the algorithm by which the doubly-linked session list is
+ amended and culled. Decided that performance is better than cute
+ session numbers (which we don't display to the users anymore anyway)
+ and we now assign a session number (CC->cs_pid) starting with 1 when the
+ server starts and incrementing indefinitely. Need to test this more.
+
Revision 641.23 2005/03/07 04:08:07 ajc
* vcard.c: realloc fix
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
+
*/
lprintf(CTDL_DEBUG, "Removing context for session %d\n", con->cs_pid);
begin_critical_section(S_SESSION_TABLE);
- if (con->prev) con->prev->next = con->next; else ContextList = con->next;
- if (con->next) con->next->prev = con->prev;
- --num_sessions;
+ if (con->prev) {
+ con->prev->next = con->next;
+ }
+ else {
+ ContextList = con->next;
+ }
+ if (con->next) {
+ con->next->prev = con->prev;
+ }
+ --num_sessions;
end_critical_section(S_SESSION_TABLE);
/* Run any cleanup routines registered by loadable modules.
sigaddset(&set, SIGQUIT);
sigaddset(&set, SIGHUP);
sigaddset(&set, SIGTERM);
- sigaddset(&set, SIGSEGV);
- sigaddset(&set, SIGILL);
- sigaddset(&set, SIGBUS);
+ // sigaddset(&set, SIGSEGV); commented out because
+ // sigaddset(&set, SIGILL); we want core dumps
+ // sigaddset(&set, SIGBUS);
sigprocmask(SIG_UNBLOCK, &set, NULL);
+
signal(SIGINT, signal_cleanup);
signal(SIGQUIT, signal_cleanup);
signal(SIGHUP, signal_cleanup);
signal(SIGTERM, signal_cleanup);
- signal(SIGSEGV, signal_cleanup);
- signal(SIGILL, signal_cleanup);
- signal(SIGBUS, signal_cleanup);
+ // signal(SIGSEGV, signal_cleanup); commented out because
+ // signal(SIGILL, signal_cleanup); we want core dumps
+ // signal(SIGBUS, signal_cleanup);
/*
* Do not shut down the server on broken pipe signals, otherwise the
* sessions terminate.
*/
struct CitContext *CreateNewContext(void) {
- struct CitContext *me, *ptr;
+ struct CitContext *me;
+ static int next_pid = 0;
me = (struct CitContext *) malloc(sizeof(struct CitContext));
if (me == NULL) {
* the list.
*/
begin_critical_section(S_SESSION_TABLE);
-
- if (ContextList == NULL) {
- ContextList = me;
- me->cs_pid = 1;
- me->prev = NULL;
- me->next = NULL;
- }
-
- else if (ContextList->cs_pid > 1) {
- me->prev = NULL;
- me->next = ContextList;
- ContextList = me;
- me->cs_pid = 1;
- }
-
- else {
- for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
- if (ptr->next == NULL) {
- ptr->next = me;
- me->cs_pid = ptr->cs_pid + 1;
- me->prev = ptr;
- me->next = NULL;
- goto DONE;
- }
- else if (ptr->next->cs_pid > (ptr->cs_pid+1)) {
- me->prev = ptr;
- me->next = ptr->next;
- ptr->next->prev = me;
- ptr->next = me;
- me->cs_pid = ptr->cs_pid + 1;
- goto DONE;
- }
- }
+ me->cs_pid = ++next_pid;
+ me->prev = NULL;
+ me->next = ContextList;
+ ContextList = me;
+ if (me->next != NULL) {
+ me->next->prev = me;
}
-
-DONE: ++num_sessions;
+ ++num_sessions;
end_critical_section(S_SESSION_TABLE);
return(me);
}