]>
git.ipfire.org Git - thirdparty/pdns.git/blob - pdns/communicator.cc
2 PowerDNS Versatile Database Driven Nameserver
3 Copyright (C) 2002-2009 PowerDNS.COM BV
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License version 2 as
7 published by the Free Software Foundation;
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 #include "packetcache.hh"
21 #include "communicator.hh"
23 #include <boost/utility.hpp>
24 #include "dnsbackend.hh"
25 #include "ueberbackend.hh"
26 #include "packethandler.hh"
27 #include "resolver.hh"
30 #include "arguments.hh"
32 #include "packetcache.hh"
33 #include <boost/lexical_cast.hpp>
35 #include "namespaces.hh"
38 void CommunicatorClass::mainloop(void)
42 signal(SIGPIPE
,SIG_IGN
);
44 L
<<Logger::Error
<<"Master/slave communicator launching"<<endl
;
46 d_tickinterval
=::arg().asNum("slave-cycle-interval");
56 masterUpdateCheck(&P
);
57 tick
=doNotifications();
59 tick
= min (tick
, d_tickinterval
);
61 // L<<Logger::Error<<"tick = "<<tick<<", d_tickinterval = "<<d_tickinterval<<endl;
64 while(time(0) < next
) {
65 rc
=d_any_sem
.tryWait();
70 if(!d_suck_sem
.tryWait()) {
74 sr
=d_suckdomains
.front();
75 d_suckdomains
.pop_front();
77 suck(sr
.domain
,sr
.master
);
80 // this gets executed at least once every second
85 catch(AhuException
&ae
) {
86 L
<<Logger::Error
<<"Communicator thread died because of error: "<<ae
.reason
<<endl
;
90 catch(std::exception
&e
) {
91 L
<<Logger::Error
<<"Communicator thread died because of STL error: "<<e
.what()<<endl
;
96 L
<< Logger::Error
<< "Communicator caught unknown exception." << endl
;