kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit 4f31d53e76072c7558276b5a941949f9607ff9e2
parent 332e8f4ba0363ba816109a51a8e46ef37056dde7
Author: Joris Vink <joris@coders.se>
Date:   Tue, 22 Apr 2014 23:07:24 +0200

Allow KORE_RESULT_RETRY from authentication blocks

Diffstat:
src/auth.c | 9+++++++--
src/http.c | 11+++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/auth.c b/src/auth.c @@ -75,9 +75,14 @@ kore_auth(struct http_request *req, struct kore_auth *auth) return (KORE_RESULT_ERROR); } - if (r == KORE_RESULT_OK) { + switch (r) { + case KORE_RESULT_OK: kore_debug("kore_auth() for %s successful", req->path); - return (KORE_RESULT_OK); + /* FALLTHROUGH */ + case KORE_RESULT_RETRY: + return (r); + default: + break; } kore_debug("kore_auth() for %s failed", req->path); diff --git a/src/http.c b/src/http.c @@ -198,18 +198,25 @@ http_process_request(struct http_request *req, int retry_only) else r = KORE_RESULT_OK; - if (r == KORE_RESULT_OK) { + switch (r) { + case KORE_RESULT_OK: req->hdlr = hdlr; cb = hdlr->addr; worker->active_hdlr = hdlr; r = cb(req); worker->active_hdlr = NULL; - } else { + break; + case KORE_RESULT_RETRY: + break; + case KORE_RESULT_ERROR: /* * Set r to KORE_RESULT_OK so we can properly * flush the result from kore_auth(). */ r = KORE_RESULT_OK; + break; + default: + fatal("kore_auth() returned unknown %d", r); } } req->end = kore_time_ms();