[master] ff6c1ce39 Revert "Turn enum h2_stream_e into a const struct which knows its own name."
Poul-Henning Kamp
phk at FreeBSD.org
Wed Oct 3 13:55:11 UTC 2018
commit ff6c1ce396c8e5da579fe62cf7f030e81cbbc8b3
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Oct 3 13:53:47 2018 +0000
Revert "Turn enum h2_stream_e into a const struct which knows its own name."
This reverts commit 4e7e349949d7305dd8d21539b128b0225f7357b7.
diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h
index 938f0d6a4..70e31d14e 100644
--- a/bin/varnishd/http2/cache_http2.h
+++ b/bin/varnishd/http2/cache_http2.h
@@ -104,13 +104,11 @@ struct h2_setting_s {
/**********************************************************************/
-struct h2_stream_s {
- const char *name;
- const char *desc;
-};
-
-#define H2_STREAM(u,s,d) extern const struct h2_stream_s H2_S_##u[1];
+enum h2_stream_e {
+ H2_STREAM__DUMMY = -1,
+#define H2_STREAM(U,s,d) H2_S_##U,
#include "tbl/h2_stream.h"
+};
#define H2_FRAME_FLAGS(l,u,v) extern const uint8_t H2FF_##u;
#include "tbl/h2_frames.h"
@@ -120,7 +118,7 @@ struct h2_req {
#define H2_REQ_MAGIC 0x03411584
uint32_t stream;
int scheduled;
- const struct h2_stream_s *state;
+ enum h2_stream_e state;
struct h2_sess *h2sess;
struct req *req;
double t_send;
diff --git a/bin/varnishd/http2/cache_http2_panic.c b/bin/varnishd/http2/cache_http2_panic.c
index 640cdbe53..9e80eb67b 100644
--- a/bin/varnishd/http2/cache_http2_panic.c
+++ b/bin/varnishd/http2/cache_http2_panic.c
@@ -50,11 +50,13 @@ h2_sess_panic(struct vsb *vsb, const struct sess *sp)
VTAILQ_FOREACH(r2, &h2->streams, list) {
PAN_CheckMagic(vsb, r2, H2_REQ_MAGIC);
VSB_printf(vsb, "0x%08x", r2->stream);
- if (r2->state == NULL)
- VSB_printf(vsb, " State NULL");
- else
- VSB_printf(vsb, " State %s (%s)",
- r2->state->name, r2->state->desc);
+ switch (r2->state) {
+#define H2_STREAM(U,sd,d) case H2_S_##U: VSB_printf(vsb, " %-6s", sd); break;
+#include <tbl/h2_stream.h>
+ default:
+ VSB_printf(vsb, " State %d", r2->state);
+ break;
+ }
VSB_printf(vsb, "\n");
}
VSB_indent(vsb, -2);
diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c
index 4d4034af5..070bf2cad 100644
--- a/bin/varnishd/http2/cache_http2_proto.c
+++ b/bin/varnishd/http2/cache_http2_proto.c
@@ -60,10 +60,6 @@ static const struct h2_error_s H2NN_ERROR[1] = {{
1
}};
-#define H2_STREAM(u,s,d) const struct h2_stream_s H2_S_##u[1] = {{ s, d }};
-#include "tbl/h2_stream.h"
-
-
enum h2frame {
#define H2_FRAME(l,u,t,f,...) H2F_##u = t,
#include "tbl/h2_frames.h"
@@ -217,8 +213,7 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2,
ASSERT_RXTHR(h2);
AN(h2e);
Lck_Lock(&h2->sess->mtx);
- VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%s",
- r2->stream, r2->state ? r2->state->name : "NULL");
+ VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state);
if (r2->error == NULL)
r2->error = h2e;
if (r2->scheduled) {
@@ -429,14 +424,18 @@ h2_win_adjust(const struct h2_sess *h2, uint32_t oldval, uint32_t newval)
CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC);
if (r2 == h2->req0)
continue; // rfc7540,l,2699,2699
- if (r2->state == H2_S_IDLE ||
- r2->state == H2_S_OPEN ||
- r2->state == H2_S_CLOS_REM) {
+ switch (r2->state) {
+ case H2_S_IDLE:
+ case H2_S_OPEN:
+ case H2_S_CLOS_REM:
/*
* We allow a window to go negative, as per
* rfc7540,l,2676,2680
*/
r2->t_window += (int64_t)newval - oldval;
+ break;
+ default:
+ break;
}
}
}
@@ -1003,28 +1002,38 @@ h2_sweep(struct worker *wrk, struct h2_sess *h2)
VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) {
if (r2 == h2->req0) {
assert (r2->state == H2_S_IDLE);
- } else if (r2->state == H2_S_CLOSED) {
+ continue;
+ }
+ switch (r2->state) {
+ case H2_S_CLOSED:
if (!r2->scheduled)
h2_del_req(wrk, r2);
- } else if (r2->state == H2_S_CLOS_REM) {
+ break;
+ case H2_S_CLOS_REM:
if (!r2->scheduled) {
h2_tx_rst(wrk, h2, h2->req0, r2->stream,
H2SE_REFUSED_STREAM);
h2_del_req(wrk, r2);
- } else if (h2_stream_tmo(h2, r2)) {
- tmo = 1;
+ continue;
}
- } else if (r2->state == H2_S_CLOS_LOC ||
- r2->state == H2_S_OPEN) {
- if (h2_stream_tmo(h2, r2))
+ /* FALLTHROUGH */
+ case H2_S_CLOS_LOC:
+ case H2_S_OPEN:
+ if (h2_stream_tmo(h2, r2)) {
tmo = 1;
- } else if(r2->state == H2_S_IDLE) {
+ continue;
+ }
+ break;
+ case H2_S_IDLE:
/* This stream was created from receiving a
* PRIORITY frame, and should not be counted
* as an active stream keeping the connection
* open. */
AZ(r2->scheduled);
nprio++;
+ break;
+ default:
+ break;
}
}
if (tmo)
diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c
index f38ef6bfd..ce114d390 100644
--- a/bin/varnishd/http2/cache_http2_session.c
+++ b/bin/varnishd/http2/cache_http2_session.c
@@ -420,8 +420,8 @@ h2_new_session(struct worker *wrk, void *arg)
break;
Lck_Lock(&h2->sess->mtx);
VTAILQ_FOREACH(r2, &h2->streams, list)
- VSLb(h2->vsl, SLT_Debug, "ST %u %s",
- r2->stream, r2->state ? r2->state->name : "NULL");
+ VSLb(h2->vsl, SLT_Debug, "ST %u %d",
+ r2->stream, r2->state);
(void)Lck_CondWait(h2->cond, &h2->sess->mtx, VTIM_real() + .1);
Lck_Unlock(&h2->sess->mtx);
}
More information about the varnish-commit
mailing list