Commit 8c5118d1 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune Committed by Nils Goroll

Move redundant checks to an explicit H2_SEND_HELD()

It is unclear to me whether those calls belong under the h2 session
lock, but this patch doesn't change any behavior.
parent a0b8a734
...@@ -39,9 +39,12 @@ ...@@ -39,9 +39,12 @@
#include "vend.h" #include "vend.h"
#include "vtim.h" #include "vtim.h"
#define H2_SEND_HELD(h2, r2) (VTAILQ_FIRST(&(h2)->txqueue) == (r2))
static void static void
h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
{ {
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
...@@ -51,7 +54,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) ...@@ -51,7 +54,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
ASSERT_RXTHR(h2); ASSERT_RXTHR(h2);
r2->wrk = wrk; r2->wrk = wrk;
VTAILQ_INSERT_TAIL(&h2->txqueue, r2, tx_list); VTAILQ_INSERT_TAIL(&h2->txqueue, r2, tx_list);
while (VTAILQ_FIRST(&h2->txqueue) != r2) while (!H2_SEND_HELD(h2, r2))
AZ(Lck_CondWait(&wrk->cond, &h2->sess->mtx, 0)); AZ(Lck_CondWait(&wrk->cond, &h2->sess->mtx, 0));
r2->wrk = NULL; r2->wrk = NULL;
} }
...@@ -59,6 +62,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) ...@@ -59,6 +62,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
void void
H2_Send_Get(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) H2_Send_Get(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2)
{ {
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
...@@ -75,7 +79,7 @@ h2_send_rel_locked(struct h2_sess *h2, const struct h2_req *r2) ...@@ -75,7 +79,7 @@ h2_send_rel_locked(struct h2_sess *h2, const struct h2_req *r2)
CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC);
Lck_AssertHeld(&h2->sess->mtx); Lck_AssertHeld(&h2->sess->mtx);
assert(VTAILQ_FIRST(&h2->txqueue) == r2); AN(H2_SEND_HELD(h2, r2));
VTAILQ_REMOVE(&h2->txqueue, r2, tx_list); VTAILQ_REMOVE(&h2->txqueue, r2, tx_list);
r2 = VTAILQ_FIRST(&h2->txqueue); r2 = VTAILQ_FIRST(&h2->txqueue);
if (r2 != NULL) { if (r2 != NULL) {
...@@ -272,7 +276,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, ...@@ -272,7 +276,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
assert(len == 0 || ptr != NULL); assert(len == 0 || ptr != NULL);
AN(acct); AN(acct);
assert(VTAILQ_FIRST(&h2->txqueue) == r2); AN(H2_SEND_HELD(h2, r2));
if (h2_errcheck(r2, h2)) if (h2_errcheck(r2, h2))
return; return;
...@@ -301,7 +305,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, ...@@ -301,7 +305,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
tf = h2_do_window(wrk, r2, h2, (len > mfs) ? mfs : len); tf = h2_do_window(wrk, r2, h2, (len > mfs) ? mfs : len);
if (h2_errcheck(r2, h2)) if (h2_errcheck(r2, h2))
return; return;
assert(VTAILQ_FIRST(&h2->txqueue) == r2); AN(H2_SEND_HELD(h2, r2));
} else } else
tf = mfs; tf = mfs;
...@@ -322,7 +326,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags, ...@@ -322,7 +326,7 @@ h2_send(struct worker *wrk, struct h2_req *r2, h2_frame ftyp, uint8_t flags,
(len > mfs) ? mfs : len); (len > mfs) ? mfs : len);
if (h2_errcheck(r2, h2)) if (h2_errcheck(r2, h2))
return; return;
assert(VTAILQ_FIRST(&h2->txqueue) == r2); AN(H2_SEND_HELD(h2, r2));
} }
if (tf < len) { if (tf < len) {
H2_Send_Frame(wrk, h2, ftyp, H2_Send_Frame(wrk, h2, ftyp,
......
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