Ticket #204: rwlock_deadlock_tight_loop.diff
File rwlock_deadlock_tight_loop.diff, 1.9 KB (added by , 6 years ago) |
---|
-
rwlock.c
91 91 } 92 92 93 93 lock->mutex = 0; 94 lock->cond = 0; 94 95 lock->num_active = 0; 95 96 //lock->exclusive_waiters = 0; 96 97 lock->num_shared_waiters = 0; … … 99 100 rc = pthread_mutex_init(&lock->mutex, NULL); 100 101 if (rc != 0) return rc; 101 102 103 rc = pthread_cond_init(&lock->cond, NULL); 104 if (rc != 0 ) { 105 pthread_mutex_destroy(&lock->mutex); 106 107 return rc; 108 } 109 102 110 //lock->exclusive_waiters = mksem(0); 103 111 //if (lock->exclusive_waiters < 0) return errno; 104 112 … … 114 122 { 115 123 pthread_rwlock_t lock = *_lock; 116 124 if (!lock) return EINVAL; 125 pthread_cond_destroy(&lock->cond); 117 126 pthread_mutex_destroy(&lock->mutex); 118 127 //if (close(lock->exclusive_waiters) < 0) return errno; 119 128 //if (close(lock->shared_waiters) < 0) return errno; … … 224 235 lock->num_active++; 225 236 break; 226 237 } 238 239 pthread_cond_wait(&lock->cond, &lock->mutex); 227 240 } 228 241 229 242 pthread_mutex_unlock(&lock->mutex); … … 273 286 //pthread_mutex_unlock(&lock->mutex); 274 287 //if (waitone(lock->exclusive_waiters, __abstime2timeout(abstime)) < 0) return errno; 275 288 //pthread_mutex_lock(&lock->mutex); 289 290 pthread_cond_wait(&lock->cond, &lock->mutex); 276 291 } 277 292 278 293 pthread_mutex_unlock(&lock->mutex); … … 326 341 } 327 342 } 328 343 344 pthread_cond_broadcast(&lock->cond); 329 345 pthread_mutex_unlock(&lock->mutex); 330 346 return 0; 331 347 } -
pthread_private.h
78 78 struct pthread_rwlock_t_ 79 79 { 80 80 pthread_mutex_t mutex; 81 pthread_cond_t cond; 81 82 //handle_t shared_waiters; 82 83 //handle_t exclusive_waiters; 83 84 int num_shared_waiters;