Hi I wrote a multithreaded program using openssl But with every connection it grows up about 8kb I think I freed all SSL* and SSL_CTX* I used
I used this functions to make my program threadsafe: Perhaps anyone can give me a hint if there is an error? With best regards Stephan void CRYPTO_thread_setup(void) { debugmsg("[CRYPTO_thread_setup] start"); int i; lock_cs = (pthread_mutex_t*)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)); lock_count = (long *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); for (i=0; i<CRYPTO_num_locks(); i++) { lock_count[i]=0; pthread_mutex_init(&(lock_cs[i]),NULL); } CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id); CRYPTO_set_locking_callback(pthreads_locking_callback); debugmsg("[CRYPTO_thread_setup] end"); } void thread_cleanup(void) { debugmsg("[thread_cleanup] start"); int i; CRYPTO_set_locking_callback(NULL); for (i=0; i<CRYPTO_num_locks(); i++) { pthread_mutex_destroy(&(lock_cs[i])); } OPENSSL_free(lock_cs); OPENSSL_free(lock_count); debugmsg("[thread_cleanup] end"); } void pthreads_locking_callback(int mode, int type, const char *file, int line) { //debugmsg("[pthreads_locking_callback] start"); #if 0 fprintf(stderr,"thread=%4d mode=%s lock=%s %s:%d\n", CRYPTO_thread_id(), (mode&CRYPTO_LOCK)?"l":"u", (type&CRYPTO_READ)?"r":"w",file,line); #endif #if 0 if (CRYPTO_LOCK_SSL_CERT == type) fprintf(stderr,"(t,m,f,l) %ld %d %s %d\n", CRYPTO_thread_id(), mode,file,line); #endif if (mode & CRYPTO_LOCK) { pthread_mutex_lock(&(lock_cs[type])); lock_count[type]++; } else { pthread_mutex_unlock(&(lock_cs[type])); } //debugmsg("[pthreads_locking_callback] end"); } unsigned long pthreads_thread_id(void) { unsigned long ret; ret=(unsigned long)pthread_self(); return(ret); } ______________________________________________________________________ OpenSSL Project http://www.openssl.org User Support Mailing List [EMAIL PROTECTED] Automated List Manager [EMAIL PROTECTED]