[Libwebsockets] Question about max_fd check in insert_wsi_socket_into_fds

Andy Green andy at warmcat.com
Tue Apr 28 15:30:00 CEST 2015



On 28 April 2015 20:26:04 GMT+08:00, Subi S S <subi.s at cambiumnetworks.com> wrote:
>int
>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

http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=229bfec9486d239fe82487a50c7e0ae1e6c5a0f1

-Andy

>Thanks,
>Subi
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Libwebsockets mailing list
>Libwebsockets at ml.libwebsockets.org
>http://ml.libwebsockets.org/mailman/listinfo/libwebsockets




More information about the Libwebsockets mailing list