Re: [libmicrohttpd] running in main thread

2019-12-04 Thread silvioprog
On Wed, Dec 4, 2019 at 9:38 AM Evgeny Grin wrote: > You can also use very portable and universal solution: > > mhd = MHD_start_daemon(MHD_USE_AUTO, > > while(1) > { > fd_set rs; > fd_set ws; > Thanks for sharing! Is there any version of this code using epoll()? If so, I could contribute

Re: [libmicrohttpd] running in main thread

2019-12-04 Thread Evgeny Grin
You can also use very portable and universal solution:   mhd = MHD_start_daemon(MHD_USE_AUTO,  while(1){ fd_set rs; fd_set ws; fd_set es; MHD_socket maxsock;  struct timeval tv;  struct timeval* tvp; unsigned long long tov;   FD_ZERO (&rs);  FD_ZERO (&ws);  FD_ZERO (&es); maxsock = MHD_INVALID_

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread Christian Grothoff
On 12/2/19 10:18 PM, José Bollo wrote: >> Well, that's trivial. Please consider the attached fragment (not >> tested, but should be very close to what you need, modulo error >> handling). > I know it is trivial (my implementation below) but I advocate to offer > a facility that does the job. It avo

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread José Bollo
On Mon, 2 Dec 2019 22:03:51 +0100 Christian Grothoff wrote: > On 12/2/19 9:55 PM, José Bollo wrote: > > > > I tried to write something like "while(true) MHD_run();" but strace > > showed its inefficiency. > > Oh my. Yes, that'd be bad. > > > IMHO it can make sense: "1. setup 2. run" without

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread Christian Grothoff
On 12/2/19 9:55 PM, José Bollo wrote: > > I tried to write something like "while(true) MHD_run();" but strace > showed its inefficiency. Oh my. Yes, that'd be bad. > IMHO it can make sense: "1. setup 2. run" without exit conditon and not > bound to any stdin, i.e. a normal unix daemon. > Well,

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread José Bollo
On Mon, 2 Dec 2019 17:41:09 +0100 Christian Grothoff wrote: > On 12/2/19 4:49 PM, José Bollo wrote: > > On Mon, 2 Dec 2019 15:08:39 +0100 > > José Bollo wrote: > > > >> On Mon, 2 Dec 2019 15:04:52 +0100 > >> José Bollo wrote: > >> > >> rereading comment of MHD_USE_INTERNAL_POLLING_THREAD my

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread silvioprog
On Mon, Dec 2, 2019 at 2:22 PM silvioprog wrote: > 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_

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread silvioprog
Dear friends. On Mon, Dec 2, 2019 at 12:49 PM José Bollo 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 >

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread Christian Grothoff
On 12/2/19 4:49 PM, José Bollo wrote: > On Mon, 2 Dec 2019 15:08:39 +0100 > José Bollo wrote: > >> On Mon, 2 Dec 2019 15:04:52 +0100 >> José Bollo wrote: >> >> rereading comment of MHD_USE_INTERNAL_POLLING_THREAD my question looks >> stupid > > No in fact the question is serious. There is no si

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread José Bollo
On Mon, 2 Dec 2019 15:08:39 +0100 José Bollo wrote: > On Mon, 2 Dec 2019 15:04:52 +0100 > José Bollo wrote: > > rereading comment of MHD_USE_INTERNAL_POLLING_THREAD my question looks > stupid No in fact the question is serious. There is no simple way to let run MHD on the main thread. It requi

Re: [libmicrohttpd] running in main thread

2019-12-02 Thread José Bollo
On Mon, 2 Dec 2019 15:04:52 +0100 José Bollo wrote: rereading comment of MHD_USE_INTERNAL_POLLING_THREAD my question looks stupid sorry for the noise > Hi all, > > I searched in examples how to "block" in main thread on serving files > but I only found examples with the sequence summarized her