Ticket #114: lock.patch
File lock.patch, 1.2 KB (added by , 5 years ago) |
---|
-
src/main.c
128 128 server_info_t info; 129 129 struct in_addr localaddr; 130 130 131 #ifdef HAVE_TLS 132 #if OPENSSL_VERSION_NUMBER < 0x10100000L 133 static pthread_mutex_t *lock_cs; 134 void pthreads_locking_callback(int mode, int type, char *file, int line) 135 { 136 if(mode & CRYPTO_LOCK) 137 pthread_mutex_lock(&(lock_cs[type])); 138 else 139 pthread_mutex_unlock(&(lock_cs[type])); 140 } 141 142 unsigned long pthreads_thread_id(void) 143 { 144 return (unsigned long)pthread_self(); 145 } 146 #endif 147 #endif /* HAVE_TLS */ 148 131 149 /* 132 150 * The world starts here. 133 151 * - First initialize the run path and … … 157 175 #if OPENSSL_VERSION_NUMBER < 0x10100000L 158 176 SSL_library_init(); 159 177 SSL_load_error_strings(); 178 if((lock_cs = OPENSSL_malloc(CRYPTO_num_locks() * sizeof(pthread_mutex_t)))) 179 { 180 int i; 181 for (i = 0; i < CRYPTO_num_locks(); i++) 182 pthread_mutex_init(&(lock_cs[i]), NULL); 183 CRYPTO_set_id_callback((unsigned long (*)())pthreads_thread_id); 184 CRYPTO_set_locking_callback((void (*)())pthreads_locking_callback); 185 } 160 186 #endif 161 187 #endif /* HAVE_TLS */ 162 188