* [including the GNU Public Licence.]
*/
/* ====================================================================
- * Copyright (c) 1998-2001 The OpenSSL Project. All rights reserved.
+ * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
{ERR_PACK(ERR_LIB_PKCS12,0,0) ,"PKCS12 routines"},
{ERR_PACK(ERR_LIB_RAND,0,0) ,"random number generator"},
{ERR_PACK(ERR_LIB_DSO,0,0) ,"DSO support routines"},
+{ERR_PACK(ERR_LIB_TS,0,0) ,"time stamp routines"},
{ERR_PACK(ERR_LIB_ENGINE,0,0) ,"engine routines"},
{ERR_PACK(ERR_LIB_OCSP,0,0) ,"OCSP routines"},
{0,NULL},
{ERR_R_DSO_LIB ,"DSO lib"},
{ERR_R_ENGINE_LIB ,"ENGINE lib"},
{ERR_R_OCSP_LIB ,"OCSP lib"},
+{ERR_R_TS_LIB ,"TS lib"},
{ERR_R_NESTED_ASN1_ERROR ,"nested asn1 error"},
{ERR_R_BAD_ASN1_OBJECT_HEADER ,"bad asn1 object header"},
int i;
static int init = 1;
- if (!init) return;
-
+ CRYPTO_r_lock(CRYPTO_LOCK_ERR);
+ if (!init)
+ {
+ CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
+ return;
+ }
+
+ CRYPTO_r_unlock(CRYPTO_LOCK_ERR);
CRYPTO_w_lock(CRYPTO_LOCK_ERR);
+ if (!init)
+ {
+ CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
+ return;
+ }
for (i = 1; i <= NUM_SYS_STR_REASONS; i++)
{
/* static unsigned long pid_hash(ERR_STATE *a) */
static unsigned long pid_hash(const void *a_void)
{
- return(((const ERR_STATE *)a_void)->pid*13);
+ return((((const ERR_STATE *)a_void)->pid + (unsigned long)((const ERR_STATE *)a_void)->pidptr)*13);
}
/* static int pid_cmp(ERR_STATE *a, ERR_STATE *b) */
static int pid_cmp(const void *a_void, const void *b_void)
{
- return((int)((long)((const ERR_STATE *)a_void)->pid -
- (long)((const ERR_STATE *)b_void)->pid));
+ return (((const ERR_STATE *)a_void)->pid != ((const ERR_STATE *)b_void)->pid)
+ || (((const ERR_STATE *)a_void)->pidptr != ((const ERR_STATE *)b_void)->pidptr);
}
void ERR_remove_state(unsigned long pid)
{
ERR_STATE tmp;
+ void *pidptr;
err_fns_check();
- if (pid == 0)
- pid=(unsigned long)CRYPTO_thread_id();
+ if (pid != 0)
+ pidptr = &errno;
+ else
+ {
+ pid = CRYPTO_thread_id();
+ pidptr = CRYPTO_thread_idptr();
+ }
+
tmp.pid=pid;
+ tmp.pidptr=pidptr;
/* thread_del_item automatically destroys the LHASH if the number of
* items reaches zero. */
ERRFN(thread_del_item)(&tmp);
ERR_STATE *ret,tmp,*tmpp=NULL;
int i;
unsigned long pid;
+ void *pidptr;
err_fns_check();
- pid=(unsigned long)CRYPTO_thread_id();
- tmp.pid=pid;
+ pid = CRYPTO_thread_id();
+ pidptr = CRYPTO_thread_idptr();
+ tmp.pid = pid;
+ tmp.pidptr = pidptr;
ret=ERRFN(thread_get_item)(&tmp);
/* ret == the error state, if NULL, make a new one */
ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
if (ret == NULL) return(&fallback);
ret->pid=pid;
+ ret->pidptr=pidptr;
ret->top=0;
ret->bottom=0;
for (i=0; i<ERR_NUM_ERRORS; i++)