Skip to content

Bug fix for segfault #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/common.c
Original file line number Diff line number Diff line change
@@ -388,13 +388,13 @@ void queue_free(queue_t *q) {
}

void queue_push(queue_t *q, int type, void *data) {
pthread_mutex_lock(&q->mutex);

queue_item_t *i = malloc(sizeof(queue_item_t));
i->type = type;
i->data = data;
i->next = NULL;

pthread_mutex_lock(&q->mutex);

if (q->last) {
q->last->next = i;
} else {
@@ -415,12 +415,12 @@ int queue_pop(queue_t *q, void **datap) {
q->first = i->next;
if (!q->first)
q->last = NULL;
pthread_mutex_unlock(&q->mutex);

*datap = i->data;
int type = i->type;
free(i);

pthread_mutex_unlock(&q->mutex);
return type;
}

2 changes: 1 addition & 1 deletion src/read.c
Original file line number Diff line number Diff line change
@@ -536,7 +536,7 @@ static void read_thread(void) {
debug("read: skip %llu", iter.block.number_in_file);
continue;
}
for ( ; w && w->end < uend; w = w->next) ;
for ( ; w && w->end <= uend; w = w->next) ;
Copy link

@xkszltl xkszltl Sep 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to have <= here together with the >= in the if condition above?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nvm that's start, I think this makes sense.

}
debug("read: want %llu", iter.block.number_in_file);