diff options
author | Bodo Möller <bodo@openssl.org> | 2008-05-19 20:45:25 +0000 |
---|---|---|
committer | Bodo Möller <bodo@openssl.org> | 2008-05-19 20:45:25 +0000 |
commit | 4bd4afa34e4c67279edee29c93b03bd7ed144d88 (patch) | |
tree | 7a83925c7d3ae520007a4d2de775314d9b4132bf /crypto | |
parent | 148bb9515c7e1be16cc17e4b59e043c84a40af16 (diff) |
Change use of CRYPTO_THREADID so that we always use both the ulong and
ptr members.
(So if the id_callback is bogus, we still have &errno.)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/cryptlib.c | 17 | ||||
-rw-r--r-- | crypto/crypto.h | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/crypto/cryptlib.c b/crypto/cryptlib.c index 73bdfd8ce9..cb858d5519 100644 --- a/crypto/cryptlib.c +++ b/crypto/cryptlib.c @@ -434,29 +434,30 @@ void CRYPTO_set_idptr_callback(void *(*func)(void)) void CRYPTO_THREADID_set(CRYPTO_THREADID *id) { - memset(id, 0, sizeof(*id)); + if (id_callback) + id->ulong = id_callback(); + else + id->ulong = 0; + if (idptr_callback) id->ptr = idptr_callback(); - else if (id_callback) - id->ulong = id_callback(); else id->ptr = &errno; } int CRYPTO_THREADID_cmp(const CRYPTO_THREADID *id1, const CRYPTO_THREADID *id2) { + if (id1->ulong != id2->ulong) + return ((id1->ulong < id2->ulong) ? -1 : 1); if (id1->ptr != id2->ptr) return ((id1->ptr < id2->ptr) ? -1 : 1); - if (id1->ulong != id2->ulong) - return ((id1->ulong < id2->ulong ) ? -1 : 1); return 0; } unsigned long CRYPTO_THREADID_hash(const CRYPTO_THREADID *id) { - if (idptr_callback || !id_callback) - return (unsigned long)id->ptr; - return id->ulong; + /* will need further processing to arrive at a good hash (mem_dbg.c uses this) */ + return id->ulong + (unsigned long)id->ptr; } void CRYPTO_THREADID_cpy(CRYPTO_THREADID *dst, const CRYPTO_THREADID *src) diff --git a/crypto/crypto.h b/crypto/crypto.h index bb9b89c6a5..437ed63df1 100644 --- a/crypto/crypto.h +++ b/crypto/crypto.h @@ -307,8 +307,8 @@ DECLARE_STACK_OF(CRYPTO_EX_DATA_FUNCS) * apart when someone decides to extend this in some way. */ typedef struct crypto_threadid { - void *ptr; unsigned long ulong; + void *ptr; } CRYPTO_THREADID; /* Per class, we have a STACK of CRYPTO_EX_DATA_FUNCS for each CRYPTO_EX_DATA |