4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 \brief Daemon internal header */
31 #include "../boost/intrusive/iset.hpp"
32 #include "../boost/intrusive/iset_hook.hpp"
33 #include <boost/utility.hpp>
34 #include <boost/function.hpp>
35 #include "../../Scheduler/Scheduler.hh"
36 #include "../../Scheduler/SignalEvent.hh"
38 ///////////////////////////////ih.p////////////////////////////////////////
43 /** \brief Internal: Watch daemon process for successful startup */
49 DaemonWatcher(int pid, int coutpipe, int cerrpipe, int stdout, int stderr);
58 typedef boost::function<void ()> Callback;
60 Forwarder(int src, Callback cb);
63 void addTarget(int fd);
67 // This is awkward ... we'll need to erase an element from the target list given
68 // only the target object. This is best implement using an intrusive container.
69 // However, this makes memory-management explicit and we'll need to be careful.
70 typedef std::deque<char> Buffer;
72 typedef boost::intrusive::ilist_base_hook<TargetListTag> TargetListBase;
74 struct Target : public TargetListBase
76 Target(Forwarder & fwd, int fd);
79 Buffer::size_type offset;
80 scheduler::FdEvent writeevent;
82 typedef boost::intrusive::ilist<TargetListBase::value_traits<Target>,false> Targets;
87 void operator()(T * t) { delete t; }
90 void readData(int event);
91 void writeData(int event, Target * target);
97 scheduler::FdEvent readevent_;
100 void pipeClosed(int id);
101 void sigChld(siginfo_t const &);
112 scheduler::SignalEvent cldSignal_;
113 scheduler::TimerEvent timer_;
114 Forwarder coutForwarder_;
115 Forwarder cerrForwarder_;
120 ///////////////////////////////ih.e////////////////////////////////////////
127 // comment-column: 40
128 // c-file-style: "senf"
129 // indent-tabs-mode: nil
130 // ispell-local-dictionary: "american"
131 // compile-command: "scons -u test"