+ initial_thread = pthread_self();
+ worker_thread(NULL);
+
+ /* Server is exiting. Wait for workers to shutdown. */
+ lprintf(7, "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(1, "pthread_join: %s\n", strerror(i));
+ phree(wnp);
+ begin_critical_section(S_WORKER_LIST);
+ }
+ end_critical_section(S_WORKER_LIST);
+
+ master_cleanup();