* Reworked shutdown sequence to avoid thread deadlock
authorArt Cancro <ajc@citadel.org>
Tue, 12 Oct 2004 02:48:12 +0000 (02:48 +0000)
committerArt Cancro <ajc@citadel.org>
Tue, 12 Oct 2004 02:48:12 +0000 (02:48 +0000)
citadel/ChangeLog
citadel/server_main.c

index 468ba8b5efec06f2d0076488fc76dde7487bb8fd..cb2686653292de50c7cac887463bda0ece0aef25 100644 (file)
@@ -1,4 +1,7 @@
  $Log$
+ Revision 626.10  2004/10/12 02:48:11  ajc
+ * Reworked shutdown sequence to avoid thread deadlock
+
  Revision 626.9  2004/10/12 02:17:49  ajc
  * Cleaned up some things that generated compiler warnings
  * crypto keys directory is now relative to the server's working directory,
@@ -6153,3 +6156,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 6020ebf541acd82c0956775ca4a2b177c1a56f0e..e770bc6f4e39a24813ae2f9e4d4b3832c78af9fa 100644 (file)
@@ -71,7 +71,6 @@ int main(int argc, char **argv)
        int a, i;                       /* General-purpose variables */
        struct passwd *pw;
        int drop_root_perms = 1;
-       struct worker_node *wnp;
        size_t size;
         
        /* specify default port name and trace file */
@@ -233,23 +232,7 @@ int main(int argc, char **argv)
        worker_thread(NULL);
 
        /* Server is exiting. Wait for workers to shutdown. */
-       lprintf(CTDL_INFO, "Waiting for worker threads to shut down\n");
-
-       begin_critical_section(S_WORKER_LIST);
-       while (worker_list != NULL) {
-               wnp = worker_list;
-               worker_list = wnp->next;
-
-               /* avoid deadlock with an exiting thread */
-               end_critical_section(S_WORKER_LIST);
-               if ((i = pthread_join(wnp->tid, NULL))) {
-                       lprintf(CTDL_CRIT, "pthread_join: %s\n", strerror(i));
-               }
-               free(wnp);
-               begin_critical_section(S_WORKER_LIST);
-       }
-       end_critical_section(S_WORKER_LIST);
-
+       lprintf(CTDL_INFO, "Server is shutting down.\n");
        master_cleanup();
        return(0);
 }