]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[MEDIUM] session: tell analysers what bit they were called for
authorWilly Tarreau <w@1wt.eu>
Tue, 7 Jul 2009 08:55:49 +0000 (10:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 7 Jul 2009 08:55:49 +0000 (10:55 +0200)
Some stream analysers might become generic enough to be called
for several bits. So we cannot have the analyser bit hard coded
into the analyser itself. Let's make the caller inform the callee.

include/proto/proto_http.h
include/proto/proto_tcp.h
src/proto_http.c
src/proto_tcp.c
src/proto_uxst.c
src/session.c

index 8620bf45bb5d013e1f87576cddaf4de107d49f11..d70603c83257fc1780ad0431fd0d2d67736de36b 100644 (file)
@@ -61,10 +61,10 @@ int event_accept(int fd);
 int process_cli(struct session *t);
 int process_srv_data(struct session *t);
 int process_srv_conn(struct session *t);
-int http_wait_for_request(struct session *s, struct buffer *req);
-int http_process_request(struct session *t, struct buffer *req);
-int http_process_tarpit(struct session *s, struct buffer *req);
-int http_process_request_body(struct session *s, struct buffer *req);
+int http_wait_for_request(struct session *s, struct buffer *req, int an_bit);
+int http_process_request(struct session *t, struct buffer *req, int an_bit);
+int http_process_tarpit(struct session *s, struct buffer *req, int an_bit);
+int http_process_request_body(struct session *s, struct buffer *req, int an_bit);
 int process_response(struct session *t);
 
 void produce_content(struct session *s, struct buffer *rep);
index 109bc09acb699dd894a13ca35c86cf2be8ba3384..61ec0bd0b3203a0b71aa285b8e00985a55fd10b6 100644 (file)
@@ -32,7 +32,7 @@ int tcpv4_bind_socket(int fd, int flags, struct sockaddr_in *local, struct socka
 void tcpv4_add_listener(struct listener *listener);
 void tcpv6_add_listener(struct listener *listener);
 int tcp_bind_listener(struct listener *listener, char *errmsg, int errlen);
-int tcp_inspect_request(struct session *s, struct buffer *req);
+int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit);
 
 #endif /* _PROTO_PROTO_TCP_H */
 
index 7d43770ff6e3d384e2c443eec20944b69cda9609..33e94664c6311960692ebd633b58a124e47f567d 100644 (file)
@@ -1509,7 +1509,7 @@ void http_msg_analyzer(struct buffer *buf, struct http_msg *msg, struct hdr_idx
  * when it has nothing left to do, and may remove any analyser when it wants to
  * abort.
  */
-int http_wait_for_request(struct session *s, struct buffer *req)
+int http_wait_for_request(struct session *s, struct buffer *req, int an_bit)
 {
        /*
         * We will parse the partial (or complete) lines.
@@ -1780,7 +1780,7 @@ int http_wait_for_request(struct session *s, struct buffer *req)
                                txn->req.cap, s->fe->req_cap);
 
        /* end of job, return OK */
-       req->analysers &= ~AN_REQ_WAIT_HTTP;
+       req->analysers &= ~an_bit;
        req->analyse_exp = TICK_ETERNITY;
        return 1;
 
@@ -1814,14 +1814,14 @@ int http_wait_for_request(struct session *s, struct buffer *req)
  * needs more data, encounters an error, or wants to immediately abort the
  * request. It relies on buffers flags, and updates s->req->analysers.
  */
-int http_process_request(struct session *s, struct buffer *req)
+int http_process_request(struct session *s, struct buffer *req, int an_bit)
 {
        int cur_idx;
        struct http_txn *txn = &s->txn;
        struct http_msg *msg = &txn->req;
        struct proxy *cur_proxy;
 
-       req->analysers &= ~AN_REQ_HTTP_HDR;
+       req->analysers &= ~an_bit;
        req->analyse_exp = TICK_ETERNITY;
 
        DPRINTF(stderr,"[%u] %s: session=%p b=%p, exp(r,w)=%u,%u bf=%08x bl=%d analysers=%02x\n",
@@ -2448,7 +2448,7 @@ int http_process_request(struct session *s, struct buffer *req)
  * returns zero, at the beginning because it prevents any other processing
  * from occurring, and at the end because it terminates the request.
  */
-int http_process_tarpit(struct session *s, struct buffer *req)
+int http_process_tarpit(struct session *s, struct buffer *req, int an_bit)
 {
        struct http_txn *txn = &s->txn;
 
@@ -2490,7 +2490,7 @@ int http_process_tarpit(struct session *s, struct buffer *req)
  * because it expects the request to be parsed. It returns zero if it needs to
  * read more data, or 1 once it has completed its analysis.
  */
-int http_process_request_body(struct session *s, struct buffer *req)
+int http_process_request_body(struct session *s, struct buffer *req, int an_bit)
 {
        struct http_msg *msg = &s->txn.req;
        unsigned long body = msg->sol[msg->eoh] == '\r' ? msg->eoh + 2 : msg->eoh + 1;
@@ -2551,7 +2551,7 @@ int http_process_request_body(struct session *s, struct buffer *req)
            tick_is_expired(req->analyse_exp, now_ms)) {
                /* The situation will not evolve, so let's give up on the analysis. */
                s->logs.tv_request = now;  /* update the request timer to reflect full request */
-               req->analysers &= ~AN_REQ_HTTP_BODY;
+               req->analysers &= ~an_bit;
                req->analyse_exp = TICK_ETERNITY;
                return 1;
        }
index 4a841866f65420113066d7c380ec1f4029b185e9..59f76c4a6c0f051228eae4a532e44a88ef5be78e 100644 (file)
@@ -373,7 +373,7 @@ void tcpv6_add_listener(struct listener *listener)
  * called after XXX bytes have been received (or transfered), and the min of
  * all's wishes will be used to ring back (unless a special condition occurs).
  */
-int tcp_inspect_request(struct session *s, struct buffer *req)
+int tcp_inspect_request(struct session *s, struct buffer *req, int an_bit)
 {
        struct tcp_rule *rule;
        int partial;
@@ -441,7 +441,7 @@ int tcp_inspect_request(struct session *s, struct buffer *req)
        /* if we get there, it means we have no rule which matches, or
         * we have an explicit accept, so we apply the default accept.
         */
-       req->analysers &= ~AN_REQ_INSPECT;
+       req->analysers &= ~an_bit;
        req->analyse_exp = TICK_ETERNITY;
        return 1;
 }
index 8af3d5a63956a9016c445459a2e7ba09504f64a1..a450217f36ecdc789a0aca46e12cb27ec52a5cfa 100644 (file)
@@ -640,7 +640,7 @@ int unix_sock_parse_request(struct session *s, char *line)
  * STATS_ST_CLOSE. It removes the AN_REQ_UNIX_STATS bit from req->analysers
  * once done. It always returns 0.
  */
-int uxst_req_analyser_stats(struct session *s, struct buffer *req)
+int uxst_req_analyser_stats(struct session *s, struct buffer *req, int an_bit)
 {
        char *line, *p;
 
@@ -694,7 +694,7 @@ int uxst_req_analyser_stats(struct session *s, struct buffer *req)
 
        case STATS_ST_CLOSE:
                /* end of dump */
-               s->req->analysers &= ~AN_REQ_UNIX_STATS;
+               s->req->analysers &= ~an_bit;
                s->ana_state = 0;
                break;
        }
@@ -793,7 +793,7 @@ struct task *uxst_process_session(struct task *t)
                         */
                        while (s->req->analysers) {
                                if (s->req->analysers & AN_REQ_UNIX_STATS)
-                                       if (!uxst_req_analyser_stats(s, s->req))
+                                       if (!uxst_req_analyser_stats(s, s->req, AN_REQ_UNIX_STATS))
                                                break;
 
                                /* Just make sure that nobody set a wrong flag causing an endless loop */
index 0f82639b8505d5d336abbaa3e087351e5e85e47c..1d223d080baf4bc1984656ea42d2d53f49f72799 100644 (file)
@@ -726,31 +726,31 @@ resync_stream_interface:
 
                                if (s->req->analysers & AN_REQ_INSPECT) {
                                        last_ana |= AN_REQ_INSPECT;
-                                       if (!tcp_inspect_request(s, s->req))
+                                       if (!tcp_inspect_request(s, s->req, AN_REQ_INSPECT))
                                                break;
                                }
 
                                if (s->req->analysers & AN_REQ_WAIT_HTTP) {
                                        last_ana |= AN_REQ_WAIT_HTTP;
-                                       if (!http_wait_for_request(s, s->req))
+                                       if (!http_wait_for_request(s, s->req, AN_REQ_WAIT_HTTP))
                                                break;
                                }
 
                                if (s->req->analysers & AN_REQ_HTTP_HDR) {
                                        last_ana |= AN_REQ_HTTP_HDR;
-                                       if (!http_process_request(s, s->req))
+                                       if (!http_process_request(s, s->req, AN_REQ_HTTP_HDR))
                                                break;
                                }
 
                                if (s->req->analysers & AN_REQ_HTTP_TARPIT) {
                                        last_ana |= AN_REQ_HTTP_TARPIT;
-                                       if (!http_process_tarpit(s, s->req))
+                                       if (!http_process_tarpit(s, s->req, AN_REQ_HTTP_TARPIT))
                                                break;
                                }
 
                                if (s->req->analysers & AN_REQ_HTTP_BODY) {
                                        last_ana |= AN_REQ_HTTP_BODY;
-                                       if (!http_process_request_body(s, s->req))
+                                       if (!http_process_request_body(s, s->req, AN_REQ_HTTP_BODY))
                                                break;
                                }
                        }