Permalink
Browse files

More compact H2 error names

  • Loading branch information...
1 parent a62435b commit 7144af0e8fa2a5c354b7cd79baf70b8bf5e333d6 @bsdphk bsdphk committed Feb 17, 2017
Showing with 22 additions and 22 deletions.
  1. +2 −2 bin/varnishd/http2/cache_http2.h
  2. +16 −16 bin/varnishd/http2/cache_http2_hpack.c
  3. +4 −4 bin/varnishd/http2/cache_http2_proto.c
@@ -42,8 +42,8 @@ struct h2_error_s {
typedef const struct h2_error_s *h2_error;
#define H2EC0(U,v,d)
-#define H2EC1(U,v,d) extern const struct h2_error_s H2E_C_##U[1];
-#define H2EC2(U,v,d) extern const struct h2_error_s H2E_S_##U[1];
+#define H2EC1(U,v,d) extern const struct h2_error_s H2CE_##U[1];
+#define H2EC2(U,v,d) extern const struct h2_error_s H2SE_##U[1];
#define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d)
#define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc)
#include "tbl/h2_error.h"
@@ -49,7 +49,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
if (namelen == 2) {
VSLb(hp->vsl, SLT_BogoHeader, "Empty name");
- return (H2E_C_PROTOCOL_ERROR);
+ return (H2CE_PROTOCOL_ERROR);
}
for (p = b; p < b + len; p++) {
@@ -64,7 +64,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
VSLb(hp->vsl, SLT_BogoHeader,
"Illegal header name: %.*s",
(int)(len > 20 ? 20 : len), b);
- return (H2E_C_PROTOCOL_ERROR);
+ return (H2CE_PROTOCOL_ERROR);
} else if (p < b + namelen) {
/* ': ' added by us */
assert(*p == ':' || *p == ' ');
@@ -75,7 +75,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len)
VSLb(hp->vsl, SLT_BogoHeader,
"Illegal header value: %.*s",
(int)(len > 20 ? 20 : len), b);
- return (H2E_C_PROTOCOL_ERROR);
+ return (H2CE_PROTOCOL_ERROR);
}
}
@@ -95,7 +95,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len)
if (len > UINT_MAX) { /* XXX: cache_param max header size */
VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.20s", b);
- return (H2E_S_ENHANCE_YOUR_CALM);
+ return (H2SE_ENHANCE_YOUR_CALM);
}
if (b[0] == ':') {
@@ -127,7 +127,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len)
VSLb(hp->vsl, SLT_BogoHeader,
"Unknown pseudo-header: %.*s",
(int)(len > 20 ? 20 : len), b);
- return (H2E_S_PROTOCOL_ERROR);
+ return (H2SE_PROTOCOL_ERROR);
}
} else
n = hp->nhd;
@@ -138,14 +138,14 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len)
VSLb(hp->vsl, SLT_BogoHeader,
"Duplicate pseudo-header: %.*s",
(int)(len > 20 ? 20 : len), b);
- return (H2E_S_PROTOCOL_ERROR);
+ return (H2SE_PROTOCOL_ERROR);
}
} else {
/* Check for space in struct http */
if (n >= hp->shd) {
VSLb(hp->vsl, SLT_LostHeader, "Too many headers: %.*s",
(int)(len > 20 ? 20 : len), b);
- return (H2E_S_ENHANCE_YOUR_CALM);
+ return (H2SE_ENHANCE_YOUR_CALM);
}
hp->nhd++;
}
@@ -195,7 +195,7 @@ h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d)
boundary */
VSLb(h2->new_req->http->vsl, SLT_BogoHeader,
"HPACK compression error (%s)", VHD_Error(d->vhd_ret));
- ret = H2E_C_COMPRESSION_ERROR;
+ ret = H2CE_COMPRESSION_ERROR;
} else
ret = d->error;
d->magic = 0;
@@ -227,7 +227,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
/* Only H2E_ENHANCE_YOUR_CALM indicates that we should continue
processing. Other errors should have been returned and handled
by the caller. */
- assert(d->error == 0 || d->error == H2E_S_ENHANCE_YOUR_CALM);
+ assert(d->error == 0 || d->error == H2SE_ENHANCE_YOUR_CALM);
while (1) {
AN(d->out);
@@ -239,14 +239,14 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
VSLb(hp->vsl, SLT_BogoHeader,
"HPACK compression error (%s)",
VHD_Error(d->vhd_ret));
- d->error = H2E_C_COMPRESSION_ERROR;
+ d->error = H2CE_COMPRESSION_ERROR;
break;
} else if (d->vhd_ret == VHD_OK || d->vhd_ret == VHD_MORE) {
assert(in_u == in_l);
break;
}
- if (d->error == H2E_S_ENHANCE_YOUR_CALM) {
+ if (d->error == H2SE_ENHANCE_YOUR_CALM) {
d->out_u = 0;
assert(d->out_u < d->out_l);
continue;
@@ -258,7 +258,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
case VHD_NAME:
assert(d->namelen == 0);
if (d->out_l - d->out_u < 2) {
- d->error = H2E_S_ENHANCE_YOUR_CALM;
+ d->error = H2SE_ENHANCE_YOUR_CALM;
break;
}
d->out[d->out_u++] = ':';
@@ -271,7 +271,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
case VHD_VALUE:
assert(d->namelen > 0);
if (d->out_l - d->out_u < 1) {
- d->error = H2E_S_ENHANCE_YOUR_CALM;
+ d->error = H2SE_ENHANCE_YOUR_CALM;
break;
}
d->error = h2h_checkhdr(hp, d->out, d->namelen,
@@ -289,15 +289,15 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
break;
case VHD_BUF:
- d->error = H2E_S_ENHANCE_YOUR_CALM;
+ d->error = H2SE_ENHANCE_YOUR_CALM;
break;
default:
WRONG("Unhandled return value");
break;
}
- if (d->error == H2E_S_ENHANCE_YOUR_CALM) {
+ if (d->error == H2SE_ENHANCE_YOUR_CALM) {
http_Teardown(hp);
d->out = d->reset;
d->out_l = hp->ws->r - d->out;
@@ -307,7 +307,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d,
break;
}
- if (d->error == H2E_S_ENHANCE_YOUR_CALM)
+ if (d->error == H2SE_ENHANCE_YOUR_CALM)
return (0); /* Stream error, delay reporting until
h2h_decode_fini so that we can process the
complete header block */
@@ -41,8 +41,8 @@
#include "vtim.h"
#define H2EC0(U,v,d)
-#define H2EC1(U,v,d) const struct h2_error_s H2E_C_##U[1] = {{#U,d,v,0,1}};
-#define H2EC2(U,v,d) const struct h2_error_s H2E_S_##U[1] = {{#U,d,v,1,0}};
+#define H2EC1(U,v,d) const struct h2_error_s H2CE_##U[1] = {{#U,d,v,0,1}};
+#define H2EC2(U,v,d) const struct h2_error_s H2SE_##U[1] = {{#U,d,v,1,0}};
#define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d)
#define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc)
#include "tbl/h2_error.h"
@@ -394,7 +394,7 @@ h2_do_req(struct worker *wrk, void *priv)
VSL(SLT_Debug, 0, "H2REQ CNT done");
/* XXX clean up req */
r2->state = H2_S_CLOSED;
- h2_del_req(wrk, r2, H2E_S_NO_ERROR);
+ h2_del_req(wrk, r2, H2SE_NO_ERROR);
}
void __match_proto__(h2_frame_f)
@@ -765,7 +765,7 @@ h2_new_session(struct worker *wrk, void *arg)
/* Delete all idle streams */
VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) {
if (r2->state == H2_S_IDLE)
- h2_del_req(wrk, r2, H2E_S_NO_ERROR);
+ h2_del_req(wrk, r2, H2SE_NO_ERROR);
}
}

0 comments on commit 7144af0

Please sign in to comment.