From: g0dil Date: Tue, 3 Feb 2009 08:40:25 +0000 (+0000) Subject: Scheduler: Implement PollTimerSource X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=b76d83f9671e935cbd5f2c6873efae1f75d25dac;p=senf.git Scheduler: Implement PollTimerSource Utils/Daemon: Fix DuplicateEventRegistration bug git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1091 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/Scheduler/Scheduler.test.cc b/Scheduler/Scheduler.test.cc index c8dc0b4..8d6a53f 100644 --- a/Scheduler/Scheduler.test.cc +++ b/Scheduler/Scheduler.test.cc @@ -1,4 +1,3 @@ - // $Id$ // // Copyright (C) 2006 @@ -318,7 +317,7 @@ BOOST_AUTO_UNIT_TEST(testScheduler) BOOST_CHECK_NO_THROW( senf::scheduler::process() ); } - BOOST_CHECK_EQUAL( eventCount, 8u ); + BOOST_CHECK( eventCount >= 8u ); /////////////////////////////////////////////////////////////////////////// diff --git a/Scheduler/TimerSource.cc b/Scheduler/TimerSource.cc index 17d2de7..84048b0 100644 --- a/Scheduler/TimerSource.cc +++ b/Scheduler/TimerSource.cc @@ -27,6 +27,7 @@ //#include "TimerSource.ih" // Custom includes +#include "FdEvent.hh" //#include "TimerSource.mpp" #define prefix_ @@ -146,6 +147,27 @@ prefix_ void senf::scheduler::detail::POSIXTimerSource::reschedule() SENF_THROW_SYSTEM_EXCEPTION("timer_settime()"); } +/////////////////////////////////////////////////////////////////////////// +// senf::scheduler::detail::PollTimerSource + +prefix_ void senf::scheduler::detail::PollTimerSource::timeout(ClockService::clock_type timeout) +{ + ClockService::clock_type now (ClockService::now()); + int delay (ClockService::in_milliseconds(timeout-now)+1); + FileDispatcher::instance().timeout(delay<0?0:delay); +} + +prefix_ void senf::scheduler::detail::PollTimerSource::notimeout() +{ + FileDispatcher::instance().timeout(-1); +} + +prefix_ void senf::scheduler::detail::PollTimerSource::enable() +{} + +prefix_ void senf::scheduler::detail::PollTimerSource::disable() +{} + ///////////////////////////////cc.e//////////////////////////////////////// #undef prefix_ //#include "TimerSource.mpp" diff --git a/Scheduler/TimerSource.hh b/Scheduler/TimerSource.hh index f17c6fc..ae45048 100644 --- a/Scheduler/TimerSource.hh +++ b/Scheduler/TimerSource.hh @@ -86,7 +86,10 @@ namespace detail { { public: virtual void timeout(ClockService::clock_type timeout); - virtual void disableTimeout(); + virtual void notimeout(); + + virtual void enable(); + virtual void disable(); }; class TimerFDTimerSource @@ -94,7 +97,10 @@ namespace detail { { public: virtual void timeout(ClockService::clock_type timeout); - virtual void disableTimeout(); + virtual void notimeout(); + + virtual void enable(); + virtual void disable(); }; }}} diff --git a/Utils/Daemon/Daemon.cc b/Utils/Daemon/Daemon.cc index 6bd84ae..8cbf98f 100644 --- a/Utils/Daemon/Daemon.cc +++ b/Utils/Daemon/Daemon.cc @@ -132,8 +132,11 @@ prefix_ void senf::Daemon::openLog() << " Could not open \"" << stdoutLog_ << "\" for redirecting stdout."; stdout_ = fd; } - if (stderrLog_ == stdoutLog_) - stderr_ = fd; + if (stderrLog_ == stdoutLog_) { + stderr_ = ::dup(fd); + if (stderr_ < 0) + SENF_THROW_SYSTEM_EXCEPTION("::dup()"); + } else if (! stderrLog_.empty()) { fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666); if (fd < 0) @@ -307,6 +310,7 @@ senf::Daemon * senf::Daemon::instance_ (0); prefix_ void senf::Daemon::configure() { + // int i (not unsigned) since argc_ is int ... for (int i (1); i