~ubuntu-branches/ubuntu/precise/haproxy/precise-proposed

« back to all changes in this revision

Viewing changes to src/backend.c

  • Committer: Bazaar Package Importer
  • Author(s): Christo Buschek
  • Date: 2011-03-11 12:41:59 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20110311124159-9foyp4juf1ilqipo
Tags: 1.4.13-1
* New maintainer upload (Closes: #615246)
* New upstream release
* Standards-version goes 3.9.1 (no change)
* Added patch bashism (Closes: #581109)
* Added a README.source file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
        struct http_msg *msg  = &txn->req;
245
245
        struct proxy    *px   = s->be;
246
246
        unsigned int     plen = px->url_param_len;
247
 
        unsigned long    len  = msg->hdr_content_len;
 
247
        unsigned long    len  = msg->body_len;
248
248
        const char      *params = req->data + msg->sov;
249
249
        const char      *p    = params;
250
250
 
545
545
                                /* URL Parameter hashing */
546
546
                                if (s->txn.req.msg_state < HTTP_MSG_BODY)
547
547
                                        break;
548
 
                                if (s->txn.meth == HTTP_METH_POST &&
549
 
                                    memchr(s->txn.req.sol + s->txn.req.sl.rq.u, '&',
550
 
                                           s->txn.req.sl.rq.u_l ) == NULL)
 
548
 
 
549
                                s->srv = get_server_ph(s->be,
 
550
                                                       s->txn.req.sol + s->txn.req.sl.rq.u,
 
551
                                                       s->txn.req.sl.rq.u_l);
 
552
 
 
553
                                if (!s->srv && s->txn.meth == HTTP_METH_POST)
551
554
                                        s->srv = get_server_ph_post(s);
552
 
                                else
553
 
                                        s->srv = get_server_ph(s->be,
554
 
                                                               s->txn.req.sol + s->txn.req.sl.rq.u,
555
 
                                                               s->txn.req.sl.rq.u_l);
556
555
                                break;
557
556
 
558
557
                        case BE_LB_HASH_HDR:
660
659
 
661
660
                s->srv_addr = s->srv->addr;
662
661
 
 
662
                if (!s->srv_addr.sin_addr.s_addr) {
 
663
                        /* if the server has no address, we use the same address
 
664
                         * the client asked, which is handy for remapping ports
 
665
                         * locally on multiple addresses at once.
 
666
                         */
 
667
                        if (!(s->be->options & PR_O_TRANSP) && !(s->flags & SN_FRT_ADDR_SET))
 
668
                                get_frt_addr(s);
 
669
 
 
670
                        s->srv_addr.sin_addr = ((struct sockaddr_in *)&s->frt_addr)->sin_addr;
 
671
                }
 
672
 
663
673
                /* if this server remaps proxied ports, we'll use
664
674
                 * the port the client connected to with an offset. */
665
675
                if (s->srv->state & SRV_MAPPORTS) {
1286
1296
        return 1;
1287
1297
}
1288
1298
 
 
1299
/* set test->i to the id of the backend */
 
1300
static int
 
1301
acl_fetch_be_id(struct proxy *px, struct session *l4, void *l7, int dir,
 
1302
                struct acl_expr *expr, struct acl_test *test) {
 
1303
 
 
1304
        test->flags = ACL_TEST_F_READ_ONLY;
 
1305
 
 
1306
        test->i = l4->be->uuid;
 
1307
 
 
1308
        return 1;
 
1309
}
 
1310
 
 
1311
/* set test->i to the id of the server */
 
1312
static int
 
1313
acl_fetch_srv_id(struct proxy *px, struct session *l4, void *l7, int dir,
 
1314
                struct acl_expr *expr, struct acl_test *test) {
 
1315
 
 
1316
        if (!l4->srv)
 
1317
                return 0;
 
1318
 
 
1319
        test->flags = ACL_TEST_F_READ_ONLY;
 
1320
 
 
1321
        test->i = l4->srv->puid;
 
1322
 
 
1323
        return 1;
 
1324
}
 
1325
 
1289
1326
/* set test->i to the number of connections per second reaching the frontend */
1290
1327
static int
1291
1328
acl_fetch_fe_sess_rate(struct proxy *px, struct session *l4, void *l7, int dir,
1429
1466
        { "queue", acl_parse_int, acl_fetch_queue_size, acl_match_int, ACL_USE_NOTHING },
1430
1467
        { "avg_queue", acl_parse_int, acl_fetch_avg_queue_size, acl_match_int, ACL_USE_NOTHING },
1431
1468
        { "srv_is_up",    acl_parse_nothing,   acl_fetch_srv_is_up,  acl_match_nothing, ACL_USE_NOTHING },
 
1469
        { "be_id",        acl_parse_int,     acl_fetch_be_id,          acl_match_int,     ACL_USE_NOTHING },
 
1470
        { "srv_id",       acl_parse_int,     acl_fetch_srv_id,         acl_match_int,     ACL_USE_NOTHING },
1432
1471
        { NULL, NULL, NULL, NULL },
1433
1472
}};
1434
1473