Dear friends.

On Mon, Dec 2, 2019 at 12:49 PM José Bollo <jo...@nonadev.net> wrote:

> No in fact the question is serious. There is no simple way to let run
> MHD on the main thread. It requires implementing an external
> poll/select loop.
>
> Can you provide an integrated main that serves and doesn't return until
> stopped?
>

IMHO, it would be really very useful. Unfortunately, without this feature,
we need to implement hard logic using select()/epoll() by hand in our
console applications.

In Rust and Pascal we generally call some locking function to stay
"running" application, in those cases, it would be nice to call something
like this:

static int my_awesome_callback(void *cls) {
  return *application_terminated* ? MHD_YES : MHD_NO;
}

MHD_main_loop(my_awesome_callback, NULL);

so the MHD_main_loop() would hold the console application without exiting,
something like getchar() does. Many other C/Rust libraries implements this
loop, for example:

1. libsoup / C:
https://gitlab.gnome.org/GNOME/libsoup/blob/master/examples/simple-httpd.c#L300
2. mongoose / C:
https://github.com/cesanta/mongoose/blob/master/examples/simplest_web_server/simplest_web_server.c#L33
3. warp / Rust:
https://github.com/seanmonstar/warp/blob/master/examples/hello.rs#L9
4. actix-web / Rust:
https://github.com/actix/actix-web/blob/master/examples/basic.rs#L46

This is a very appreciated feature in many other libraries/frameworks.

Best regards
> José Bollo


-- 
Silvio Clécio

Reply via email to