summaryrefslogtreecommitdiffstats
path: root/crypto/err
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
committerGeoff Thorpe <geoff@openssl.org>2008-07-03 19:59:25 +0000
commit5f834ab123af6444b7cffe21849e434ad6479f8a (patch)
tree0cc48f4fc085f781606cb118b715781651487cb3 /crypto/err
parent8528128b2a740d34d3ae1d43c525d7e6ea6d7f37 (diff)
Revert my earlier CRYPTO_THREADID commit, I will commit a reworked
version some time soon.
Diffstat (limited to 'crypto/err')
-rw-r--r--crypto/err/err.c40
-rw-r--r--crypto/err/err.h7
-rw-r--r--crypto/err/err_prn.c4
3 files changed, 24 insertions, 27 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index b96e675618..f615cb4766 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -429,13 +429,13 @@ static ERR_STRING_DATA *int_err_del_item(ERR_STRING_DATA *d)
static unsigned long err_state_hash(const ERR_STATE *a)
{
- return CRYPTO_THREADID_hash(&a->tid);
+ return (a->pid + (unsigned long)a->pidptr) * 13;
}
static IMPLEMENT_LHASH_HASH_FN(err_state, ERR_STATE)
static int err_state_cmp(const ERR_STATE *a, const ERR_STATE *b)
{
- return CRYPTO_THREADID_cmp(&a->tid, &b->tid);
+ return (a->pid != b->pid) || (a->pidptr != b->pidptr);
}
static IMPLEMENT_LHASH_COMP_FN(err_state, ERR_STATE)
@@ -980,37 +980,40 @@ const char *ERR_reason_error_string(unsigned long e)
return((p == NULL)?NULL:p->string);
}
-void ERR_remove_thread_state(CRYPTO_THREADID *tid)
+void ERR_remove_state(unsigned long pid)
{
ERR_STATE tmp;
+ void *pidptr;
- if (tid)
- CRYPTO_THREADID_cpy(&tmp.tid, tid);
- else
- CRYPTO_THREADID_set(&tmp.tid);
err_fns_check();
+ 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);
}
-#ifndef OPENSSL_NO_DEPRECATED
-void ERR_remove_state(unsigned long pid)
- {
- ERR_remove_thread_state(NULL);
- }
-#endif
-
ERR_STATE *ERR_get_state(void)
{
static ERR_STATE fallback;
- CRYPTO_THREADID tid;
ERR_STATE *ret,tmp,*tmpp=NULL;
int i;
+ unsigned long pid;
+ void *pidptr;
err_fns_check();
- CRYPTO_THREADID_set(&tid);
- CRYPTO_THREADID_cpy(&tmp.tid, &tid);
+ 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 */
@@ -1018,7 +1021,8 @@ ERR_STATE *ERR_get_state(void)
{
ret=(ERR_STATE *)OPENSSL_malloc(sizeof(ERR_STATE));
if (ret == NULL) return(&fallback);
- CRYPTO_THREADID_cpy(&ret->tid, &tid);
+ ret->pid=pid;
+ ret->pidptr=pidptr;
ret->top=0;
ret->bottom=0;
for (i=0; i<ERR_NUM_ERRORS; i++)
diff --git a/crypto/err/err.h b/crypto/err/err.h
index 99340c8294..942f820a02 100644
--- a/crypto/err/err.h
+++ b/crypto/err/err.h
@@ -147,10 +147,8 @@ extern "C" {
#define ERR_NUM_ERRORS 16
typedef struct err_state_st
{
-#ifndef OPENSSL_NO_DEPRECATED
unsigned long pid;
-#endif
- CRYPTO_THREADID tid;
+ void *pidptr; /* new in OpenSSL 0.9.9 */
int err_flags[ERR_NUM_ERRORS];
unsigned long err_buffer[ERR_NUM_ERRORS];
char *err_data[ERR_NUM_ERRORS];
@@ -353,10 +351,7 @@ void ERR_load_ERR_strings(void);
void ERR_load_crypto_strings(void);
void ERR_free_strings(void);
-void ERR_remove_thread_state(CRYPTO_THREADID *tid);
-#ifndef OPENSSL_NO_DEPRECATED
void ERR_remove_state(unsigned long pid); /* if zero we look it up */
-#endif
ERR_STATE *ERR_get_state(void);
#ifndef OPENSSL_NO_LHASH
diff --git a/crypto/err/err_prn.c b/crypto/err/err_prn.c
index 6515d10c07..2224a901e5 100644
--- a/crypto/err/err_prn.c
+++ b/crypto/err/err_prn.c
@@ -72,10 +72,8 @@ void ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
const char *file,*data;
int line,flags;
unsigned long es;
- CRYPTO_THREADID tid;
- CRYPTO_THREADID_set(&tid);
- es = CRYPTO_THREADID_hash(&tid);
+ es=CRYPTO_thread_id();
while ((l=ERR_get_error_line_data(&file,&line,&data,&flags)) != 0)
{
ERR_error_string_n(l, buf, sizeof buf);