Commit af9b7f66 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Polish VTCP usage in the acceptor setup

This adds the errno value to error logs for TCP fast open and accept
filters. For FreeBSD errno is cleared prior to calling setsockopt with
the hope that it will help understand if it's actually failing with an
undocumented ENOENT.

Speaking of documentation, the return value is either 0 or -1 for so
there's no point in logging that.
parent 02a9d3d4
......@@ -623,14 +623,11 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
VTAILQ_FOREACH(ls, &heritage.socks, list) {
CHECK_OBJ_NOTNULL(ls->transport, TRANSPORT_MAGIC);
assert (ls->sock > 0); // We know where stdin is
if (cache_param->tcp_fastopen) {
int i;
i = VTCP_fastopen(ls->sock, cache_param->listen_depth);
if (i)
VSL(SLT_Error, 0,
"Kernel TCP Fast Open: sock=%d, ret=%d %s",
ls->sock, i, vstrerror(errno));
}
if (cache_param->tcp_fastopen &&
VTCP_fastopen(ls->sock, cache_param->listen_depth))
VSL(SLT_Error, 0,
"Kernel TCP Fast Open: sock=%d, errno=%d %s",
ls->sock, errno, vstrerror(errno));
if (listen(ls->sock, cache_param->listen_depth)) {
VCLI_SetResult(cli, CLIS_CANT);
VCLI_Out(cli, "Listen failed on socket '%s': %s",
......@@ -638,14 +635,10 @@ ccf_start(struct cli *cli, const char * const *av, void *priv)
return;
}
vca_tcp_opt_set(ls->sock, ls->uds, 1);
if (cache_param->accept_filter) {
int i;
i = VTCP_filter_http(ls->sock);
if (i)
VSL(SLT_Error, 0,
"Kernel filtering: sock=%d, ret=%d %s",
ls->sock, i, vstrerror(errno));
}
if (cache_param->accept_filter && VTCP_filter_http(ls->sock))
VSL(SLT_Error, 0,
"Kernel filtering: sock=%d, errno=%d %s",
ls->sock, errno, vstrerror(errno));
}
need_test = 1;
......
......@@ -151,10 +151,11 @@ VTCP_filter_http(int sock)
int retval;
struct accept_filter_arg afa;
memset(&afa, 0, sizeof(afa));
strcpy(afa.af_name, "httpready");
memset(&afa, 0, sizeof afa);
bprintf(afa.af_name, "httpready");
errno = 0;
retval = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER,
&afa, sizeof afa );
&afa, sizeof afa);
return (retval);
}
......@@ -166,7 +167,7 @@ VTCP_filter_http(int sock)
int retval;
int defer = 1;
retval = setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT,
retval = setsockopt(sock, SOL_TCP, TCP_DEFER_ACCEPT,
&defer, sizeof defer);
return (retval);
}
......
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