DOT deliver2 -> DONE [style=bold]
*/
-static void cnt_deliver(struct worker *w, struct sess *sp) { (void)w; (void)sp; INCOMPL(); }
+static void
+cnt_deliver(struct worker *w, struct sess *sp)
+{
+
+ vca_write_obj(w, sp);
+ sp->step = STP_DONE;
+}
/*--------------------------------------------------------------------
DOT DONE [
DOT fetch_error -> ERROR
*/
-static void cnt_fetch(struct worker *w, struct sess *sp) { (void)w; (void)sp; INCOMPL(); }
+static void
+cnt_fetch(struct worker *w, struct sess *sp)
+{
+
+ RFC2616_cache_policy(sp, sp->bkd_http);
+
+ VCL_fetch_method(sp);
+
+ if (sp->handling == VCL_RET_LOOKUP)
+ INCOMPL();
+ if (sp->handling == VCL_RET_PASS)
+ INCOMPL();
+ if (sp->handling == VCL_RET_INSERT_PASS)
+ INCOMPL();
+ if (sp->handling == VCL_RET_INSERT) {
+ FetchBody(w, sp);
+ sp->step = STP_DELIVER;
+ return;
+ }
+ if (sp->handling == VCL_RET_ERROR)
+ INCOMPL();
+ INCOMPL();
+}
/*--------------------------------------------------------------------
DOT subgraph cluster_hit {
static void
cnt_lookup(struct worker *w, struct sess *sp)
{
- struct object *o;
- o = HSH_Lookup(w, sp->http);
- sp->obj = o;
- if (o->busy) {
+ sp->obj = HSH_Lookup(w, sp->http);
+ if (sp->obj->busy) {
VSL_stats->cache_miss++;
sp->step = STP_MISS;
} else {
VSL_stats->cache_hit++;
- VSL(SLT_Hit, sp->fd, "%u", o->xid);
+ VSL(SLT_Hit, sp->fd, "%u", sp->obj->xid);
sp->step = STP_HIT;
}
}
if (sp->handling == VCL_RET_LOOKUP)
INCOMPL();
if (sp->handling == VCL_RET_FETCH) {
- /* XXX */
- FetchSession(w, sp);
- sp->step = STP_DONE;
+ FetchHeaders(w, sp);
+ sp->step = STP_FETCH;
return;
}
INCOMPL();
}
/*--------------------------------------------------------------------*/
+
int
-FetchSession(struct worker *w, struct sess *sp)
+FetchBody(struct worker *w, struct sess *sp)
{
int i, cls;
struct vbe_conn *vc;
char *b;
int body;
- sp->obj->xid = sp->xid;
-
- vc = VBE_GetFd(sp->backend, sp->xid);
- if (vc == NULL)
- vc = VBE_GetFd(sp->backend, sp->xid);
- assert(vc != NULL); /* XXX: handle this */
- VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
-
- hp = vc->http;
- http_BuildSbuf(vc->fd, Build_Fetch, w->sb, sp->http);
- i = write(vc->fd, sbuf_data(w->sb), sbuf_len(w->sb));
- assert(i == sbuf_len(w->sb));
- time(&sp->t_req);
-
- /* XXX: copy any contents */
-
- /*
- * XXX: It might be cheaper to avoid the event_engine and simply
- * XXX: read(2) the header
- */
- http_RecvHead(hp, vc->fd, w->eb, NULL, NULL);
- event_base_loop(w->eb, 0);
- time(&sp->t_resp);
- assert(http_DissectResponse(hp, vc->fd) == 0);
-
- body = RFC2616_cache_policy(sp, hp);
-
- VCL_fetch_method(sp);
-
- if (sp->obj->cacheable)
- EXP_Insert(sp->obj);
+ vc = sp->vbc;
+ hp = sp->bkd_http;
http_BuildSbuf(sp->fd, Build_Reply, w->sb, hp);
if (body) {
sp->obj->header = strdup(sbuf_data(w->sb));
VSL_stats->n_header++;
- vca_write_obj(w, sp);
-
if (http_GetHdr(hp, "Connection", &b) && !strcasecmp(b, "close"))
cls = 1;
else
VBE_RecycleFd(vc);
+ if (sp->obj->cacheable)
+ EXP_Insert(sp->obj);
HSH_Unbusy(sp->obj);
if (!sp->obj->cacheable)
HSH_Deref(sp->obj);
+ return (0);
+}
- return (1);
+/*--------------------------------------------------------------------*/
+
+int
+FetchHeaders(struct worker *w, struct sess *sp)
+{
+ int i, cls;
+ struct vbe_conn *vc;
+ struct http *hp;
+ char *b;
+ int body;
+
+ sp->obj->xid = sp->xid;
+
+ vc = VBE_GetFd(sp->backend, sp->xid);
+ if (vc == NULL)
+ vc = VBE_GetFd(sp->backend, sp->xid);
+ assert(vc != NULL); /* XXX: handle this */
+ VSL(SLT_Backend, sp->fd, "%d %s", vc->fd, sp->backend->vcl_name);
+
+ hp = vc->http;
+ http_BuildSbuf(vc->fd, Build_Fetch, w->sb, sp->http);
+ i = write(vc->fd, sbuf_data(w->sb), sbuf_len(w->sb));
+ assert(i == sbuf_len(w->sb));
+ time(&sp->t_req);
+
+ /* XXX: copy any body ?? */
+
+ /*
+ * XXX: It might be cheaper to avoid the event_engine and simply
+ * XXX: read(2) the header
+ */
+ http_RecvHead(hp, vc->fd, w->eb, NULL, NULL);
+ event_base_loop(w->eb, 0);
+ time(&sp->t_resp);
+ assert(http_DissectResponse(hp, vc->fd) == 0);
+ sp->vbc = vc;
+ sp->bkd_http = hp;
+ return (0);
}