[Libwebsockets] Some more patches to add..

Andy Green andy.green at linaro.org
Tue Oct 20 06:25:45 CEST 2015


On 20 October 2015 at 12:04, Ash 20001 <ash20001 at hotmail.com> wrote:
> Hello Andy,
> Did you get these two issues below?
>
> ________________________________
> From: andy.green at linaro.org
> To: libwebsockets at ml.libwebsockets.org
> Date: Tue, 13 Oct 2015 23:46:53 -0700
> Subject: [Libwebsockets] Some more patches to add..
>
>
> HI Andy,
> Since you are back, I have some more bug fixes that are easier for me to
> just tell you here and you can perhaps commit them?
>
> 1. server.c
> if (strcasecmp(http_conn_str, "close"))
> connection_type = HTTP_CONNECTION_CLOSE;
> should be
> if (!strcasecmp(http_conn_str, "close"))
> connection_type = HTTP_CONNECTION_CLOSE;

I pushed this one thanks.  It looks like it chose
HTTP_CONNECTION_CLOSE a lot... but that's maybe inefficient rather
than any other problem.  But thanks for the fix.

> 2. context.c
> SSL is inited for plain HTTP server.
>
>                 if (lws_context_init_server_ssl(info, context))
>                         goto bail;
>
>                 if (lws_context_init_client_ssl(info, context))
>                         goto bail;
>
> I am not sure why we need this code for a pure HTTP server since there is no
> SSL. But anyway these functions call SSL_library_init() which is not
> reentrant, so in my case, i had one thread host an HTTP server and another
> host an HTTPS server and was running into all sorts of reentrancy issues
> because SSL_library_init was called simultaneously.

Lws just isn't trying to be threadsafe, it has no locking at all.  It
seems by following the relatively small problems found by adventureous
thread warriors such as yourself that it anyway can be used that way
if with care.

At any rate README.coding says

Libwebsockets is singlethreaded
-------------------------------

Directly performing websocket actions from other threads is not allowed.
Aside from the internal data being inconsistent in `forked()` processes,
the scope of a `wsi` (`struct websocket`) can end at any time during service
with the socket closing and the `wsi` freed.

I added some more documentation there specifically warning against
simultaneously creating contexts.

-Andy

>
>
> _______________________________________________ Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets



More information about the Libwebsockets mailing list