mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-02-20 12:46:56 +00:00
MEDIUM: frontend: move the fd-specific settings to session_accept_fd()
The frontend is generic and does not depend on a file descriptor, so applying some socket options to the incoming fd is not its role. Let's move the setsockopt() calls earlier in session_accept_fd() where others are done as well.
This commit is contained in:
parent
99eb0f13bc
commit
f9d1bc6d9a
@ -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 */
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user