kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit b65cc934260d5f846fd6cbab26ca764519692c08
parent 7dfa7e6ec01abe0d0ceddfb64be6e2d3c2ffcc38
Author: Joris Vink <joris@coders.se>
Date:   Fri, 31 May 2013 00:40:06 +0200

allow handlers to return KORE_RESULT_RETRY. This will tell the worker to reschedule the page request again at the end of its list. (Allows module creators to write truely nonblocking modules).

Diffstat:
includes/kore.h | 1+
src/kore.c | 18+++++++++++++-----
2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/includes/kore.h b/includes/kore.h @@ -19,6 +19,7 @@ #define KORE_RESULT_ERROR 0 #define KORE_RESULT_OK 1 +#define KORE_RESULT_RETRY 2 #define errno_s strerror(errno) #define ssl_errno_s ERR_error_string(ERR_get_error(), NULL) diff --git a/src/kore.c b/src/kore.c @@ -593,19 +593,27 @@ kore_worker_entry(void *arg) r = hdlr(req); pthread_rwlock_unlock(&module_lock); - if (r != KORE_RESULT_ERROR) { + switch (r) { + case KORE_RESULT_OK: r = net_send_flush(req->owner); if (r == KORE_RESULT_ERROR) kore_server_disconnect(req->owner); - } else { + break; + case KORE_RESULT_ERROR: kore_server_disconnect(req->owner); + break; + case KORE_RESULT_RETRY: + TAILQ_INSERT_TAIL(&(kw->requests), req, list); + break; } pthread_mutex_unlock(&(req->owner->lock)); - pthread_mutex_lock(&(kw->lock)); - http_request_free(req); - kw->load--; + if (r != KORE_RESULT_RETRY) { + pthread_mutex_lock(&(kw->lock)); + http_request_free(req); + kw->load--; + } } }