* Altered the algorithm by which the doubly-linked session list is
authorArt Cancro <ajc@citadel.org>
Thu, 10 Mar 2005 03:11:07 +0000 (03:11 +0000)
committerArt Cancro <ajc@citadel.org>
Thu, 10 Mar 2005 03:11:07 +0000 (03:11 +0000)
  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.

citadel/ChangeLog
citadel/citserver.c
citadel/server.h
citadel/sysdep.c

index 4c983868411f6f23bf7a641d9de610c7e53874dc..f98281c10eca87e4ab9fabd73573c1ab7639d318 100644 (file)
@@ -1,4 +1,11 @@
  $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
 
@@ -6523,3 +6530,4 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
+
index ee4b5ffcfd08d8a6a187ebce001f6815d25d8c8c..8572418ba33e9d46705597eafbcd8d7f1cf5f613 100644 (file)
@@ -208,9 +208,16 @@ void RemoveContext (struct CitContext *con)
         */
        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.
index c59ef57eb9d50a34de36b93bd536ab7c20c897e5..05035324d874e7b36c82fd5ef256bd015c902e2a 100644 (file)
@@ -68,7 +68,7 @@ enum {
  * modification in a linked list.
  */
 struct CitContext {
-       struct CitContext *prev;
+       struct CitContext *prev;        /* Link to previous session in list */
        struct CitContext *next;        /* Link to next session in the list */
 
        struct ctdluser user;   /* Database record buffers */
index c4d255f790985e55337b763d8a811e87f12220f0..23acaa4bea0a71deee7c7135b56353f592b2913d 100644 (file)
@@ -211,17 +211,18 @@ void init_sysdep(void) {
        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
@@ -409,7 +410,8 @@ struct CitContext *MyContext(void) {
  * 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) {
@@ -430,42 +432,14 @@ struct CitContext *CreateNewContext(void) {
         * 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);
 }