crossroads

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

backendavailable.c (1045B)


      1 /*************************************************************************
      2  * This file is part of Crosroads 1.23, a load balancer and fail over
      3  * utility for TCP. Copyright (c) Karel Kubat, distributed under GPL.
      4  * Visit http://crossroads.e-tunity.com for information.
      5  *************************************************************************/
      6 #include "crossroads.h"
      7 
      8 int backend_available (int target) {
      9     /* Backend is available when:
     10      * (a) The state indicates availability;
     11      * (b) Either, there is no max to the active connections, or
     12      *     the # of connections is below the max.
     13      */
     14     if (servicereport->backendstate[target].avail == st_available &&
     15 	(activeservice->backend[target].maxconnections == 0 ||
     16 	 activeservice->backend[target].maxconnections >
     17 	 servicereport->backendstate[target].nclients)) {
     18 	msg ("Service %s: target nr %d is available", 
     19 	     activeservice->name, target);
     20 	return (1);
     21     }
     22 
     23     msg ("Service %s: target nr %d is unavailable", 
     24 	 activeservice->name, target);
     25     return (0);
     26 }