[Libwebsockets] Question about max_fd check in insert_wsi_socket_into_fds

Subi S S subi.s at cambiumnetworks.com
Tue Apr 28 17:28:01 CEST 2015

Thanks Andy 

-----Original Message-----
From: Andy Green [mailto:andy.green at linaro.org] On Behalf Of Andy Green
Sent: 28 April 2015 19:00
To: Subi S S; libwebsockets at ml.libwebsockets.org
Subject: Re: [Libwebsockets] Question about max_fd check in insert_wsi_socket_into_fds

On 28 April 2015 20:26:04 GMT+08:00, Subi S S <subi.s at cambiumnetworks.com> wrote:
>insert_wsi_socket_into_fds(struct libwebsocket_context *context,
>                                              struct libwebsocket *wsi) 
>        struct libwebsocket_pollargs pa = { wsi->sock, LWS_POLLIN, 0 };
>        if (context->fds_count >= context->max_fds) {
>                lwsl_err("Too many fds (%d)\n", context->max_fds);
>                return 1;
>        }
>if (wsi->sock >= context->max_fds) { --------------------------------> 
>Whether this check is really needed, in some system I found wsi->sock 
>is really high , is it safe to remove this ?
>                lwsl_err("Socket fd %d is too high (%d)\n",
>                                          wsi->sock, context->max_fds);
>                return 1;
>        }

In current sources, this is protected with an #ifndef _WIN32... which is the only platform we know to use opaque handles for socket handles... if your sources are too old to have that, and you are on Windows, you should update to the latest or think about adding this patch



>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org

More information about the Libwebsockets mailing list