crossroads

Git mirror of https://crossroads.e-tunity.com/
git clone git://git.finwo.net/app/crossroads
Log | Files | Refs | LICENSE

execute.cc (981B)


      1 #include "wakeupthread"
      2 
      3 void Wakeupthread::execute() {
      4     Threadlist::desc("Wakeup thread");
      5     
      6     while (1) {
      7 	if (config.wakeupsec()) {
      8 	    for (unsigned i = 0; i < balancer.nbackends(); i++) {
      9 		if (! balancer.backend(i).live()) {
     10 		    Backend target(balancer.backend(i).backenddef());
     11 		    debugmsg("Wakeup thread: checking " <<
     12 			     target.description() << '\n');
     13 		    target.live(balancer.backend(i).live());
     14 		    try {
     15 			target.check();
     16 			if (target.live()) {
     17 			    msg ("Wakeup call: backend " << 
     18 				 target.description() <<
     19 				 " has awoken\n");
     20 			    balancer.backend(i).live(true);
     21 			} else
     22 			    balancer.backend(i).markconnecterror();
     23 		    } catch (Error &e) {
     24 			debugmsg("Exception in wakeup thread: " <<
     25 				 e.what() << '\n');
     26 		    } catch (...) {
     27 			debugmsg("Exception in wakeup thread\n");
     28 		    }
     29 		}
     30 	    }
     31 	    sleep (config.wakeupsec());
     32 	} else {
     33 	    debugmsg("Wakeup thread: no activity right now\n");
     34 	    sleep(30);
     35 	}
     36     }
     37 }
     38