History

pthread: Fix deadlock during thread initialization

Sometimes, if pthread_create() failed, then pthread_cond_wait() could accidentally be called in the worker threads after the uninit function had already called pthread_cond_broadcast(), leading to a deadlock. Don't call pthread_cond_wait() if c->done is set.

Derek Buitenhuis committed 13 years ago

Commit eb90a201 parent c9ef6b02 files · +4 −2Browse files

Showing the changes to libavfilter/pthread.c (1 of 2 files). Show all

Unified · Split

libavfilter/pthread.c+2−1
@@ -73,7 +73,8 @@ static void* attribute_align_arg worker(void *v) · 72 unmodified lines
73 if (c->current_job == nb_threads + c->nb_jobs)73 if (c->current_job == nb_threads + c->nb_jobs)
74 pthread_cond_signal(&c->last_job_cond);74 pthread_cond_signal(&c->last_job_cond);
75 75
76 pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);76 if (!c->done)
77 pthread_cond_wait(&c->current_job_cond, &c->current_job_lock);
77 our_job = self_id;78 our_job = self_id;
78 79
79 if (c->done) {80 if (c->done) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t