-
// $Id$
//
// Copyright (C) 2006
BOOST_CHECK_NO_THROW( senf::scheduler::process() );
}
- BOOST_CHECK_EQUAL( eventCount, 8u );
+ BOOST_CHECK( eventCount >= 8u );
///////////////////////////////////////////////////////////////////////////
//#include "TimerSource.ih"
// Custom includes
+#include "FdEvent.hh"
//#include "TimerSource.mpp"
#define prefix_
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"
{
public:
virtual void timeout(ClockService::clock_type timeout);
- virtual void disableTimeout();
+ virtual void notimeout();
+
+ virtual void enable();
+ virtual void disable();
};
class TimerFDTimerSource
{
public:
virtual void timeout(ClockService::clock_type timeout);
- virtual void disableTimeout();
+ virtual void notimeout();
+
+ virtual void enable();
+ virtual void disable();
};
}}}
<< " 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)
prefix_ void senf::Daemon::configure()
{
+ // int i (not unsigned) since argc_ is int ...
for (int i (1); i<argc_; ++i) {
if (argv_[i] == std::string("--no-daemon"))
daemonize(false);
void init() {
std::cout << "Running init()" << std::endl;
+ std::cerr << "(stderr)" << std::endl;
}
void run() {
std::cout << "Running run()" << std::endl;
- delay(1500);
+ delay(2000);
}
};
::kill(pid, SIGHUP);
}
- delay(1000);
+ delay(2000);
BOOST_CHECK( ! boost::filesystem::exists("testDaemon.pid") );
BOOST_CHECK( boost::filesystem::exists("testDaemon.log") );
BOOST_CHECK( boost::filesystem::exists("testDaemon.log.1") );
std::ifstream log ("testDaemon.log.1");
std::stringstream data;
data << log.rdbuf();
- BOOST_CHECK_EQUAL( data.str(), "Running init()\nRunning run()\n" );
+ BOOST_CHECK_EQUAL( data.str(), "Running init()\n(stderr)\nRunning run()\n" );
BOOST_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log") );
BOOST_CHECK_NO_THROW( boost::filesystem::remove("testDaemon.log.1") );
}
namesz = areas[i]['size']
nameix = i
areas[nameix]['name'] = field['name'][:int(areas[nameix]['size'] * charsPerBit)]
- if len(areas) == 2 and areas[0].get('bottom',True):
+ if field['name'] and len(areas) == 2 and areas[0].get('bottom',True):
if areas[0].get('name','') : ix = 1
else : ix = 0
if 6 <= int(areas[ix]['size'] * charsPerBit):