Skip to content

Commit

Permalink
Merge pull request #2 from j4cobgarby/fix-detach-segfault
Browse files Browse the repository at this point in the history
fix the possibility for pthread_detach(0)
  • Loading branch information
tidwall authored Apr 10, 2024
2 parents 8258e56 + ff9a69c commit ec26837
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion deps/worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ static void *worker_entry(void *arg) {
ts.tv_sec += 1;
pthread_cond_timedwait(&thread->cond, &thread->mu, &ts);
if (thread->len == 0) {
thread->th = 0;
if (!thread->end) {
pthread_detach(thread->th);
}
thread->th = 0;
thread->end = false;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion neco.c
Original file line number Diff line number Diff line change
Expand Up @@ -2739,10 +2739,10 @@ static void *worker_entry(void *arg) {
ts.tv_sec += 1;
pthread_cond_timedwait(&thread->cond, &thread->mu, &ts);
if (thread->len == 0) {
thread->th = 0;
if (!thread->end) {
pthread_detach(thread->th);
}
thread->th = 0;
thread->end = false;
break;
}
Expand Down

0 comments on commit ec26837

Please sign in to comment.