mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 15:32:53 +01:00
thread: remove harmless race on status_ in End()
if a thread was still doing work when End() was called there'd be a race on worker->status_. in these cases, however, the specific value is meaningless as it would be >= OK and the thread would have been shut down properly, but we'll check 'impl_' instead to avoid any potential TSan/DRD reports. Change-Id: Ib93cbc226a099f07761f7bad765549dffb8054b1
This commit is contained in:
parent
5a1a7264fc
commit
46fd44c104
@ -269,18 +269,19 @@ static void Launch(WebPWorker* const worker) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void End(WebPWorker* const worker) {
|
static void End(WebPWorker* const worker) {
|
||||||
if (worker->status_ >= OK) {
|
|
||||||
#ifdef WEBP_USE_THREAD
|
#ifdef WEBP_USE_THREAD
|
||||||
|
if (worker->impl_ != NULL) {
|
||||||
ChangeState(worker, NOT_OK);
|
ChangeState(worker, NOT_OK);
|
||||||
pthread_join(worker->impl_->thread_, NULL);
|
pthread_join(worker->impl_->thread_, NULL);
|
||||||
pthread_mutex_destroy(&worker->impl_->mutex_);
|
pthread_mutex_destroy(&worker->impl_->mutex_);
|
||||||
pthread_cond_destroy(&worker->impl_->condition_);
|
pthread_cond_destroy(&worker->impl_->condition_);
|
||||||
#else
|
WebPSafeFree(worker->impl_);
|
||||||
worker->status_ = NOT_OK;
|
worker->impl_ = NULL;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
WebPSafeFree(worker->impl_);
|
#else
|
||||||
worker->impl_ = NULL;
|
worker->status_ = NOT_OK;
|
||||||
|
assert(worker->impl_ == NULL);
|
||||||
|
#endif
|
||||||
assert(worker->status_ == NOT_OK);
|
assert(worker->status_ == NOT_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user