[Libwebsockets] trouble with external POLL array handling

Edwin van den Oetelaar oetelaar.automatisering at gmail.com
Wed Jan 16 10:51:50 CET 2013


Hello Andy (and others)

I am a bit confused about the meaning of MAX_CLIENTS (which is 100 by default)
The thing is that although there is space of 3201 items (MAX_CLIENTS *
FD_HASHTABLE_MODULUS + 1) in the fds struct (inside the struct
libwebsocket_context)
I get refused connections in line 918 of libwebsockets.c

		if (context->fds_count >= MAX_CLIENTS) {
			lwsl_warn("too busy to accept new client\n");
			break;
		}

My mental image of how this works is broken I think, put another way,
how many concurrent sockets are supported by default and why? I think
it could be 3200 but it looks like it is limited to 100 (or I am
missing the point here)

thanks already,
Edwin van den Oetelaar

some info :

Usages of Macro MAX_CLIENTS: [10 occurrences]
libwebsockets
extension-x-google-mux.h
    63:  struct libwebsocket *wsi_muxconns[MAX_CLIENTS];
    81:  struct libwebsocket *wsi_children[MAX_CLIENTS];
libwebsockets.c
    84:  if (context->fd_hashtable[h].length == MAX_CLIENTS - 1) {
  918:  if (context->fds_count >= MAX_CLIENTS) {
1046:  if (context->fds_count >= MAX_CLIENTS) {
1770:  lwsl_info(" MAX_CLIENTS: %u\n", MAX_CLIENTS);
private-libwebsockets.h
  129:  #ifndef MAX_CLIENTS
  130:  #define MAX_CLIENTS 100
  286:  struct libwebsocket *wsi[MAX_CLIENTS + 1];
  294:  struct pollfd fds[MAX_CLIENTS * FD_HASHTABLE_MODULUS + 1];


On Wed, Jan 16, 2013 at 9:36 AM, Edwin van den Oetelaar
<oetelaar.automatisering at gmail.com> wrote:
> Wonderful how fast development is happening here!
> I am testing your patches right now, but my system (gcc version 4.4.3
> (Ubuntu 4.4.3-4ubuntu5.1)) does not like your patch.
>
> +/* some versions of gcc see a false positive here, workaround */
> +#ifdef __GNUC__
> +#pragma GCC diagnostic ignored "-Warray-bounds"
> +#endif
>
> I get fails on compile :
> test-server.c: In function ‘callback_http’:
> test-server.c:257: error: #pragma GCC diagnostic not allowed inside functions
> test-server.c:265: error: #pragma GCC diagnostic not allowed inside functions
>
> I can just remove it for now, but maybe this helps someone else.
>
> Great work, I like it!!
> Edwin van den Oetelaar
>



More information about the Libwebsockets mailing list