From c0167702d3db7acb76933db4a3deda281705518a Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Wed, 2 Oct 2013 13:11:15 +0000 Subject: [PATCH] Stop timer in ~EventWindows(). Running out of handles seems to have been an issue when adding another test target, this should solve it. BUG= R=mflodman@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2339004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4897 4adac7df-926f-26a2-2b94-8c16560cd09d --- webrtc/system_wrappers/source/event_win.cc | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/webrtc/system_wrappers/source/event_win.cc b/webrtc/system_wrappers/source/event_win.cc index d2032131d0..398e714a75 100644 --- a/webrtc/system_wrappers/source/event_win.cc +++ b/webrtc/system_wrappers/source/event_win.cc @@ -23,16 +23,17 @@ EventWindows::EventWindows() } EventWindows::~EventWindows() { + StopTimer(); CloseHandle(event_); } bool EventWindows::Set() { // Note: setting an event that is already set has no effect. - return SetEvent(event_) == 1 ? true : false; + return SetEvent(event_) == 1; } bool EventWindows::Reset() { - return ResetEvent(event_) == 1 ? true : false; + return ResetEvent(event_) == 1; } EventTypeWrapper EventWindows::Wait(unsigned long max_time) { @@ -52,6 +53,7 @@ bool EventWindows::StartTimer(bool periodic, unsigned long time) { timeKillEvent(timerID_); timerID_ = NULL; } + if (periodic) { timerID_ = timeSetEvent(time, 0, (LPTIMECALLBACK)HANDLE(event_), 0, TIME_PERIODIC | TIME_CALLBACK_EVENT_PULSE); @@ -60,15 +62,15 @@ bool EventWindows::StartTimer(bool periodic, unsigned long time) { TIME_ONESHOT | TIME_CALLBACK_EVENT_SET); } - if (timerID_ == NULL) { - return false; - } - return true; + return timerID_ != NULL; } bool EventWindows::StopTimer() { - timeKillEvent(timerID_); - timerID_ = NULL; + if (timerID_ != NULL) { + timeKillEvent(timerID_); + timerID_ = NULL; + } + return true; }