From: José Bollo Date: Tue, 26 Apr 2016 19:56:27 +0000 (+0200) Subject: simplify handling of MHD_run X-Git-Tag: blowfish_2.0.1~163 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=6309ade131c20f1ad3a8385921e0fb278dfe850c;p=src%2Fapp-framework-binder.git simplify handling of MHD_run Change-Id: I96c89ef38d44cd25e7e7453a81c75cd790a8d54b Signed-off-by: José Bollo --- 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)