]> code.citadel.org Git - citadel.git/commitdiff
* More scheduler changes. Removed the rescan pipe again, and also
authorArt Cancro <ajc@citadel.org>
Wed, 16 Jun 2004 04:17:43 +0000 (04:17 +0000)
committerArt Cancro <ajc@citadel.org>
Wed, 16 Jun 2004 04:17:43 +0000 (04:17 +0000)
  removed the mutex wrapper around select().  In my initial testing I am
  getting reliable, fast service, but further testing is needed.

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

index 5898423d994b7f788dd0cd71aae8fe4bf6cda74e..689ba63123bd861d16175261a9821057d20bab35 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 621.16  2004/06/16 04:17:43  ajc
+ * More scheduler changes.  Removed the rescan pipe again, and also
+   removed the mutex wrapper around select().  In my initial testing I am
+   getting reliable, fast service, but further testing is needed.
+
  Revision 621.15  2004/06/16 03:13:02  ajc
  * Scheduler fix ... added the rescan pipe back in
 
@@ -5850,4 +5855,3 @@ 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 a8f072d37a6bf5c6c5b28991d6e9800c99688082..1e9ea667ff8ed263bf325953124e73436a6ee217 100644 (file)
@@ -214,7 +214,6 @@ enum {
        S_DATABASE,
        S_NETDB,
        S_SUPPMSGMAIN,
-       S_I_WANNA_SELECT,
        S_CONFIG,
        S_WORKER_LIST,
        S_HOUSEKEEPING,
index cee6c1fd583be5e5ddf9eaee6340088d3625877f..7d21eb0b24a17d6f9cfc97c1a159762e960fe9d4 100644 (file)
@@ -94,7 +94,6 @@ struct CitContext masterCC;
 time_t last_purge = 0;                         /* Last dead session purge */
 static int num_threads = 0;                    /* Current number of threads */
 int num_sessions = 0;                          /* Current number of sessions */
-static int rescan[2];                          /* The rescan pipe */
 
 pthread_t initial_thread;              /* tid for main() thread */
 
@@ -237,17 +236,6 @@ void init_sysdep(void) {
         * socket breaks.
         */
        signal(SIGPIPE, SIG_IGN);
-
-       /*
-        * Set up the rescan pipe.  When a session goes idle, it writes a
-        * single byte to this pipe to wake up the thread calling select(),
-        * which tells it to rescan the list of session sockets.
-        */
-       if (pipe(rescan) != 0) {
-               lprintf(CTDL_EMERG, "Cannot create rescan pipe: %s\n",
-                       strerror(errno));
-               abort();
-       }
 }
 
 
@@ -906,10 +894,9 @@ void *worker_thread(void *arg) {
 do_select:     force_purge = 0;
                bind_me = NULL;         /* Which session shall we handle? */
 
-               /* Initialize the fdset.  Start with the rescan pipe. */
+               /* Initialize the fdset. */
                FD_ZERO(&readfds);
-               FD_SET(rescan[0], &readfds);
-               highest = rescan[0] + 1;
+               highest = 0;
 
                begin_critical_section(S_SESSION_TABLE);
                for (ptr = ContextList; ptr != NULL; ptr = ptr->next) {
@@ -945,13 +932,7 @@ do_select: force_purge = 0;
                if (!time_to_die) {
                        tv.tv_sec = 1;          /* wake up every second if no input */
                        tv.tv_usec = 0;
-                       /*
-                        * Avoid the "thundering herd" problem by letting only
-                        * one thread select() at a time.
-                        */
-                       begin_critical_section(S_I_WANNA_SELECT);
                        retval = select(highest + 1, &readfds, NULL, NULL, &tv);
-                       end_critical_section(S_I_WANNA_SELECT);
                }
                else {
                        break;
@@ -1018,27 +999,15 @@ do_select:       force_purge = 0;
                                        serviceptr->h_greeting_function();
                                        become_session(NULL);
                                        con->state = CON_IDLE;
-
-                                       /* Wake up the currently blocking select() by
-                                        * writing a dummy byte to the rescan pipe.
-                                        */
-                                       write(rescan[1], &i, 1);
                                        goto do_select;
                                }
                        }
                }
 
                if (time_to_die) {
-                       end_critical_section(S_I_WANNA_SELECT);
                        break;
                }
 
-               /* If the rescan pipe went active, read a dummy byte from it */
-               if (FD_ISSET(rescan[0], &readfds)) {
-                       read(rescan[0], &i, 1);
-                       goto do_select;
-               }
-
                /* It must be a client socket.  Find a context that has data
                 * waiting on its socket *and* is in the CON_IDLE state.  Any
                 * active sockets other than our chosen one are marked as
@@ -1083,11 +1052,6 @@ SKIP_SELECT:
                        force_purge = CC->kill_me;
                        become_session(NULL);
                        bind_me->state = CON_IDLE;
-
-                       /* Wake up the currently blocking select() by writing
-                        * a dummy byte to the rescan pipe.
-                        */
-                       write(rescan[1], &i, 1);
                }
 
                dead_session_purge(force_purge);