- upoll_on_readable(hsrv->upoll, NULL);
- MHD_run(hsrv->httpd);
- upoll_on_readable(hsrv->upoll, (void*)handle_epoll_readable);
-};
+ 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;
+}