[Libwebsockets] assert in client connection

Andy Green andy at warmcat.com
Mon Aug 21 15:23:30 CEST 2017



On August 21, 2017 8:26:35 PM GMT+08:00, Vijay Khurdiya <vijay.khurdiya at gmail.com> wrote:
>Hi Andy,
>
>  - are you using lws from multiple threads?
>
>I am doing lws_client_connect_via_info() in separate thread. I have
>taken
>this decision because client connect will take long time & I need to
>keep
>serving in service loop for server.

That's not a "decision" you can take.  You can't call lws apis from a different thread than the one doing the service; there is no locking inside lws.

Client connect is asynchronous in lws.  You only start the process by calling the api, it returns quickly without blocking.  Future lws 'service' progresses the client connection step by step without blocking., and callbacks appear according to what's happening.

If you want that decision to happen from a different thread, you must handle the communication from the other thread (eg set a volatile flag) and handle the request / call the lws api from the lws service thread.

-Andy

>  - does this problem exist in the test client?
>
>I think so not because test client is doing client connect when not in
>service loop.
>
>  - try setting LWS_MAX_SMP=1 in cmake (and if using multiple service
>
>threads, don't)
>I have tried but problem persist.
>
>Thanks
>
>On Thu, Aug 17, 2017 at 5:23 AM, Andy Green <andy at warmcat.com> wrote:
>
>>
>>
>> On 08/17/2017 12:42 AM, Vijay Khurdiya wrote:
>>
>>> Hi,
>>>
>>> I am getting one assert when my client trying to connect with
>server.
>>> Could you please give me hint what was wrong which cause assert.
>>>
>>> Please find below snapshot of lws log.
>>>
>>> [2017/08/14 17:58:41:0070] NOTICE: wsi 0x5aaae0: TIMEDOUT WAITING on
>25
>>> (did hdr 0, ah 0x5cb540, wl 0, pfd events 0) 1502713721 vs
>1502713720
>>>
>>> [2017/08/14 17:58:41:0075] NOTICE: lws_header_table_detach: wsi
>0x5aaae0:
>>> ah held 11s, ah.rxpos -1, ah.rxlen -1, mode/state 32
>4,wsi->more_rx_waiting
>>> 0
>>>
>>> [2017/08/14 17:58:50:5725] ERR: getaddrinfo failed
>>>
>>> [2017/08/14 17:58:50:5729] NOTICE: lws_header_table_detach: wsi
>0x5aaae0:
>>> ah held 1502713596s, ah.rxpos -1, ah.rxlen -1, mode/state 32
>>> 4,wsi->more_rx_waiting 0
>>>
>>> /libwebsockets/2.0.3-r0/git/lib/parsers.c:313:
>lws_header_table_detach:
>>> Assertion `pt->ah_count_in_use > 0' failed.
>>>
>>
>> The assert is saying there's a mismatch in the count of the number of
>ah
>> in use.
>>
>> However I haven't seen that even on v2.0, and the ah counting is all
>done
>> in internal apis in one place.
>>
>>  - does this still exist in current master (or v2.3-stable which is
>nearly
>> identical atm)?
>>
>>  - are you using lws from multiple threads?
>>
>>  - does this problem exist in the test client?
>>
>>  - try setting LWS_MAX_SMP=1 in cmake (and if using multiple service
>> threads, don't)
>>
>> I eyeballed the 2.0.3 code but it cleans up after getaddrinfo failure
>> normally.
>>
>> -Andy
>>
>>
>>>
>>> _______________________________________________
>>> Libwebsockets mailing list
>>> Libwebsockets at ml.libwebsockets.org
>>> https://libwebsockets.org/mailman/listinfo/libwebsockets
>>>
>>>



More information about the Libwebsockets mailing list