void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { char *rw_text,*operation_text; if (mode & CRYPTO_LOCK) operation_text="lock "; else if (mode & CRYPTO_UNLOCK) operation_text="unlock"; else operation_text="ERROR "; if (mode & CRYPTO_READ) rw_text="r"; else if (mode & CRYPTO_WRITE) rw_text="w"; else rw_text="ERROR"; fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_thread_id(), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (do_dynlock_cb) do_dynlock_cb(mode, type, file, line); } else if (locking_callback != NULL) locking_callback(mode,type,file,line); }
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, int line) { int ret = 0; if (add_lock_callback != NULL) { #ifdef LOCK_DEBUG int before= *pointer; #endif ret=add_lock_callback(pointer,amount,type,file,line); #ifdef LOCK_DEBUG { CRYPTO_THREADID id; CRYPTO_THREADID_current(&id); TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), before,amount,ret, CRYPTO_get_lock_name(type), file,line); } #endif } else { CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line); ret= *pointer+amount; #ifdef LOCK_DEBUG { CRYPTO_THREADID id; CRYPTO_THREADID_current(&id); TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), *pointer,amount,ret, CRYPTO_get_lock_name(type), file,line); } #endif *pointer=ret; CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line); } return(ret); }
static void threadLockCleanup(void) { int i; CRYPTO_set_locking_callback(NULL); fprintf(stderr,"cleanup\n"); for (i = 0; i < CRYPTO_num_locks(); i++) { pthread_mutex_destroy(&(lock_cs[i])); fprintf(stderr,"%8ld:%s\n",lock_count[i], CRYPTO_get_lock_name(i)); } OPENSSL_free(lock_cs); OPENSSL_free(lock_count); }
int CRYPTO_add_lock(int *pointer, int amount, int type, const char *file, int line) { int ret = 0; if (add_lock_callback != NULL) { #ifdef LOCK_DEBUG int before= *pointer; #endif ret=add_lock_callback(pointer,amount,type,file,line); #ifdef LOCK_DEBUG fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_thread_id(), before,amount,ret, CRYPTO_get_lock_name(type), file,line); #endif } else { CRYPTO_lock(CRYPTO_LOCK|CRYPTO_WRITE,type,file,line); ret= *pointer+amount; #ifdef LOCK_DEBUG fprintf(stderr,"ladd:%08lx:%2d+%2d->%2d %-18s %s:%d\n", CRYPTO_thread_id(), *pointer,amount,ret, CRYPTO_get_lock_name(type), file,line); #endif *pointer=ret; CRYPTO_lock(CRYPTO_UNLOCK|CRYPTO_WRITE,type,file,line); } return(ret); }
void thread_cleanup(void) { int i; CRYPTO_set_locking_callback(NULL); fprintf(stderr, "cleanup\n"); for (i = 0; i < CRYPTO_num_locks(); i++) { delete lock_cs[i]; fprintf(stderr, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); } OPENSSL_free(lock_cs); OPENSSL_free(lock_count); fprintf(stderr, "done cleanup\n"); }
void thread_setup(void) { int i; lock_cs = (BLocker **) OPENSSL_malloc(CRYPTO_num_locks() * sizeof(BLocker *)); lock_count = (long *)OPENSSL_malloc(CRYPTO_num_locks() * sizeof(long)); for (i = 0; i < CRYPTO_num_locks(); i++) { lock_count[i] = 0; lock_cs[i] = new BLocker(CRYPTO_get_lock_name(i)); } CRYPTO_set_id_callback((unsigned long (*)())beos_thread_id); CRYPTO_set_locking_callback(beos_locking_callback); }
void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { CRYPTO_THREADID id; char *rw_text,*operation_text; if (mode & CRYPTO_LOCK) operation_text="lock "; else if (mode & CRYPTO_UNLOCK) operation_text="unlock"; else operation_text="ERROR "; if (mode & CRYPTO_READ) rw_text="r"; else if (mode & CRYPTO_WRITE) rw_text="w"; else rw_text="ERROR"; CRYPTO_THREADID_current(&id); TINYCLR_SSL_FPRINTF(OPENSSL_TYPE__FILE_STDERR,"lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_THREADID_hash(&id), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } } else if (locking_callback != NULL) locking_callback(mode,type,file,line); }
void thread_cleanup(void) { int i; CRYPTO_set_locking_callback(NULL); fprintf(stdout, "thread_cleanup\n"); for (i = 0; i < CRYPTO_num_locks(); i++) { MPKMutexFree(lock_cs[i]); fprintf(stdout, "%8ld:%s\n", lock_count[i], CRYPTO_get_lock_name(i)); } OPENSSL_free(lock_cs); OPENSSL_free(lock_count); MPKSemaphoreFree(ThreadSem); fprintf(stdout, "done cleanup\n"); }
void CRYPTO_lock(int mode, int type, const char *file, int line) { #ifdef LOCK_DEBUG { char *rw_text,*operation_text; if (mode & CRYPTO_LOCK) operation_text="lock "; else if (mode & CRYPTO_UNLOCK) operation_text="unlock"; else operation_text="ERROR "; if (mode & CRYPTO_READ) rw_text="r"; else if (mode & CRYPTO_WRITE) rw_text="w"; else rw_text="ERROR"; fprintf(stderr,"lock:%08lx:(%s)%s %-18s %s:%d\n", CRYPTO_thread_id(), rw_text, operation_text, CRYPTO_get_lock_name(type), file, line); } #endif if (type < 0) { if (dynlock_lock_callback != NULL) { struct CRYPTO_dynlock_value *pointer = CRYPTO_get_dynlock_value(type); OPENSSL_assert(pointer != NULL); dynlock_lock_callback(mode, pointer, file, line); CRYPTO_destroy_dynlockid(type); } } else if (locking_callback != NULL) locking_callback(mode,type,file,line); }