On Tue, Jun 20, 2006 at 07:03:49PM +0200, Kurt Roeckx wrote: >> Applications are also expected to provide a thread ID callback by >> calling CRYPTO_set_id_callback(), although the failure to do so should >> not be a problem on Linux where different threads run with different >> PIDs, since OpenSSL uses the PID as a default for the thread ID.
> I believe this is the only "LinuxThreads" implementation that > you're talking about. Since kernel 2.6 there is also support for > the Native POSIX Thread Library (NPTL). Afaik, that doesn't > change PID for each process anymore. I guess in that case one > must use pthread_self(), which returns a pthread_t. Yes, true. Sorry for the incomplete and incorrect description. >> (OpenSSL requires the thread ID that is an unsigned long. Not all >> systems may provide this, but in practice, you can work around this >> problem by casting a pointer of any per-thread object in shared memory >> space into an unsigned long; e.g., do foo=malloc(1); and then use >> (unsigned long)(void *)foo as the thread ID. You might want to add >> "assert(sizeof(void *) <= sizeof(long));" to the program if you use >> this approach.) > This would a problem on platforms like windows x64 which are > LLP64, where a long is still 32 bit and a pointer is 64 bit. > Fortuantly, we don't need that on windows. OK, I have implemented something new for OpenSSL 0.9.9-dev (this will become available in openssl-SNAP-20060624.tar.gz at ftp://ftp.openssl.org/snapshot/ in about 12 hours, and of course in later 0.9.9-dev snapshots): In addition to void CRYPTO_set_id_callback(unsigned long (*func)(void)); there will be void CRYPTO_set_idptr_callback(void *(*func)(void)); Same thing, just here the type of the ID is void * rather than unsigned long. Thus the malloc() trick will work. OpenSSL compares both IDs and believes that it is in a previous thread only if both values agree with what they previously were. The default value I have chosen for the pointer-type thread ID (if an application does not provide a callback) is &errno. For most, if not all, platforms, this default might end all worries about CRYPTO_set_id_callback(). ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager [EMAIL PROTECTED]