comparison src/c/urweb.c @ 2105:882556b3029d

Fix silly mistake from last commit; also switch away from rand() in openssl.c
author Adam Chlipala <adam@chlipala.net>
date Thu, 22 Jan 2015 09:46:20 -0500
parents 7755f00a4fc3
children 4895c41b2ec6 e10881cd92da
comparison
equal deleted inserted replaced
2104:7755f00a4fc3 2105:882556b3029d
169 169
170 static pthread_mutex_t rand_mutex = PTHREAD_MUTEX_INITIALIZER; 170 static pthread_mutex_t rand_mutex = PTHREAD_MUTEX_INITIALIZER;
171 171
172 static uw_Basis_int my_rand() { 172 static uw_Basis_int my_rand() {
173 pthread_mutex_lock(&rand_mutex); 173 pthread_mutex_lock(&rand_mutex);
174 int r = RAND_bytes((unsigned char *)&ret, sizeof ret); 174 int ret, r = RAND_bytes((unsigned char *)&ret, sizeof ret);
175 pthread_mutex_unlock(&rand_mutex); 175 pthread_mutex_unlock(&rand_mutex);
176 176
177 if (r) 177 if (r)
178 return abs(r); 178 return abs(ret);
179 else 179 else
180 return -1; 180 return -1;
181 } 181 }
182 182
183 static client *new_client() { 183 static client *new_client() {
360 360
361 extern void uw_global_custom(); 361 extern void uw_global_custom();
362 extern void uw_init_crypto(); 362 extern void uw_init_crypto();
363 363
364 void uw_global_init() { 364 void uw_global_init() {
365 srand(time(NULL) ^ getpid());
366
367 clients = malloc(0); 365 clients = malloc(0);
368 366
369 uw_global_custom(); 367 uw_global_custom();
370 uw_init_crypto(); 368 uw_init_crypto();
371 } 369 }