In TaskQueueWin fix race in canceling MutlimediaTimer
Bug: webrtc:11232 Change-Id: I371f0b78a572c94f2eefd8e0859eed88bce9e37e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/165762 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30232}
This commit is contained in:
parent
fae640003c
commit
fa73393574
@ -134,11 +134,15 @@ class MultimediaTimer {
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
::ResetEvent(event_);
|
||||
if (timer_id_) {
|
||||
::timeKillEvent(timer_id_);
|
||||
timer_id_ = 0;
|
||||
}
|
||||
// Now that timer is killed and not able to set the event, reset the event.
|
||||
// Doing it in opposite order is racy because event may be set between
|
||||
// event was reset and timer is killed leaving MultimediaTimer in surprising
|
||||
// state where both event is set and timer is canceled.
|
||||
::ResetEvent(event_);
|
||||
}
|
||||
|
||||
HANDLE* event_for_wait() { return &event_; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user