From 0e2f46e4887618ce45e979d939d1329312ecaacd Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Sun, 13 Aug 2023 01:53:28 +0200 Subject: WIP parallel --- http.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'http.c') diff --git a/http.c b/http.c index 0960d85..22b45d9 100644 --- a/http.c +++ b/http.c @@ -2,6 +2,7 @@ #include "slweb/http.h" #include +#include #include #include #include @@ -909,12 +910,15 @@ static int process_payload(struct http_ctx *const h, const char *const line) { struct ctx *const c = &h->ctx; const struct http_payload p = ctx_to_payload(c); - const int ret = h->cfg.payload(&p, &h->wctx.r, h->cfg.user); + struct http_future f = {0}; + const int ret = h->cfg.payload(&p, &h->wctx.r, &f, h->cfg.user); ctx_free(c); if (ret) return ret; + else if (f.f) + return h->cfg.async(&f, h->cfg.user); return start_response(h); } @@ -950,6 +954,7 @@ static int expect(struct http_ctx *const h, const char *const value) if (!strcmp(value, "100-continue")) { struct ctx *const c = &h->ctx; + struct http_future f = {0}; const struct http_payload p = { .u.post.expect_continue = true, @@ -963,10 +968,12 @@ static int expect(struct http_ctx *const h, const char *const value) .resource = c->resource }; - const int ret = h->cfg.payload(&p, &h->wctx.r, h->cfg.user); + const int ret = h->cfg.payload(&p, &h->wctx.r, &f, h->cfg.user); if (ret) return ret; + else if (f.f) + return h->cfg.async(&f, h->cfg.user); return start_response(h); } @@ -1075,12 +1082,15 @@ static int send_payload(struct http_ctx *const h, const struct http_payload *const p) { struct ctx *const c = &h->ctx; - const int ret = h->cfg.payload(p, &h->wctx.r, h->cfg.user); + struct http_future f = {0}; + const int ret = h->cfg.payload(p, &h->wctx.r, &f, h->cfg.user); ctx_free(c); if (ret) return ret; + else if (f.f) + return h->cfg.async(&f, h->cfg.user); return start_response(h); } -- cgit v1.2.3