+ if (hreq) {
+ afb_hreq_unref(hreq);
+ }
+}
+
+static void do_run(int signum, void *arg)
+{
+ MHD_UNSIGNED_LONG_LONG to;
+ struct afb_hsrv *hsrv = arg;
+
+ if (!signum) {
+ do { MHD_run(hsrv->httpd); } while(MHD_get_timeout(hsrv->httpd, &to) == MHD_YES && !to);
+ }
+ fdev_set_events(hsrv->fdev, EPOLLIN);
+}
+
+void run_micro_httpd(struct afb_hsrv *hsrv)
+{
+ fdev_set_events(hsrv->fdev, 0);
+ if (jobs_queue(hsrv, 0, do_run, hsrv) < 0)
+ do_run(0, hsrv);
+}
+
+static void listen_callback(void *hsrv, uint32_t revents, struct fdev *fdev)
+{
+ run_micro_httpd(hsrv);