[6.0] 713d99976 The rest of previous commit.
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Jul 10 07:42:09 UTC 2019
commit 713d99976bed0f84ef0d78b59cdfd0b3bff24d72
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Jan 15 22:14:43 2019 +0000
The rest of previous commit.
diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c
index fb37ad574..1e56ab5f6 100644
--- a/bin/varnishd/cache/cache_acceptor.c
+++ b/bin/varnishd/cache/cache_acceptor.c
@@ -370,12 +370,7 @@ vca_make_session(struct worker *wrk, void *arg)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CAST_OBJ_NOTNULL(wa, arg, WRK_ACCEPT_MAGIC);
- if (VTCP_blocking(wa->acceptsock)) {
- closefd(&wa->acceptsock);
- wrk->stats->sess_drop++; // XXX Better counter ?
- WS_Release(wrk->aws, 0);
- return;
- }
+ VTCP_blocking(wa->acceptsock);
/* Turn accepted socket into a session */
AN(wrk->aws->r);
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 4141dfa21..2402b10b5 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -441,10 +441,7 @@ SES_Wait(struct sess *sp, const struct transport *xp)
* XXX: waiter_epoll prevents us from zeroing the struct because
* XXX: it keeps state across calls.
*/
- if (VTCP_nonblocking(sp->fd)) {
- SES_Delete(sp, SC_REM_CLOSE, NAN);
- return;
- }
+ VTCP_nonblocking(sp->fd);
/*
* put struct waited on the workspace
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index b339339f5..fad043e84 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -177,30 +177,6 @@ http1_req_fail(struct req *req, enum sess_close reason)
SES_Close(req->sp, reason);
}
-/*----------------------------------------------------------------------
- */
-
-static int
-http1_req_cleanup(struct sess *sp, struct worker *wrk, struct req *req)
-{
- AZ(wrk->aws->r);
- AZ(req->ws->r);
- Req_Cleanup(sp, wrk, req);
-
- if (sp->fd >= 0 && req->doclose != SC_NULL)
- SES_Close(sp, req->doclose);
-
- if (sp->fd < 0) {
- wrk->stats->sess_closed++;
- AZ(req->vcl);
- Req_Release(req);
- SES_Delete(sp, SC_NULL, NAN);
- return (1);
- }
-
- return (0);
-}
-
static int v_matchproto_(vtr_minimal_response_f)
http1_minimal_response(struct req *req, uint16_t status)
{
@@ -342,18 +318,9 @@ HTTP1_Session(struct worker *wrk, struct req *req)
* Whenever we come in from the acceptor or waiter, we need to set
* blocking mode. It would be simpler to do this in the acceptor
* or waiter, but we'd rather do the syscall in the worker thread.
- * On systems which return errors for ioctl, we close early
*/
- if (http1_getstate(sp) == H1NEWREQ && VTCP_blocking(sp->fd)) {
- AN(req->htc->ws->r);
- if (errno == ECONNRESET)
- SES_Close(sp, SC_REM_CLOSE);
- else
- SES_Close(sp, SC_TX_ERROR);
- WS_Release(req->htc->ws, 0);
- AN(http1_req_cleanup(sp, wrk, req));
- return;
- }
+ if (http1_getstate(sp) == H1NEWREQ)
+ VTCP_blocking(sp->fd);
req->transport = &HTTP1_transport;
@@ -455,8 +422,22 @@ HTTP1_Session(struct worker *wrk, struct req *req)
AZ(wrk->aws->r);
http1_setstate(sp, H1CLEANUP);
} else if (st == H1CLEANUP) {
- if (http1_req_cleanup(sp, wrk, req))
+
+ AZ(wrk->aws->r);
+ AZ(req->ws->r);
+
+ if (sp->fd >= 0 && req->doclose != SC_NULL)
+ SES_Close(sp, req->doclose);
+
+ if (sp->fd < 0) {
+ wrk->stats->sess_closed++;
+ Req_Cleanup(sp, wrk, req);
+ Req_Release(req);
+ SES_Delete(sp, SC_NULL, NAN);
return;
+ }
+
+ Req_Cleanup(sp, wrk, req);
HTC_RxInit(req->htc, req->ws);
if (req->htc->rxbuf_e != req->htc->rxbuf_b)
wrk->stats->sess_readahead++;
diff --git a/include/vtcp.h b/include/vtcp.h
index 29f83cb75..a5431aba6 100644
--- a/include/vtcp.h
+++ b/include/vtcp.h
@@ -45,8 +45,8 @@ void VTCP_hisname(int sock, char *abuf, unsigned alen,
char *pbuf, unsigned plen);
int VTCP_filter_http(int sock);
int VTCP_fastopen(int sock, int depth);
-int VTCP_blocking(int sock);
-int VTCP_nonblocking(int sock);
+void VTCP_blocking(int sock);
+void VTCP_nonblocking(int sock);
int VTCP_linger(int sock, int linger);
int VTCP_check_hup(int sock);
More information about the varnish-commit
mailing list