Master,

I'm going to test it in C simulating my scenario (in Pascal), the idea
using a list of daemons is really awesome.

Thanks a lot for the full example, I probably will be back with some news!
:-)

On Fri, Dec 2, 2016 at 4:40 PM, Evgeny Grin <k...@yandex.ru> wrote:

> You will need something like:
>
> -----------------
>   size_t N = 0; /* number of inited daemons */
>   size_t n = 0; /* current worker */
>   MHD_Daemon* daemons[MAX_DAEMONS];
>   daemons[N++] = MHD_start_daemon (MHD_USE_NO_LISTEN_SOCKET |
> MHD_USE_SELECT_INTERNALLY, ....);
>   while (processingAllowed())
>   {
>     int fd = accept (listen_fd, &addr, &addrlen);
>     if (-1 == fd)
>       continue;
>
>     if (!isSomeFunctionOfMyAppResponding())
>     {
>       if (N < MAX_DAEMONS)
>       { /* Add new daemon if space is available */
>         daemons[N++] = MHD_start_daemon (MHD_USE_NO_LISTEN_SOCKET |
> MHD_USE_SELECT_INTERNALLY, ....);
>       }
>       n++; /* Switch to next worker */
>       if (MAX_DAEMONS == n)
>       {
>         n = 0; /* Return processing to first daemon */
>       }
>     }
>     MHD_add_connection (daemons[n], fd, &addr, &addrlen);
>   }
> -----------------
>
> "Slow" daemons will continue processing their connections, when slowdown
> is detected, you will switch new connections to next daemon.
>
> --
> Best Wishes,
> Evgeny Grin


-- 
Silvio Clécio

Reply via email to