Commit 0929e834 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

More backend/http_conn cleanup

parent 9fb31481
......@@ -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);
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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;
......
......@@ -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)
......
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