mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-31 10:31:46 +00:00
[MINOR] pre-set analyser flags on the listener at registration time
In order to achieve more generic accept() code, we can set the request analysers at the listener registration time. It's better than doing it during accept(), and allows more code reuse.
This commit is contained in:
parent
70cb633e2c
commit
3bc13774e1
@ -88,6 +88,7 @@ struct listener {
|
||||
void (*handler)(struct task *t, int *next); /* protocol handler */
|
||||
int *timeout; /* pointer to client-side timeout */
|
||||
void *private; /* any private data which may be used by accept() */
|
||||
unsigned int analysers; /* bitmap of required protocol analysers */
|
||||
union { /* protocol-dependant access restrictions */
|
||||
struct { /* UNIX socket permissions */
|
||||
uid_t uid; /* -1 to leave unchanged */
|
||||
|
@ -46,6 +46,7 @@
|
||||
#include <proto/proto_http.h>
|
||||
#include <proto/proxy.h>
|
||||
#include <proto/server.h>
|
||||
#include <proto/session.h>
|
||||
#include <proto/task.h>
|
||||
|
||||
|
||||
@ -3218,6 +3219,13 @@ int readcfgfile(const char *file)
|
||||
listener->timeout = &curproxy->timeout.client;
|
||||
listener->accept = event_accept;
|
||||
listener->private = curproxy;
|
||||
listener->handler = process_session;
|
||||
|
||||
if (curproxy->mode == PR_MODE_HTTP)
|
||||
listener->analysers |= AN_REQ_HTTP_HDR;
|
||||
|
||||
if (curproxy->tcp_req.inspect_delay)
|
||||
listener->analysers |= AN_REQ_INSPECT;
|
||||
|
||||
listener = listener->next;
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ int event_accept(int fd) {
|
||||
setsockopt(cfd, SOL_SOCKET, SO_LINGER, (struct linger *) &nolinger, sizeof(struct linger));
|
||||
|
||||
task_init(t);
|
||||
t->process = process_session;
|
||||
t->process = l->handler;
|
||||
t->context = s;
|
||||
|
||||
s->task = t;
|
||||
@ -366,11 +366,8 @@ int event_accept(int fd) {
|
||||
if (p->mode == PR_MODE_HTTP) /* reserve some space for header rewriting */
|
||||
s->req->rlim -= MAXREWRITE;
|
||||
|
||||
if (s->fe->tcp_req.inspect_delay)
|
||||
s->req->analysers |= AN_REQ_INSPECT;
|
||||
|
||||
if (p->mode == PR_MODE_HTTP)
|
||||
s->req->analysers |= AN_REQ_HTTP_HDR;
|
||||
/* activate default analysers enabled for this listener */
|
||||
s->req->analysers = l->analysers;
|
||||
|
||||
if (!s->req->analysers)
|
||||
buffer_write_ena(s->req); /* don't wait to establish connection */
|
||||
|
Loading…
Reference in New Issue
Block a user