Mailing List Archive

[master] 819ed3f29 Be explict about SC_NULL in initialization and tests.
commit 819ed3f299f8429544bb01c34a73d67d0ba50c65
Author: Poul-Henning Kamp <phk@FreeBSD.org>
Date: Tue Jan 4 14:34:03 2022 +0000

Be explict about SC_NULL in initialization and tests.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 132cd2f4e..b62ea248e 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -126,7 +126,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC);
AN(bp->vsc);

- if (! VRT_Healthy(ctx, dir, NULL)) {
+ if (!VRT_Healthy(ctx, dir, NULL)) {
VSLb(bo->vsl, SLT_FetchError,
"backend %s: unhealthy", VRT_BACKEND_string(dir));
bp->vsc->unhealthy++;
@@ -207,6 +207,7 @@ vbe_dir_getfd(VRT_CTX, struct worker *wrk, VCL_BACKEND dir, struct backend *bp,
INIT_OBJ(bo->htc, HTTP_CONN_MAGIC);
bo->htc->priv = pfd;
bo->htc->rfd = fdp;
+ bo->htc->doclose = SC_NULL;
FIND_TMO(first_byte_timeout,
bo->htc->first_byte_timeout, bo, bp);
FIND_TMO(between_bytes_timeout,
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index 99e9653a1..844e51b5a 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -153,15 +153,16 @@ Req_New(struct sess *sp)
INIT_OBJ(req->vfc, VFP_CTX_MAGIC);
p = (void*)PRNDUP(p + sizeof(*req->vfc));

- req->htc = (void*)p;
+ req->htc = (void*)p; // XXX: TWICE ?!
p = (void*)PRNDUP(p + sizeof(*req->htc));

req->vdc = (void*)p;
memset(req->vdc, 0, sizeof *req->vdc);
p = (void*)PRNDUP(p + sizeof(*req->vdc));

- req->htc = (void*)p;
+ req->htc = (void*)p; // XXX: TWICE ?!
INIT_OBJ(req->htc, HTTP_CONN_MAGIC);
+ req->htc->doclose = SC_NULL;
p = (void*)PRNDUP(p + sizeof(*req->htc));

req->top = (void*)p;
@@ -176,8 +177,8 @@ Req_New(struct sess *sp)
req->t_first = NAN;
req->t_prev = NAN;
req->t_req = NAN;
-
req->req_step = R_STP_TRANSPORT;
+ req->doclose = SC_NULL;

return (req);
}
@@ -289,6 +290,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
req->is_hit = 0;
req->req_step = R_STP_TRANSPORT;
req->vcf = NULL;
+ req->doclose = SC_NULL;
+ req->htc->doclose = SC_NULL;

if (WS_Overflowed(req->ws))
wrk->stats->ws_client_overflow++;
diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c
index ee4159005..e5bd6beeb 100644
--- a/bin/varnishd/cache/cache_req_body.c
+++ b/bin/varnishd/cache/cache_req_body.c
@@ -245,7 +245,7 @@ VRB_Ignore(struct req *req)

CHECK_OBJ_NOTNULL(req, REQ_MAGIC);

- if (req->doclose)
+ if (req->doclose != SC_NULL)
return (0);
if (req->req_body_status->avail > 0)
(void)VRB_Iterate(req->wrk, req->vsl, req,
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 86a74b0cb..9556ab722 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -363,7 +363,8 @@ cnt_synth(struct worker *wrk, struct req *req)
http_PrintfHeader(req->resp, "Content-Length: %zd",
VSB_len(synth_body));

- if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close"))
+ if (req->doclose == SC_NULL &&
+ http_HdrIs(req->resp, H_Connection, "close"))
req->doclose = SC_RESP_CLOSE;

/* Discard any lingering request body before delivery */
@@ -489,10 +490,11 @@ cnt_transmit(struct worker *wrk, struct req *req)

HSH_Cancel(wrk, req->objcore, boc);

- if (!req->doclose && (req->objcore->flags & OC_F_FAILED))
+ if (req->doclose == SC_NULL && (req->objcore->flags & OC_F_FAILED)) {
/* The object we delivered failed due to a streaming error.
* Fail the request. */
req->doclose = SC_TX_ERROR;
+ }

if (boc != NULL)
HSH_DerefBoc(wrk, req->objcore);
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 282f4d9a0..e90d1d48e 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -52,7 +52,7 @@ v1d_bytes(struct vdp_ctx *vdx, enum vdp_action act, void **priv,

if (len > 0)
wl = V1L_Write(vdx->wrk, ptr, len);
- if (act > VDP_NULL && V1L_Flush(vdx->wrk))
+ if (act > VDP_NULL && V1L_Flush(vdx->wrk) != SC_NULL)
return (-1);
if (len != wl)
return (-1);
@@ -96,9 +96,10 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
CHECK_OBJ_ORNULL(boc, BOC_MAGIC);
CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);

- if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) {
+ if (req->doclose == SC_NULL &&
+ http_HdrIs(req->resp, H_Connection, "close")) {
req->doclose = SC_RESP_CLOSE;
- } else if (req->doclose) {
+ } else if (req->doclose != SC_NULL) {
if (!http_HdrIs(req->resp, H_Connection, "close")) {
http_Unset(req->resp, H_Connection);
http_SetHeader(req->resp, "Connection: close");
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 57df205ce..fd491fc32 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -55,7 +55,7 @@ vbf_iter_req_body(void *priv, unsigned flush, const void *ptr, ssize_t l)

if (l > 0) {
(void)V1L_Write(bo->wrk, ptr, l);
- if (flush && V1L_Flush(bo->wrk))
+ if (flush && V1L_Flush(bo->wrk) != SC_NULL)
return (-1);
}
return (0);
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index d27d8485e..641f6e805 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -176,7 +176,7 @@ http1_req_panic(struct vsb *vsb, const struct req *req)
static void v_matchproto_(vtr_req_fail_f)
http1_req_fail(struct req *req, stream_close_t reason)
{
- assert(reason > 0);
+ assert(reason != SC_NULL);
assert(req->sp->fd != 0);
if (req->sp->fd > 0)
SES_Close(req->sp, reason);
@@ -210,7 +210,7 @@ http1_minimal_response(struct req *req, uint16_t status)
if (wl != l) {
if (wl < 0)
VTCP_Assert(1);
- if (!req->doclose)
+ if (req->doclose == SC_NULL)
req->doclose = SC_REM_CLOSE;
return (-1);
}
@@ -237,7 +237,7 @@ struct transport HTTP1_transport = {
static inline void
http1_abort(struct req *req, uint16_t status)
{
- AN(req->doclose);
+ assert(req->doclose != SC_NULL);
assert(status >= 400);
(void)http1_minimal_response(req, status);
}
@@ -358,7 +358,7 @@ HTTP1_Session(struct worker *wrk, struct req *req)
req->acct.req_hdrbytes +=
req->htc->rxbuf_e - req->htc->rxbuf_b;
if (i) {
- assert(req->doclose > 0);
+ assert(req->doclose != SC_NULL);
SES_Close(req->sp, req->doclose);
assert(!WS_IsReserved(req->ws));
assert(!WS_IsReserved(wrk->aws));
diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c
index 7274b446f..a73eb0b55 100644
--- a/bin/varnishd/http1/cache_http1_line.c
+++ b/bin/varnishd/http1/cache_http1_line.c
@@ -118,6 +118,7 @@ V1L_Open(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl,
v1l->wfd = fd;
v1l->deadline = deadline;
v1l->vsl = vsl;
+ v1l->werr = SC_NULL;
wrk->v1l = v1l;

WS_Release(ws, u * sizeof(struct iovec));
@@ -134,9 +135,7 @@ V1L_Close(struct worker *wrk, uint64_t *cnt)
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(cnt);
sc = V1L_Flush(wrk);
- v1l = wrk->v1l;
- wrk->v1l = NULL;
- CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC);
+ TAKE_OBJ_NOTNULL(v1l, &wrk->v1l, V1L_MAGIC);
*cnt = v1l->cnt;
ws = v1l->ws;
ws_snap = v1l->ws_snap;
@@ -241,7 +240,7 @@ V1L_Flush(const struct worker *wrk)
VSLb(v1l->vsl, SLT_Debug,
"Write error, retval = %zd, len = %zd, errno = %s",
i, v1l->liov, VAS_errtxt(errno));
- AZ(v1l->werr);
+ assert(v1l->werr == SC_NULL);
if (errno == EPIPE)
v1l->werr = SC_REM_CLOSE;
else
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index fc05f7779..c408acd65 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -1163,7 +1163,7 @@ h2_req_body(struct req *req)
void v_matchproto_(vtr_req_fail_f)
h2_req_fail(struct req *req, stream_close_t reason)
{
- assert(reason > 0);
+ assert(reason != SC_NULL);
assert(req->sp->fd != 0);
VSLb(req->vsl, SLT_Debug, "H2FAILREQ");
}
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit