#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/format.hpp>
+#include <boost/bind.hpp>
#include <senf/Utils/Exception.hh>
#include <senf/Utils/membind.hh>
#include <senf/Utils/Backtrace.hh>
if (! stdoutLog_.empty()) {
fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
if (fd < 0)
- SENF_THROW_SYSTEM_EXCEPTION("")
- << " Could not open \"" << stdoutLog_ << "\" for redirecting stdout.";
+ SENF_THROW_SYSTEM_EXCEPTION(
+ " Could not open \"" + stdoutLog_ + "\" for redirecting stdout.");
stdout_ = fd;
}
if (! stderrLog_.empty()) {
else {
fd = ::open(stdoutLog_.c_str(), O_WRONLY | O_APPEND | O_CREAT, 0666);
if (fd < 0)
- SENF_THROW_SYSTEM_EXCEPTION("")
- << " Could not open \"" << stderrLog_ << "\" for redirecting stderr.";
+ SENF_THROW_SYSTEM_EXCEPTION(
+ " Could not open \"" + stderrLog_ + "\" for redirecting stderr.");
stderr_ = fd;
}
}
{
std::ofstream pidf (tempname.c_str());
if (! pidf)
- SENF_THROW_SYSTEM_EXCEPTION("")
- << " Could not open pidfile \"" << tempname << "\" for output.";
+ SENF_THROW_SYSTEM_EXCEPTION(" Could not open pidfile \"" + tempname + "\" for output.");
pidf << ::getpid() << std::endl;
if (! pidf)
- SENF_THROW_SYSTEM_EXCEPTION("")
- << " Could not write to pidfile \"" << tempname << "\".";
+ SENF_THROW_SYSTEM_EXCEPTION(" Could not write to pidfile \"" + tempname + "\".");
}
if (::link(tempname.c_str(), pidfile_.c_str()) < 0) {
if (errno != EEXIST)
- SENF_THROW_SYSTEM_EXCEPTION("") << linkErrorFormat % pidfile_ % tempname;
+ SENF_THROW_SYSTEM_EXCEPTION((linkErrorFormat % pidfile_ % tempname).str());
}
else {
struct ::stat s;
LIBC_CALL( ::unlink, (tempname.c_str() ));
if (::link(pidfile_.c_str(), tempname.c_str()) < 0) {
if (errno != ENOENT)
- SENF_THROW_SYSTEM_EXCEPTION("") << linkErrorFormat % tempname % pidfile_;
+ SENF_THROW_SYSTEM_EXCEPTION( (linkErrorFormat % tempname % pidfile_).str());
// Hmm ... the pidfile mysteriously disappeared ... try again.
continue;
}
//-/////////////////////////////////////////////////////////////////////////////////////////////////
// senf::detail::DaemonWatcher::Forwarder
+prefix_ senf::detail::DaemonWatcher::Forwarder::Target::Target(Forwarder & fwd, int fd_)
+ : fd (fd_), offset (0),
+ writeevent ("senf::detail::DaemonWatcher::Forwarder::Target::writeevent",
+ boost::bind(&Forwarder::writeData, &fwd, _1, this),
+ fd, scheduler::FdEvent::EV_WRITE, false)
+{}
+
prefix_ senf::detail::DaemonWatcher::Forwarder::Forwarder(int src, Callback cb)
: src_(src), cb_(cb),
readevent_("senf::detail::DaemonWatcher::Forwarder::readevent", senf::membind(&Forwarder::readData, this),