[master] 62a2da0 Mark failures on the WS rather than on struct http, there is no advantage from having two mechanisms.
Poul-Henning Kamp
phk at FreeBSD.org
Wed Jun 25 11:11:10 CEST 2014
commit 62a2da09c27d5d57978ffbfda011fa7a9ceb068f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 25 09:09:20 2014 +0000
Mark failures on the WS rather than on struct http, there is no
advantage from having two mechanisms.
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 020157a..410aa7e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -197,7 +197,6 @@ struct http {
uint16_t status;
uint8_t protover;
uint8_t conds; /* If-* headers present */
- uint8_t failed; /* usually: ws-alloc failed */
};
/*--------------------------------------------------------------------
@@ -1017,7 +1016,7 @@ const char *http_GetReq(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
int http_IsHdr(const txt *hh, const char *hdr);
enum sess_close http_DoConnection(const struct http *);
-void http_CopyHome(struct http *hp);
+void http_CopyHome(const struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void http_CollectHdr(struct http *hp, const char *hdr);
void http_VSL_log(const struct http *hp);
diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c
index 159751b..2fc70be 100644
--- a/bin/varnishd/cache/cache_http.c
+++ b/bin/varnishd/cache/cache_http.c
@@ -95,12 +95,12 @@ http_VSL_log(const struct http *hp)
/*--------------------------------------------------------------------*/
static void
-http_fail(struct http *hp)
+http_fail(const struct http *hp)
{
VSC_C_main->losthdr++;
- VSLb(hp->vsl, SLT_Error, "out of workspace");
- hp->failed = 1;
+ VSLb(hp->vsl, SLT_Error, "out of workspace (%s)", hp->ws->id);
+ WS_MarkOverflow(hp->ws);
}
/*--------------------------------------------------------------------*/
@@ -210,7 +210,7 @@ http_SetH(const struct http *to, unsigned n, const char *fm)
/*--------------------------------------------------------------------*/
static void
-http_PutField(struct http *to, int field, const char *string)
+http_PutField(const struct http *to, int field, const char *string)
{
char *p;
@@ -274,7 +274,8 @@ http_CollectHdr(struct http *hp, const char *hdr)
unsigned u, l, ml, f, x, d;
char *b = NULL, *e = NULL;
- if (hp->failed)
+ CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC);
+ if (WS_Overflowed(hp->ws))
return;
l = hdr[0];
assert(l == strlen(hdr + 1));
@@ -760,7 +761,7 @@ http_Merge(const struct http *fm, struct http *to, int not_ce)
*/
void
-http_CopyHome(struct http *hp)
+http_CopyHome(const struct http *hp)
{
unsigned u, l;
char *p;
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index b74e101..c11f2d9 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -50,7 +50,7 @@ static char vrt_hostname[255] = "";
*/
static void
-vrt_do_string(struct http *hp, int fld,
+vrt_do_string(const struct http *hp, int fld,
const char *err, const char *p, va_list ap)
{
const char *b;
@@ -60,7 +60,7 @@ vrt_do_string(struct http *hp, int fld,
b = VRT_String(hp->ws, NULL, p, ap);
if (b == NULL || *b == '\0') {
VSLb(hp->vsl, SLT_LostHeader, "%s", err);
- hp->failed = 1;
+ WS_MarkOverflow(hp->ws);
return;
}
http_SetH(hp, fld, b);
@@ -100,11 +100,11 @@ VRT_l_##obj##_status(const struct vrt_ctx *ctx, long num) \
CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \
if (num > 65535) { \
VSLb(ctx->vsl, SLT_VCL_Error, "%s.status > 65535", #obj); \
- ctx->http_##obj->failed = 1; \
+ WS_MarkOverflow(ctx->http_##obj->ws); \
} else if ((num % 1000) < 100) { \
VSLb(ctx->vsl, SLT_VCL_Error, "illegal %s.status (..0##)", \
#obj); \
- ctx->http_##obj->failed = 1; \
+ WS_MarkOverflow(ctx->http_##obj->ws); \
} else { \
http_SetStatus(ctx->http_##obj, (uint16_t)num); \
} \
@@ -244,7 +244,7 @@ VRT_l_client_identity(const struct vrt_ctx *ctx, const char *str, ...)
va_end(ap);
if (b == NULL) {
VSLb(ctx->vsl, SLT_LostHeader, "client.identity");
- ctx->req->http->failed = 1;
+ WS_MarkOverflow(ctx->req->http->ws);
return;
}
ctx->req->client_identity = b;
@@ -331,7 +331,7 @@ VRT_l_beresp_storage_hint(const struct vrt_ctx *ctx, const char *str, ...)
va_end(ap);
if (b == NULL) {
VSLb(ctx->vsl, SLT_LostHeader, "storage.hint");
- ctx->bo->beresp->failed = 1;
+ WS_MarkOverflow(ctx->bo->beresp->ws);
return;
}
ctx->bo->storage_hint = b;
More information about the varnish-commit
mailing list