[master] 0929e83 More backend/http_conn cleanup
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 6 11:35:57 CEST 2014
commit 0929e83453578a825a1c88db4b85996720182ffd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Oct 6 09:35:45 2014 +0000
More backend/http_conn cleanup
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index f661de3..056f61e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -244,7 +244,6 @@ struct http_conn {
#define HTTP_CONN_MAGIC 0x3e19edd1
int fd;
- struct vsl_log *vsl;
unsigned maxbytes;
unsigned maxhdr;
struct ws *ws;
@@ -915,7 +914,7 @@ enum http1_status_e {
HTTP1_COMPLETE = 1
};
-void HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *,
+void HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd,
unsigned maxbytes, unsigned maxhdr);
enum http1_status_e HTTP1_Reinit(struct http_conn *htc);
enum http1_status_e HTTP1_Rx(struct http_conn *htc);
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 974c5b4..2d63159 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -155,8 +155,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo)
/* Receive response */
- HTTP1_Init(htc, bo->ws, vc->fd, bo->vsl,
- cache_param->http_resp_size,
+ HTTP1_Init(htc, bo->ws, vc->fd, cache_param->http_resp_size,
cache_param->http_resp_hdr_len);
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC);
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index dc586cc..4850df2 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -357,9 +357,8 @@ HTTP1_Session(struct worker *wrk, struct req *req)
}
if (sp->sess_step == S_STP_NEWREQ) {
- HTTP1_Init(req->htc, req->ws, sp->fd, req->vsl,
- cache_param->http_req_size,
- cache_param->http_req_hdr_len);
+ HTTP1_Init(req->htc, req->ws, sp->fd,
+ cache_param->http_req_size, cache_param->http_req_hdr_len);
}
while (1) {
diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c
index 9ee962a..8eac608 100644
--- a/bin/varnishd/http1/cache_http1_proto.c
+++ b/bin/varnishd/http1/cache_http1_proto.c
@@ -60,14 +60,13 @@ const int HTTP1_Resp[3] = {
/*--------------------------------------------------------------------*/
void
-HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl,
- unsigned maxbytes, unsigned maxhdr)
+HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, unsigned maxbytes,
+ unsigned maxhdr)
{
htc->magic = HTTP_CONN_MAGIC;
htc->ws = ws;
htc->fd = fd;
- htc->vsl = vsl;
htc->maxbytes = maxbytes;
htc->maxhdr = maxhdr;
diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c
index 18b9995..daf81a5 100644
--- a/bin/varnishd/http1/cache_http1_vfp.c
+++ b/bin/varnishd/http1/cache_http1_vfp.c
@@ -46,12 +46,13 @@
*/
static ssize_t
-v1f_read(struct http_conn *htc, void *d, size_t len)
+v1f_read(const struct vfp_ctx *vc, struct http_conn *htc, void *d, size_t len)
{
ssize_t l;
unsigned char *p;
ssize_t i = 0;
+ CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
l = 0;
p = d;
@@ -71,7 +72,8 @@ v1f_read(struct http_conn *htc, void *d, size_t len)
i = read(htc->fd, p, len);
if (i < 0) {
// XXX: VTCP_Assert(i); // but also: EAGAIN
- VSLb(htc->vsl, SLT_FetchError, "%s", strerror(errno));
+ VSLb(vc->wrk->vsl, SLT_FetchError,
+ "%s", strerror(errno));
return (i);
}
}
@@ -110,7 +112,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
if (vfe->priv2 == -1) {
/* Skip leading whitespace */
do {
- lr = v1f_read(htc, buf, 1);
+ lr = v1f_read(vc, htc, buf, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
} while (vct_islws(buf[0]));
@@ -121,7 +123,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
/* Collect hex digits, skipping leading zeros */
for (u = 1; u < sizeof buf; u++) {
do {
- lr = v1f_read(htc, buf + u, 1);
+ lr = v1f_read(vc, htc, buf + u, 1);
if (lr <= 0)
return (VFP_Error(vc,
"chunked read err"));
@@ -135,7 +137,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
/* Skip trailing white space */
while(vct_islws(buf[u]) && buf[u] != '\n') {
- lr = v1f_read(htc, buf + u, 1);
+ lr = v1f_read(vc, htc, buf + u, 1);
if (lr <= 0)
return (VFP_Error(vc, "chunked read err"));
}
@@ -157,7 +159,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
if (vfe->priv2 > 0) {
if (vfe->priv2 < l)
l = vfe->priv2;
- lr = v1f_read(htc, ptr, l);
+ lr = v1f_read(vc, htc, ptr, l);
if (lr <= 0)
return (VFP_Error(vc, "straight insufficient bytes"));
*lp = lr;
@@ -167,10 +169,10 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr,
return (VFP_OK);
}
AZ(vfe->priv2);
- i = v1f_read(htc, buf, 1);
+ i = v1f_read(vc, htc, buf, 1);
if (i <= 0)
return (VFP_Error(vc, "chunked read err"));
- if (buf[0] == '\r' && v1f_read(htc, buf, 1) <= 0)
+ if (buf[0] == '\r' && v1f_read(vc, htc, buf, 1) <= 0)
return (VFP_Error(vc, "chunked read err"));
if (buf[0] != '\n')
return (VFP_Error(vc, "chunked tail no NL"));
@@ -205,7 +207,7 @@ v1f_pull_straight(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p,
return (VFP_END);
if (vfe->priv2 < l)
l = vfe->priv2;
- lr = v1f_read(htc, p, l);
+ lr = v1f_read(vc, htc, p, l);
if (lr <= 0)
return (VFP_Error(vc, "straight insufficient bytes"));
*lp = lr;
@@ -237,7 +239,7 @@ v1f_pull_eof(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp)
l = *lp;
*lp = 0;
- lr = v1f_read(htc, p, l);
+ lr = v1f_read(vc, htc, p, l);
if (lr < 0)
return (VFP_Error(vc, "eof socket fail"));
if (lr == 0)
More information about the varnish-commit
mailing list