mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
fix hang on thread creation failure
with assertions enabled the code would abort in WebPWorkerChangeState with: Assertion `worker->status_ >= OK' without them the code would hang in the _cond_wait. this change makes WebPWorkerChangeState a no-op in this case. Change-Id: Iea855568bbdef2865ae61ab54473b3a7c230e91a
This commit is contained in:
parent
a31f843a9f
commit
473ae95324
@ -44,8 +44,10 @@ static void *WebPWorkerThreadLoop(void *ptr) { // thread loop
|
||||
// main thread state control
|
||||
static void WebPWorkerChangeState(WebPWorker* const worker,
|
||||
WebPWorkerStatus new_status) {
|
||||
// no-op when attempting to change state on a thread that didn't come up
|
||||
if (worker->status_ < OK) return;
|
||||
|
||||
pthread_mutex_lock(&worker->mutex_);
|
||||
assert(worker->status_ >= OK);
|
||||
// wait for the worker to finish
|
||||
while (worker->status_ != OK) {
|
||||
pthread_cond_wait(&worker->condition_, &worker->mutex_);
|
||||
@ -71,7 +73,7 @@ int WebPWorkerSync(WebPWorker* const worker) {
|
||||
#ifdef WEBP_USE_THREAD
|
||||
WebPWorkerChangeState(worker, OK);
|
||||
#endif
|
||||
assert(worker->status_ == OK);
|
||||
assert(worker->status_ <= OK);
|
||||
return !worker->had_error;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user