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.)
This commit is contained in:
Bodo Möller 2008-05-19 20:45:25 +00:00
parent 148bb9515c
commit 4bd4afa34e
3 changed files with 16 additions and 10 deletions

View File

@ -4,7 +4,12 @@
Changes between 0.9.8g and 0.9.9 [xx XXX xxxx]
*) To support arbitrarily-typed thread IDs, deprecate the existing
*) Not all of this is true any longer.
Will have to be updated to reflect all subsequent changes to cryptlib.c.
--bodo
To support arbitrarily-typed thread IDs, deprecate the existing
type-specific APIs for a general purpose CRYPTO_THREADID
interface. Applications can choose the thread ID
callback type it wishes to register, as before;

View File

@ -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)

View File

@ -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