[Libwebsockets] assert in client connection
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:
> - are you using lws from multiple threads?
>I am doing lws_client_connect_via_info() in separate thread. I have
>this decision because client connect will take long time & I need to
>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.
> - does this problem exist in the test client?
>I think so not because test client is doing client connect when not in
> - try setting LWS_MAX_SMP=1 in cmake (and if using multiple service
>I have tried but problem persist.
>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:
>>> I am getting one assert when my client trying to connect with
>>> 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
>>> (did hdr 0, ah 0x5cb540, wl 0, pfd events 0) 1502713721 vs
>>> [2017/08/14 17:58:41:0075] NOTICE: lws_header_table_detach: wsi
>>> ah held 11s, ah.rxpos -1, ah.rxlen -1, mode/state 32
>>> [2017/08/14 17:58:50:5725] ERR: getaddrinfo failed
>>> [2017/08/14 17:58:50:5729] NOTICE: lws_header_table_detach: wsi
>>> ah held 1502713596s, ah.rxpos -1, ah.rxlen -1, mode/state 32
>>> 4,wsi->more_rx_waiting 0
>>> Assertion `pt->ah_count_in_use > 0' failed.
>> The assert is saying there's a mismatch in the count of the number of
>> in use.
>> However I haven't seen that even on v2.0, and the ah counting is all
>> in internal apis in one place.
>> - does this still exist in current master (or v2.3-stable which is
>> 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
>>> Libwebsockets mailing list
>>> Libwebsockets at ml.libwebsockets.org
More information about the Libwebsockets