diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-08-13 01:53:28 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-08-13 02:30:06 +0200 |
| commit | 0e2f46e4887618ce45e979d939d1329312ecaacd (patch) | |
| tree | e31ce8dd88d0343e4f12837535893a8daf43c13c /http.c | |
| parent | f6562ddab30feb4bb63d9cda9801dbf607c33d07 (diff) | |
WIP parallelparallel
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -2,6 +2,7 @@ #include "slweb/http.h" #include <dynstr.h> +#include <pthread.h> #include <sys/types.h> #include <unistd.h> #include <ctype.h> @@ -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); } |
