start_routine(NULL);
+ free(mytsd);
return(NULL);
}
memset(&masterTSD, 0, sizeof(struct thread_tsd));
}
+extern void ShutDownEventQueues(void);
+int EventQShuttingDown = 0;
+int EVQShutDown = 0;
/*
* Initialize the thread system
*/
/* Second call to module init functions now that threading is up */
initialise_modules(1);
- CtdlThreadCreate(select_on_master);
-
/* Begin with one worker thread. We will expand the pool if necessary */
CtdlThreadCreate(worker_thread);
if ((active_workers == num_workers) && (num_workers < 256)) {
CtdlThreadCreate(worker_thread);
}
- sleep(1);
+ usleep(1000);
}
/* When we get to this point we are getting ready to shut down our Citadel server */
+ if (!EventQShuttingDown)
+ {
+ EventQShuttingDown = 1;
+ ShutDownEventQueues();
+ }
+ while (!EVQShutDown)
+ usleep(1000);
+
terminate_all_sessions(); /* close all client sockets */
CtdlShutdownServiceHooks(); /* close all listener sockets to prevent new connections */
syslog(LOG_DEBUG, "Waiting %d seconds for %d worker threads to exit",
countdown, num_workers
);
- sleep(1);
+ usleep(1000);
}
}