/* 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);
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");