Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Issue 1812533002: Fix race condition in EventTimerPosix (Closed)

Created:
4 years, 9 months ago by sprang_webrtc
Modified:
4 years, 9 months ago
Reviewers:
mflodman
CC:
webrtc-reviews_webrtc.org, henrika_webrtc, zhengzhonghou_agora.io, tterriberry_mozilla.com, fengyue_agora.io, peah-webrtc, mflodman
Base URL:
https://chromium.googlesource.com/external/webrtc.git@master
Target Ref:
refs/pending/heads/master
Project:
webrtc
Visibility:
Public.

Description

Fix race condition in EventTimerPosix The intended signalling from StartTimer() to Process() is that created_at_.tv_sec is set to 0, and timer_event_->Set() is then called in order to wake the process thread from timer_event_->Wait(). When this happens the process thread will return early and the run Process() again. This time it will pick up created_at_.tv_sec = 0 and run a new Wait() call with the desired end time. However if the process thread was NOT blocking on timer_event_->Wait() when timer_event_->Set() was called from StartTimer() it will mean that the first call to timer_event_->Wait() from Process(), AFTER the new time has been configured (count_ = 1), will return early. If the timer is not periodic it means that Set() will never be called, and any calls will Wait() will block until the time out. The solution is to always reset the event in timer_event_ on the first call to timerEvent_->Wait(), after a timer has started. Also some general cleanup. BUG=

Patch Set 1 #

Patch Set 2 : Reverted signature change #

Patch Set 3 : Added unit tests #

Patch Set 4 : Fixed race in test code #

Total comments: 2

Patch Set 5 : Formatting #

Patch Set 6 : Fixed potential deadlock #

Patch Set 7 : Avoid data race #

Patch Set 8 : Test case was still racy #

Total comments: 1
Unified diffs Side-by-side diffs Delta from patch set Stats (+260 lines, -30 lines) Patch
M webrtc/system_wrappers/source/event_timer_posix.h View 1 2 3 4 2 chunks +7 lines, -3 lines 0 comments Download
M webrtc/system_wrappers/source/event_timer_posix.cc View 1 2 3 4 5 6 10 chunks +54 lines, -27 lines 1 comment Download
A webrtc/system_wrappers/source/event_timer_posix_unittest.cc View 1 2 3 4 5 6 7 1 chunk +198 lines, -0 lines 0 comments Download
M webrtc/system_wrappers/system_wrappers_tests.gyp View 1 2 1 chunk +1 line, -0 lines 0 comments Download

Messages

Total messages: 24 (10 generated)
sprang_webrtc
4 years, 9 months ago (2016-03-17 10:32:29 UTC) #2
mflodman
Functionality LG, but how can we test / make sure this works well?
4 years, 9 months ago (2016-03-17 10:43:46 UTC) #3
sprang_webrtc
Added a few unit tests. The last one fails without the changes to EventTimerPosix.
4 years, 9 months ago (2016-03-17 16:13:13 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1812533002/40001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1812533002/40001
4 years, 9 months ago (2016-03-17 20:07:37 UTC) #7
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_rel on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_rel/builds/13598)
4 years, 9 months ago (2016-03-17 21:11:24 UTC) #9
mflodman
lgtm https://codereview.webrtc.org/1812533002/diff/60001/webrtc/system_wrappers/source/event_timer_posix.h File webrtc/system_wrappers/source/event_timer_posix.h (right): https://codereview.webrtc.org/1812533002/diff/60001/webrtc/system_wrappers/source/event_timer_posix.h#newcode60 webrtc/system_wrappers/source/event_timer_posix.h:60: friend class EventTimerPosixTest; This is normally put directly ...
4 years, 9 months ago (2016-03-18 09:19:24 UTC) #10
sprang_webrtc
https://codereview.webrtc.org/1812533002/diff/60001/webrtc/system_wrappers/source/event_timer_posix.h File webrtc/system_wrappers/source/event_timer_posix.h (right): https://codereview.webrtc.org/1812533002/diff/60001/webrtc/system_wrappers/source/event_timer_posix.h#newcode60 webrtc/system_wrappers/source/event_timer_posix.h:60: friend class EventTimerPosixTest; On 2016/03/18 09:19:23, mflodman wrote: > ...
4 years, 9 months ago (2016-03-18 09:24:28 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1812533002/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1812533002/80001
4 years, 9 months ago (2016-03-18 09:24:45 UTC) #14
commit-bot: I haz the power
Try jobs failed on following builders: linux_asan on tryserver.webrtc (JOB_FAILED, http://build.chromium.org/p/tryserver.webrtc/builders/linux_asan/builds/13330)
4 years, 9 months ago (2016-03-18 10:46:23 UTC) #16
sprang_webrtc
Fixed a few issues, you may want to take another pass...
4 years, 9 months ago (2016-03-21 11:03:32 UTC) #17
mflodman
LGTM https://codereview.webrtc.org/1812533002/diff/140001/webrtc/system_wrappers/source/event_timer_posix.cc File webrtc/system_wrappers/source/event_timer_posix.cc (right): https://codereview.webrtc.org/1812533002/diff/140001/webrtc/system_wrappers/source/event_timer_posix.cc#newcode192 webrtc/system_wrappers/source/event_timer_posix.cc:192: pthread_mutex_unlock(&mutex_); Ouch, I should have spotted this too...
4 years, 9 months ago (2016-03-22 07:47:02 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1812533002/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1812533002/140001
4 years, 9 months ago (2016-03-22 08:46:42 UTC) #20
commit-bot: I haz the power
Patchset 8 (id:??) landed as https://crrev.com/53cf3463c0c31039a750d49acf4755ed03043277 Cr-Commit-Position: refs/heads/master@{#12082}
4 years, 9 months ago (2016-03-22 08:51:52 UTC) #22
commit-bot: I haz the power
4 years, 9 months ago (2016-03-22 08:51:55 UTC) #24
Message was sent while issue was closed.
Committed patchset #8 (id:140001)

Powered by Google App Engine
This is Rietveld 408576698