Mailing List Archive

[master] ec95d0499 http2_send: Proper null checks for h2 errors
commit ec95d0499777830425c890221e86ee216ea27024
Author: Dridi Boukelmoune <dridi.boukelmoune@gmail.com>
Date: Mon Oct 23 11:36:57 2023 +0200

http2_send: Proper null checks for h2 errors

diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c
index be3d6fd67..ac07d542c 100644
--- a/bin/varnishd/http2/cache_http2_send.c
+++ b/bin/varnishd/http2/cache_http2_send.c
@@ -239,11 +239,11 @@ h2_errcheck(const struct h2_req *r2, const struct h2_sess *h2)
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);

- if (r2->error)
+ if (r2->error != NULL)
return (r2->error);
- if (h2->error && r2->stream > h2->goaway_last_stream)
+ if (h2->error != NULL && r2->stream > h2->goaway_last_stream)
return (h2->error);
- return (0);
+ return (NULL);
}

static int64_t
@@ -263,15 +263,17 @@ h2_do_window(struct worker *wrk, struct h2_req *r2,
if (r2->t_window <= 0 || h2->req0->t_window <= 0) {
r2->t_winupd = VTIM_real();
h2_send_rel_locked(h2, r2);
- while (r2->t_window <= 0 && h2_errcheck(r2, h2) == 0) {
+
+ while (r2->t_window <= 0 && h2_errcheck(r2, h2) == NULL) {
r2->cond = &wrk->cond;
(void)h2_cond_wait(r2->cond, h2, r2);
r2->cond = NULL;
}
- while (h2->req0->t_window <= 0 && h2_errcheck(r2, h2) == 0)
+
+ while (h2->req0->t_window <= 0 && h2_errcheck(r2, h2) == NULL)
(void)h2_cond_wait(h2->winupd_cond, h2, r2);

- if (h2_errcheck(r2, h2) == 0) {
+ if (h2_errcheck(r2, h2) == NULL) {
w = vmin_t(int64_t, h2_win_limit(r2, h2), wanted);
h2_win_charge(r2, h2, w);
assert (w > 0);
@@ -279,7 +281,7 @@ h2_do_window(struct worker *wrk, struct h2_req *r2,
h2_send_get_locked(wrk, h2, r2);
}

- if (w == 0 && h2_errcheck(r2, h2) == 0) {
+ if (w == 0 && h2_errcheck(r2, h2) == NULL) {
assert(r2->t_window > 0);
assert(h2->req0->t_window > 0);
w = h2_win_limit(r2, h2);
@@ -316,7 +318,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,

AN(H2_SEND_HELD(h2, r2));

- if (h2_errcheck(r2, h2))
+ if (h2_errcheck(r2, h2) != NULL)
return;

AN(ftyp);
@@ -341,7 +343,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,

if (ftyp->respect_window) {
tf = h2_do_window(wrk, r2, h2, (len > mfs) ? mfs : len);
- if (h2_errcheck(r2, h2))
+ if (h2_errcheck(r2, h2) != NULL)
return;
AN(H2_SEND_HELD(h2, r2));
} else
@@ -362,7 +364,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
if (ftyp->respect_window && p != ptr) {
tf = h2_do_window(wrk, r2, h2,
(len > mfs) ? mfs : len);
- if (h2_errcheck(r2, h2))
+ if (h2_errcheck(r2, h2) != NULL)
return;
AN(H2_SEND_HELD(h2, r2));
}
@@ -383,7 +385,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
ftyp = ftyp->continuation;
flags &= ftyp->flags;
final_flags &= ftyp->flags;
- } while (!h2->error && len > 0);
+ } while (h2->error == NULL && len > 0);
}
}

@@ -396,6 +398,7 @@ H2_Send_RST(struct worker *wrk, struct h2_sess *h2, const struct h2_req *r2,
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
AN(H2_SEND_HELD(h2, r2));
+ AN(h2e);

Lck_Lock(&h2->sess->mtx);
VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", stream, h2e->txt);
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit