deal with uninitialized thread's cred_handle -- has this code been ever tested?
authorAleš Křenek <ljocha@ics.muni.cz>
Wed, 12 Dec 2007 13:50:12 +0000 (13:50 +0000)
committerAleš Křenek <ljocha@ics.muni.cz>
Wed, 12 Dec 2007 13:50:12 +0000 (13:50 +0000)
org.glite.lb.logger/src/interlogd.c
org.glite.lb.logger/src/send_event.c

index 390d6c9..9991e08 100644 (file)
@@ -337,7 +337,7 @@ main (int argc, char **argv)
   /* initialize credential key and get credentials */
   /* IMPORTANT: no other threads may run at the time, the key initialization 
      has to be done exactly once */
-  if(pthread_key_create(&cred_handle_key, cred_handle_destroy) < 0)
+  if(pthread_key_create(&cred_handle_key, cred_handle_destroy) != 0)
          abort();
   if (CAcert_dir)
      setenv("X509_CERT_DIR", CAcert_dir, 1);
index 2bea9a2..3e9444d 100644 (file)
@@ -181,13 +181,14 @@ event_queue_connect(struct event_queue *eq)
     tv.tv_usec = 0;
     /* get thread specific pointer to credentials */
     local_cred_handle = pthread_getspecific(cred_handle_key);
+
     /* check if there are new credentials */
     if(pthread_mutex_lock(&cred_handle_lock) < 0)
            abort();
     if(local_cred_handle != cred_handle) {
            il_log(LOG_DEBUG, "    new credentials were found, discarding old\n");
            /* decrement counter in credentials, if it goes to zero, deallocate */
-           if(--(local_cred_handle->counter) == 0) {
+           if(local_cred_handle && --(local_cred_handle->counter) == 0) {
                    edg_wll_gss_release_cred(&local_cred_handle->creds, &gss_stat);
                    free(local_cred_handle);
                    il_log(LOG_DEBUG, "   freed old credentials, not used anymore\n");