]> code.citadel.org Git - citadel.git/blobdiff - citadel/server/threads.c
This works much better. TSD maintained in-module instead of globally.
[citadel.git] / citadel / server / threads.c
index a745d2a4552fd0ecb840a7d63056b4321e96e9a8..f666c329b55fce56e40cc74df26e78f500fa40a0 100644 (file)
@@ -18,9 +18,7 @@
 
 int num_workers = 0;                           // Current number of worker threads
 int active_workers = 0;                                // Number of ACTIVE worker threads
-pthread_key_t ThreadKey;
 pthread_mutex_t Critters[MAX_SEMAPHORES];      // Things needing locking
-struct thread_tsd masterTSD;
 int server_shutting_down = 0;                  // set to nonzero during shutdown
 pthread_mutex_t ThreadCountMutex;
 
@@ -68,33 +66,6 @@ void end_critical_section(int which_one) {
 }
 
 
-// Return a pointer to our thread-specific (not session-specific) data.
-struct thread_tsd *MyThread(void) {
-        struct thread_tsd *c = (struct thread_tsd *) pthread_getspecific(ThreadKey) ;
-       if (!c) {
-               return &masterTSD;
-       }
-       return c;
-}
-
-
-// Called by CtdlThreadCreate()
-// We have to pass through here before starting our thread in order to create a set of data
-// that is thread-specific rather than session-specific.
-void *CTC_backend(void *supplied_start_routine) {
-       struct thread_tsd *mytsd;
-       void *(*start_routine)(void*) = supplied_start_routine;
-
-       mytsd = (struct thread_tsd *) malloc(sizeof(struct thread_tsd));
-       memset(mytsd, 0, sizeof(struct thread_tsd));
-       pthread_setspecific(ThreadKey, (const void *) mytsd);
-
-       start_routine(NULL);
-       // free(mytsd);
-       return(NULL);
-}
-
 // Function to create a thread.
 void CtdlThreadCreate(void *(*start_routine)(void*)) {
        pthread_t thread;
@@ -103,16 +74,11 @@ void CtdlThreadCreate(void *(*start_routine)(void*)) {
 
        ret = pthread_attr_init(&attr);
        ret = pthread_attr_setstacksize(&attr, THREADSTACKSIZE);
-       ret = pthread_create(&thread, &attr, CTC_backend, (void *)start_routine);
+       ret = pthread_create(&thread, &attr, start_routine, NULL);
        if (ret != 0) syslog(LOG_ERR, "pthread_create() : %m");
 }
 
 
-void InitializeMasterTSD(void) {
-       memset(&masterTSD, 0, sizeof(struct thread_tsd));
-}
-
-
 // Initialize the thread system
 void go_threading(void) {
        pthread_mutex_init(&ThreadCountMutex, NULL);