diff --git a/src/frontend.c b/src/frontend.c index b7f4e194c..bb4383b2d 100644 --- a/src/frontend.c +++ b/src/frontend.c @@ -60,38 +60,6 @@ int frontend_accept(struct stream *s) int cfd = conn->t.sock.fd; - /* Adjust some socket options */ - if (l->addr.ss_family == AF_INET || l->addr.ss_family == AF_INET6) { - if (setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, - (char *) &one, sizeof(one)) == -1) - goto out_return; - - if (fe->options & PR_O_TCP_CLI_KA) - setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, - (char *) &one, sizeof(one)); - - if (fe->options & PR_O_TCP_NOLING) - fdtab[cfd].linger_risk = 1; - -#if defined(TCP_MAXSEG) - if (l->maxseg < 0) { - /* we just want to reduce the current MSS by that value */ - int mss; - socklen_t mss_len = sizeof(mss); - if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) { - mss += l->maxseg; /* remember, it's < 0 */ - setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss)); - } - } -#endif - } - - if (global.tune.client_sndbuf) - setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf)); - - if (global.tune.client_rcvbuf) - setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf)); - if (unlikely(fe->nb_req_cap > 0)) { if ((s->req_cap = pool_alloc2(fe->req_cap_pool)) == NULL) goto out_return; /* no memory */ diff --git a/src/session.c b/src/session.c index 6dcbadb4c..247e4927d 100644 --- a/src/session.c +++ b/src/session.c @@ -166,6 +166,35 @@ int session_accept_fd(struct listener *l, int cfd, struct sockaddr_storage *addr goto out_free_sess; } + /* Adjust some socket options */ + if (l->addr.ss_family == AF_INET || l->addr.ss_family == AF_INET6) { + setsockopt(cfd, IPPROTO_TCP, TCP_NODELAY, (char *) &one, sizeof(one)); + + if (p->options & PR_O_TCP_CLI_KA) + setsockopt(cfd, SOL_SOCKET, SO_KEEPALIVE, (char *) &one, sizeof(one)); + + if (p->options & PR_O_TCP_NOLING) + fdtab[cfd].linger_risk = 1; + +#if defined(TCP_MAXSEG) + if (l->maxseg < 0) { + /* we just want to reduce the current MSS by that value */ + int mss; + socklen_t mss_len = sizeof(mss); + if (getsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, &mss_len) == 0) { + mss += l->maxseg; /* remember, it's < 0 */ + setsockopt(cfd, IPPROTO_TCP, TCP_MAXSEG, &mss, sizeof(mss)); + } + } +#endif + } + + if (global.tune.client_sndbuf) + setsockopt(cfd, SOL_SOCKET, SO_SNDBUF, &global.tune.client_sndbuf, sizeof(global.tune.client_sndbuf)); + + if (global.tune.client_rcvbuf) + setsockopt(cfd, SOL_SOCKET, SO_RCVBUF, &global.tune.client_rcvbuf, sizeof(global.tune.client_rcvbuf)); + if (unlikely((t = task_new()) == NULL)) goto out_free_sess;