Commit 292201c0 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Preparation for implementation of restarts: Move the ws from http to

the containing object (session or obj).


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2051 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e22de573
......@@ -117,7 +117,7 @@ struct http {
unsigned magic;
#define HTTP_MAGIC 0x6428b5c9
struct ws ws[1];
struct ws *ws;
txt rx; /* Received Request */
txt pl; /* Pipelined bytes */
......@@ -186,8 +186,7 @@ struct bereq {
unsigned magic;
#define BEREQ_MAGIC 0x3b6d250c
VTAILQ_ENTRY(bereq) list;
void *space;
unsigned len;
struct ws ws[1];
struct http http[1];
};
......@@ -217,6 +216,7 @@ struct object {
unsigned xid;
struct objhead *objhead;
struct ws ws_o[1];
unsigned char *vary;
unsigned heap_idx;
......@@ -285,6 +285,7 @@ struct sess {
/* HTTP request */
const char *doclose;
struct http *http;
struct ws ws[1];
/* Timestamps, all on TIM_real() timescale */
double t_open;
......@@ -460,7 +461,7 @@ void http_PutResponse(struct worker *w, int fd, struct http *to, const char *res
void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetH(struct http *to, unsigned n, const char *fm);
void http_Setup(struct http *ht, void *space, unsigned len);
void http_Setup(struct http *ht, struct ws *ws);
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
int http_GetStatus(const struct http *hp);
......@@ -475,7 +476,7 @@ int http_RecvSome(int fd, struct http *hp);
int http_RecvHead(struct http *hp, int fd);
int http_DissectRequest(struct worker *w, struct http *sp, int fd);
int http_DissectResponse(struct worker *w, struct http *sp, int fd);
void http_DoConnection(struct sess *sp);
const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
......
......@@ -147,10 +147,9 @@ VBE_new_bereq(void)
if (bereq == NULL)
return (NULL);
bereq->magic = BEREQ_MAGIC;
bereq->space = bereq + 1;
bereq->len = len;
WS_Init(bereq->ws, bereq + 1, len);
}
http_Setup(bereq->http, bereq->space, bereq->len);
http_Setup(bereq->http, bereq->ws);
return (bereq);
}
......
......@@ -763,7 +763,7 @@ cnt_recv(struct sess *sp)
return (0);
}
http_DoConnection(sp);
sp->doclose = http_DoConnection(sp->http);
/* By default we use the first backend */
AZ(sp->backend);
......
......@@ -332,7 +332,8 @@ Fetch(struct sess *sp)
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
b = malloc(len);
AN(b);
http_Setup(hp2, b, len);
WS_Init(sp->obj->ws_o, b, len);
http_Setup(hp2, sp->obj->ws_o);
CHECK_OBJ_NOTNULL(sp->backend, BACKEND_MAGIC);
hp2->logtag = HTTP_Obj;
......
......@@ -160,13 +160,12 @@ http_StatusMessage(unsigned status)
/*--------------------------------------------------------------------*/
void
http_Setup(struct http *hp, void *space, unsigned len)
http_Setup(struct http *hp, struct ws *ws)
{
assert(len > 0);
memset(hp, 0, sizeof *hp);
hp->magic = HTTP_MAGIC;
WS_Init(hp->ws, space, len);
hp->ws = ws;
hp->nhd = HTTP_HDR_FIRST;
}
......@@ -266,18 +265,19 @@ http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char
/*--------------------------------------------------------------------*/
void
http_DoConnection(struct sess *sp)
const char *
http_DoConnection(struct http *hp)
{
struct http *hp = sp->http;
char *p, *q;
const char *ret;
unsigned u;
if (!http_GetHdr(hp, H_Connection, &p)) {
if (strcmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1"))
sp->doclose = "not HTTP/1.1";
return;
return ("not HTTP/1.1");
return (NULL);
}
ret = NULL;
for (; *p; p++) {
if (isspace(*p))
continue;
......@@ -288,7 +288,7 @@ http_DoConnection(struct sess *sp)
break;
u = pdiff(p, q);
if (u == 5 && !strncasecmp(p, "close", u))
sp->doclose = "Connection: close";
ret = "Connection: close";
u = http_findhdr(hp, u, p);
if (u != 0)
hp->hdf[u] |= HDF_FILTER;
......@@ -296,6 +296,7 @@ http_DoConnection(struct sess *sp)
break;
p = q;
}
return (ret);
}
/*--------------------------------------------------------------------*/
......
......@@ -302,7 +302,6 @@ SES_New(const struct sockaddr *addr, unsigned len)
memset(sp, 0, sizeof *sp);
sp->magic = SESS_MAGIC;
sp->mem = sm;
sp->http = &sm->http;
sp->sockaddr = (void*)(&sm->sockaddr[0]);
sp->sockaddrlen = sizeof(sm->sockaddr[0]);
sp->mysockaddr = (void*)(&sm->sockaddr[1]);
......@@ -319,7 +318,9 @@ SES_New(const struct sockaddr *addr, unsigned len)
sp->sockaddrlen = len;
}
http_Setup(&sm->http, (void *)(sm + 1), sm->workspace);
WS_Init(sp->ws, (void *)(sm + 1), sm->workspace);
sp->http = &sm->http;
http_Setup(sp->http, sp->ws);
return (sp);
}
......
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