Skip to content

Commit 8155add

Browse files
authored
Merge pull request #105 from usefulcat/master
Bug fix for segfault
2 parents d2131cc + 57d9add commit 8155add

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -388,13 +388,13 @@ void queue_free(queue_t *q) {
388388
}
389389

390390
void queue_push(queue_t *q, int type, void *data) {
391-
pthread_mutex_lock(&q->mutex);
392-
393391
queue_item_t *i = malloc(sizeof(queue_item_t));
394392
i->type = type;
395393
i->data = data;
396394
i->next = NULL;
397395

396+
pthread_mutex_lock(&q->mutex);
397+
398398
if (q->last) {
399399
q->last->next = i;
400400
} else {
@@ -415,12 +415,12 @@ int queue_pop(queue_t *q, void **datap) {
415415
q->first = i->next;
416416
if (!q->first)
417417
q->last = NULL;
418+
pthread_mutex_unlock(&q->mutex);
418419

419420
*datap = i->data;
420421
int type = i->type;
421422
free(i);
422423

423-
pthread_mutex_unlock(&q->mutex);
424424
return type;
425425
}
426426

src/read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ static void read_thread(void) {
536536
debug("read: skip %llu", iter.block.number_in_file);
537537
continue;
538538
}
539-
for ( ; w && w->end < uend; w = w->next) ;
539+
for ( ; w && w->end <= uend; w = w->next) ;
540540
}
541541
debug("read: want %llu", iter.block.number_in_file);
542542

0 commit comments

Comments
 (0)