forked from mirrors/kore
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).
This commit is contained in:
parent
7dfa7e6ec0
commit
b65cc93426
|
@ -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)
|
||||
|
|
18
src/kore.c
18
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--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue