libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Doubts regarding MHD_OPTION_CONNECTION_LIMIT default


From: Evgeny Grin
Subject: Re: [libmicrohttpd] Doubts regarding MHD_OPTION_CONNECTION_LIMIT default and usage of 0
Date: Sat, 26 Nov 2016 14:05:00 +0300
User-agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.5.0

Hi Fermin,

On 24.11.2016 22:20, Fermín Galán Márquez wrote:

> From MHD documentation
> https://www.gnu.org/software/libmicrohttpd/manual/libmicrohttpd.html,
> the description of MHD_OPTION_CONNECTION_LIMIT is as follows:
> /
> //"Maximum number of concurrent connections to accept (followed by an
> unsigned int). The default is FD_SETSIZE - 4 (the maximum number of file
> descriptors supported by select minus four for stdin, stdout, stderr and
> the server socket). In other words, the default is as large as possible."/
> 
> I wonder to which number refers that FD_SETSIZE in the documentation. I
> mean:
> 
>  1. To the FD_SETSIZE at system library, which happens to be 1024, at
>     least in my system looking to
>     /usr/include/x86_64-linux-gnu/sys/select.h and
>     /usr/include/x86_64-linux-gnu/bits/typesizes.h. I understand that in
>     other system it could be different number from different system
>     library .h, but always static and independent of the operating
>     system configuration.

FD_SETSIZE is number defined as FD_SETSIZE in system headers.
On GNU/Linux systems, it's 1024 in most cases.
However, on many systems (W32, FreeBSD, Solaris, Darwin) it's not
completely static and could be defined to any particular value before
including system headers.
MHD uses value of FD_SETSIZE as it was defined during MHD compilation.
If your application redefine FD_SETSIZE, need "external" polling mode
MHD mode and need to get fd_sets from MHD, just define FD_SETSIZE before
including "microhttpd.h" and MHD_get_fdset() macro will automatically
use your value of FD_SETSIZE.

>  2. To the actual file descriptors limit used by the operating system,
>     e.g. the one that can be changed with ulimit. In this case, the
>     setting is dynamic and I understand that the "maximum number of file
>     descriptor" is taken at process (using MHD) starting time.

Changing any system limits will not change sizes of 'fd_set' which
depends of value of FD_SETSIZE defined during compilation.

> Which is the right one?

Value of FD_SETSIZE in system headers during MHD compilation as it
determines size of "fd_set" used by MHD compiled code.

> In addition, has 0 (as valid unsigned int) a meaning for this option? Or
> just it mus not be used? Not sure about this looking the documentation...

Currently value zero doesn't have any special meaning.
You can start MHD with zero limit of number of accepted connection, if
you wish.

-- 
Best Wishes,
Evgeny Grin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]