core: Scheduler::cancelEvent allows empty EventId

refs #1176

Change-Id: I80f10ed8026d64b46b4634ced9278f145f54c4a7
This commit is contained in:
Junxiao Shi committed 2014-01-30 22:40:48 -07:00
1 parent d3c792f95c
commit 234a532c0a
2 files changed
+11 -2

No files matched your search

+2 -2
View File
@@ -109,8 +109,8 @@ Scheduler::schedulePeriodicEvent(const time::Duration& after,
void
Scheduler::cancelEvent(const EventId& eventId)
{
if (!eventId->isValid())
return; // event already fired or cancelled
if (!static_cast<bool>(eventId) || !eventId->isValid())
return; // event empty, already fired, or cancelled
if (static_cast<EventQueue::iterator>(*eventId) != m_scheduledEvent) {
m_events.erase(*eventId);
+9
View File
@@ -80,6 +80,15 @@ BOOST_FIXTURE_TEST_CASE(Events, SchedulerFixture)
BOOST_CHECK_EQUAL(count4, 4);
}
BOOST_AUTO_TEST_CASE(CancelEmptyEvent)
{
boost::asio::io_service io;
Scheduler scheduler(io);
EventId i;
scheduler.cancelEvent(i);
}
BOOST_AUTO_TEST_SUITE_END()
} // namespace nfd