Commit abeded8d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Vector request failuers through the transport protocol

parent 4743b17b
......@@ -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);
}
......@@ -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;
......
......@@ -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,
......
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