forked from Ocean/datum_gateway
Fix bugs in datum_queue_free
1. q->buffer[1] doesn't seem to be free()'d 2. q->buffer[0] is duplicated, you probably meant to zero out buffer[1] 3. shouldn't the unlocking order be reverse of locking order to prevent deadlocks?
This commit is contained in:
parent
62d92d04fb
commit
a384ff68a1
@ -65,14 +65,17 @@ int datum_queue_free(DATUM_QUEUE *q) {
|
||||
if (q->buffer[0]) {
|
||||
free(q->buffer[0]);
|
||||
}
|
||||
if (q->buffer[1]) {
|
||||
free(q->buffer[1]);
|
||||
}
|
||||
|
||||
q->initialized = false;
|
||||
q->buffer[0] = 0;
|
||||
q->buffer[0] = 0;
|
||||
q->buffer[1] = 0;
|
||||
|
||||
pthread_rwlock_unlock(&q->active_buffer_rwlock);
|
||||
pthread_rwlock_unlock(&q->buffer_rwlock[0]);
|
||||
pthread_rwlock_unlock(&q->buffer_rwlock[1]);
|
||||
pthread_rwlock_unlock(&q->buffer_rwlock[0]);
|
||||
pthread_rwlock_unlock(&q->active_buffer_rwlock);
|
||||
|
||||
pthread_rwlock_destroy(&q->active_buffer_rwlock);
|
||||
pthread_rwlock_destroy(&q->buffer_rwlock[0]);
|
||||
|
Loading…
Reference in New Issue
Block a user