From f94bbfebcbd7802d81102c084784115b70930e8e Mon Sep 17 00:00:00 2001 From: Umair Sadiq Date: Thu, 3 Dec 2015 21:38:07 -0800 Subject: [PATCH] fix for negative delay in runAfterDelay Summary: Currently, the tryRunAfterDelay implicitly converts a negative delay in int to unsigned int. With this change, the api makes it clear than only unsinged int is accepted as valid delay Reviewed By: yfeldblum Differential Revision: D2710034 fb-gh-sync-id: cb3c6b91bb86bbe07fa0e590b2ea871242d19745 --- folly/io/async/EventBase.cpp | 4 ++-- folly/io/async/EventBase.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/folly/io/async/EventBase.cpp b/folly/io/async/EventBase.cpp index 55691b19..15a37237 100644 --- a/folly/io/async/EventBase.cpp +++ b/folly/io/async/EventBase.cpp @@ -645,7 +645,7 @@ bool EventBase::runImmediatelyOrRunInEventBaseThreadAndWait(const Cob& fn) { } void EventBase::runAfterDelay(const Cob& cob, - int milliseconds, + uint32_t milliseconds, TimeoutManager::InternalEnum in) { if (!tryRunAfterDelay(cob, milliseconds, in)) { folly::throwSystemError( @@ -654,7 +654,7 @@ void EventBase::runAfterDelay(const Cob& cob, } bool EventBase::tryRunAfterDelay(const Cob& cob, - int milliseconds, + uint32_t milliseconds, TimeoutManager::InternalEnum in) { CobTimeout* timeout = new CobTimeout(this, cob, in); if (!timeout->scheduleTimeout(milliseconds)) { diff --git a/folly/io/async/EventBase.h b/folly/io/async/EventBase.h index 65b6a45f..3cdaf9a7 100644 --- a/folly/io/async/EventBase.h +++ b/folly/io/async/EventBase.h @@ -440,7 +440,7 @@ class EventBase : private boost::noncopyable, */ void runAfterDelay( const Cob& c, - int milliseconds, + uint32_t milliseconds, TimeoutManager::InternalEnum in = TimeoutManager::InternalEnum::NORMAL); /** @@ -451,7 +451,7 @@ class EventBase : private boost::noncopyable, * */ bool tryRunAfterDelay( const Cob& cob, - int milliseconds, + uint32_t milliseconds, TimeoutManager::InternalEnum in = TimeoutManager::InternalEnum::NORMAL); /** -- 2.34.1