~ubuntu-branches/ubuntu/precise/crossroads/precise

« back to all changes in this revision

Viewing changes to xr/config/setbackend.cc

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ritter
  • Date: 2010-07-05 16:27:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100705162700-0g08tfav8ee9y51u
Tags: upstream-2.65
ImportĀ upstreamĀ versionĀ 2.65

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "config"
 
2
 
 
3
void Config::setbackend (string const &str, string const &host,
 
4
                         string const &url,
 
5
                         BackendCheck const &backend_check) {
 
6
    vector<string> parts = str2parts (str, ':');
 
7
    if (parts.size() < 2 || parts.size() > 4)
 
8
        throw Error("Bad back end specifier in '-b" + str +
 
9
                    "', expected: SERVER:PORT or SERVER:PORT:MAXCONNECTIONS"
 
10
                    " or SERVER:PORT:MAXCONNECTIONS:WEIGHT");
 
11
 
 
12
    BackendDef *bdp = 0;
 
13
    if (parts.size() == 2)
 
14
        bdp = new BackendDef(parts[0], parts[1]);
 
15
    else if (parts.size() == 3)
 
16
        bdp = new BackendDef(parts[0], parts[1], parts[2]);
 
17
    else if (parts.size() == 4)
 
18
        bdp = new BackendDef(parts[0], parts[1], parts[2], parts[3]);
 
19
    if (!bdp)
 
20
        throw Error("Memory fault in Config::setbackend");
 
21
    bdp->hostmatch(host);
 
22
    bdp->urlmatch(url);
 
23
    bdp->backendcheck(backend_check);
 
24
    blist.push_back (*bdp);
 
25
    delete bdp;
 
26
}