Commit 7d6566e7 authored by Geoff Simmons's avatar Geoff Simmons Committed by Dridi Boukelmoune

Set socket options correctly for the accepted socket.

Closes #2722
parent dd5ea4a2
...@@ -221,17 +221,16 @@ vca_tcp_opt_init(void) ...@@ -221,17 +221,16 @@ vca_tcp_opt_init(void)
} }
static void static void
vca_tcp_opt_test(const struct listen_sock *ls) vca_tcp_opt_test(const int sock, const unsigned uds)
{ {
int i, n, sock; int i, n;
struct tcp_opt *to; struct tcp_opt *to;
socklen_t l; socklen_t l;
void *ptr; void *ptr;
sock = ls->sock;
for (n = 0; n < n_tcp_opts; n++) { for (n = 0; n < n_tcp_opts; n++) {
to = &tcp_opts[n]; to = &tcp_opts[n];
if (to->iponly && ls->uds) if (to->iponly && uds)
continue; continue;
to->need = 1; to->need = 1;
ptr = calloc(1, to->sz); ptr = calloc(1, to->sz);
...@@ -247,15 +246,14 @@ vca_tcp_opt_test(const struct listen_sock *ls) ...@@ -247,15 +246,14 @@ vca_tcp_opt_test(const struct listen_sock *ls)
} }
static void static void
vca_tcp_opt_set(const struct listen_sock *ls, int force) vca_tcp_opt_set(const int sock, const unsigned uds, const int force)
{ {
int n, sock; int n;
struct tcp_opt *to; struct tcp_opt *to;
sock = ls->sock;
for (n = 0; n < n_tcp_opts; n++) { for (n = 0; n < n_tcp_opts; n++) {
to = &tcp_opts[n]; to = &tcp_opts[n];
if (to->iponly && ls->uds) if (to->iponly && uds)
continue; continue;
if (to->need || force) { if (to->need || force) {
VTCP_Assert(setsockopt(sock, VTCP_Assert(setsockopt(sock,
...@@ -426,10 +424,10 @@ vca_make_session(struct worker *wrk, void *arg) ...@@ -426,10 +424,10 @@ vca_make_session(struct worker *wrk, void *arg)
wrk->stats->sess_conn++; wrk->stats->sess_conn++;
if (need_test) { if (need_test) {
vca_tcp_opt_test(wa->acceptlsock); vca_tcp_opt_test(sp->fd, wa->acceptlsock->uds);
need_test = 0; need_test = 0;
} }
vca_tcp_opt_set(wa->acceptlsock, 0); vca_tcp_opt_set(sp->fd, wa->acceptlsock->uds, 0);
req = Req_New(wrk, sp); req = Req_New(wrk, sp);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
...@@ -607,7 +605,7 @@ vca_acct(void *arg) ...@@ -607,7 +605,7 @@ vca_acct(void *arg)
if (ls->sock == -2) if (ls->sock == -2)
continue; // VCA_Shutdown continue; // VCA_Shutdown
assert (ls->sock > 0); assert (ls->sock > 0);
vca_tcp_opt_set(ls, 1); vca_tcp_opt_set(ls->sock, ls->uds, 1);
} }
AZ(pthread_mutex_unlock(&shut_mtx)); AZ(pthread_mutex_unlock(&shut_mtx));
} }
...@@ -646,7 +644,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) ...@@ -646,7 +644,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
ls->endpoint, strerror(errno)); ls->endpoint, strerror(errno));
return; return;
} }
vca_tcp_opt_set(ls, 1); vca_tcp_opt_set(ls->sock, ls->uds, 1);
if (cache_param->accept_filter) { if (cache_param->accept_filter) {
int i; int i;
i = VTCP_filter_http(ls->sock); i = VTCP_filter_http(ls->sock);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment