summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2016-04-26 21:56:27 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2016-04-26 21:56:27 +0200
commit6309ade131c20f1ad3a8385921e0fb278dfe850c (patch)
tree7a539d1f33389f05734103ef4d7794f277cf5e66
parent84d141ab55dbc409aed542fe5163f1ed16353beb (diff)
simplify handling of MHD_run
Change-Id: I96c89ef38d44cd25e7e7453a81c75cd790a8d54b Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-hsrv.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/src/afb-hsrv.c b/src/afb-hsrv.c
index abec0ada..f200a960 100644
--- a/src/afb-hsrv.c
+++ b/src/afb-hsrv.c
@@ -54,15 +54,8 @@ struct hsrv_alias {
int dirfd;
};
-enum afb_hsrv_state {
- hsrv_idle = 0,
- hsrv_run,
- hsrv_rerun
-};
-
struct afb_hsrv {
unsigned refcount;
- enum afb_hsrv_state state;
struct hsrv_handler *handlers;
struct MHD_Daemon *httpd;
struct upoll *upoll;
@@ -212,15 +205,9 @@ static void end_handler(void *cls, struct MHD_Connection *connection, void **rec
static void handle_epoll_readable(struct afb_hsrv *hsrv)
{
- if (hsrv->state != hsrv_idle)
- hsrv->state = hsrv_rerun;
- else {
- do {
- hsrv->state = hsrv_run;
- MHD_run(hsrv->httpd);
- } while (hsrv->state == hsrv_rerun);
- hsrv->state = hsrv_idle;
- }
+ upoll_on_readable(hsrv->upoll, NULL);
+ MHD_run(hsrv->httpd);
+ upoll_on_readable(hsrv->upoll, (void*)handle_epoll_readable);
};
static int new_client_handler(void *cls, const struct sockaddr *addr, socklen_t addrlen)