[master] abeded8 Vector request failuers through the transport protocol
Poul-Henning Kamp
phk at FreeBSD.org
Wed Apr 6 00:09:05 CEST 2016
commit abeded8d1bf8601e0df5ea1cbd42190e24482618
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Apr 5 22:08:20 2016 +0000
Vector request failuers through the transport protocol
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index 63be280..72c3d95 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -39,6 +39,7 @@
#include "cache.h"
#include "cache_pool.h"
+#include "cache_transport.h"
#include "vtim.h"
@@ -209,11 +210,11 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
/*----------------------------------------------------------------------
*/
-void __match_proto__()
+void __match_proto__(vtr_req_fail_f)
Req_Fail(struct req *req, enum sess_close reason)
{
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
- if (req->sp->fd >= 0)
- SES_Close(req->sp, reason);
+ AN(req->transport->req_fail);
+ req->transport->req_fail(req, reason);
}
diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h
index 0af1a11..40847a5 100644
--- a/bin/varnishd/cache/cache_transport.h
+++ b/bin/varnishd/cache/cache_transport.h
@@ -40,6 +40,7 @@ typedef void vtr_deliver_f (struct req *, struct boc *, int sendbody);
typedef void vtr_req_body_f (struct req *);
typedef void vtr_sess_panic_f (struct vsb *, const struct sess *);
typedef void vtr_req_panic_f (struct vsb *, const struct req *);
+typedef void vtr_req_fail_f (struct req *, enum sess_close);
struct transport {
unsigned magic;
@@ -52,6 +53,7 @@ struct transport {
task_func_t *new_session;
task_func_t *unwait;
+ vtr_req_fail_f *req_fail;
vtr_req_body_f *req_body;
vtr_deliver_f *deliver;
vtr_sess_panic_f *sess_panic;
diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c
index 5670421..0174604 100644
--- a/bin/varnishd/http1/cache_http1_fsm.c
+++ b/bin/varnishd/http1/cache_http1_fsm.c
@@ -168,12 +168,20 @@ http1_req_panic(struct vsb *vsb, const struct req *req)
VSB_printf(vsb, "state = %s\n", http1_getstate(req->sp));
}
+static void __match_proto__(vtr_req_fail_f)
+http1_req_fail(struct req *req, enum sess_close reason)
+{
+ if (req->sp->fd >= 0)
+ SES_Close(req->sp, reason);
+}
+
struct transport HTTP1_transport = {
.name = "HTTP/1",
.magic = TRANSPORT_MAGIC,
.deliver = V1D_Deliver,
.unwait = http1_unwait,
.req_body = http1_req_body,
+ .req_fail = http1_req_fail,
.new_session = http1_new_session,
.sess_panic = http1_sess_panic,
.req_panic = http1_req_panic,
More information about the varnish-commit
mailing list