crossroads

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

backenddef1.cc (832B)


      1 #include "backenddef"
      2 
      3 unsigned BackendDef::min_wt;
      4 unsigned BackendDef::max_wt;
      5 bool BackendDef::minmax_wt_set = false;
      6 
      7 BackendDef::BackendDef (string server, string port,
      8 			string maxclients, string w) :
      9     srv(server), prt(-1), max(0), host_match(""), url_match(""),
     10     wt(1), backend_check() {
     11 
     12     if (sscanf (port.c_str(), "%d", &prt) < 1)
     13 	throw Error("Bad backend port specifier: '" + port +
     14 		    "' is not a number");
     15     if (maxclients.size() &&
     16 	sscanf (maxclients.c_str(), "%u", &max) < 1)
     17 	throw Error("Bad maximum connections specifier: '" +
     18 		    maxclients + "' is not a number");
     19 
     20     unsigned ww;
     21     if (sscanf(w.c_str(), "%u", &ww) < 1)
     22 	throw Error("Bad backend weight specifier: '" + w +
     23 		    "' is not a number");
     24     if (ww < 1)
     25 	throw Error("Weights less than 1 are not supported");
     26     weight(ww);
     27 }