+ 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);
+ }
+ sd_event_source_set_io_events(hsrv->evsrc, EPOLLIN);
+}
+
+void run_micro_httpd(struct afb_hsrv *hsrv)
+{
+ sd_event_source_set_io_events(hsrv->evsrc, 0);
+ if (jobs_queue(hsrv, 0, do_run, hsrv) < 0)
+ do_run(0, hsrv);
+}
+
+static int io_event_callback(sd_event_source *src, int fd, uint32_t revents, void *hsrv)
+{
+ run_micro_httpd(hsrv);
+ return 0;