[Libwebsockets] Returning -1 from client callback has no effect (LWS_CALLBACK_CLOSED isn't invoked)

bjorka adinov adinov.bjorka at gmail.com
Thu Mar 20 05:29:50 CET 2014


It works, many thanks


On Mon, Mar 17, 2014 at 5:45 PM, "Andy Green (林安廸)" <andy at warmcat.com>wrote:

> On 17/03/14 14:46, the mail apparently from bjorka adinov included:
>
>  Hello Andy,
>>
>> Thanks for the response.
>>
>> I'm still having trouble here as the LWS_CALLBACK_CLOSED still isn't
>> invoked even though I have returned -1 from the client callback. When I
>> checked the diffstat and revised libwebsocket_client_rx_sm function, I
>> found out that it will return 1 if the client callback returns non zero
>> including returning -1. It seems that returning 1 still won't close the
>> socket. I tried to modify libwebsocket_client_rx_sm code a little so it
>> will return -1 when client callback returns -1. This seems to work but I
>> don't know about the implication on other parts of the library. Any
>> advicess will be much appreciated.
>>
>
> Does this help?
>
> http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=
> 564056d27cf2bff345b04b7340ad163e5b77345f
>
> The server stuff had the same confusion about <0 or >0 and got changed a
> while back to basically be a bool, 0 means keep living and nonzero means
> close.
>
> There's no use of the return code other than check for wanting to close,
> so this should solve it.
>
> -Andy
>
>
>  Thank you
>>
>>
>>
>> On Sat, Mar 15, 2014 at 8:50 AM, "Andy Green (林安廸)" <andy at warmcat.com
>> >wrote:
>>
>>  On 14/03/14 14:00, the mail apparently from bjorka adinov included:
>>>
>>>   I'm afraid if I do the patching I will mess the code up, so I hope you
>>>
>>>> spare some time to look at it, and I appreciate it.
>>>>
>>>>
>>> This seems to solve it
>>>
>>> http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/commit/?id=
>>> 5ac7e7ad5a117699263fe283bc1e123aa2c66352
>>>
>>> At least with the test client, closing the connection on client receive
>>> callback provoked a zlib data error on inflate... I couldn't see how this
>>> was a real problem so I quietened the report to lwsl_info at the same
>>> time.
>>>
>>> -Andy
>>>
>>>
>>>   Thank you
>>>
>>>>
>>>>
>>>> On Thu, Mar 13, 2014 at 9:01 PM, Andy Green <andy at warmcat.com> wrote:
>>>>
>>>>
>>>>
>>>>> On 13 March 2014 17:47:49 GMT+08:00, bjorka adinov <
>>>>> adinov.bjorka at gmail.com> wrote:
>>>>>
>>>>>  Hello Andy,
>>>>>>
>>>>>> I'm using libwebsockets 1.23. On server side whenever I return -1 from
>>>>>> the
>>>>>> callback, the connection is closed and LWS_CALLBACK_CLOSED is invoked
>>>>>> on
>>>>>> both side. But when  I return -1 from client side callback, nothing
>>>>>> happened. LWS_CALLBACK_CLOSED is not invoked. When I debug the code,
>>>>>> it
>>>>>> seems the callback function is called from function
>>>>>> libwebsocket_client_rx_sm (client-parser.c) line 396 and the return
>>>>>> value
>>>>>>
>>>>>>  >from the callback function is not used ? Is this by design ? Am I
>>>>>
>>>>>  missing
>>>>>> something ?
>>>>>>
>>>>>>
>>>>> It's probably simply missing the code to take care of it, the server
>>>>> code
>>>>> gets a lot more attention.
>>>>>
>>>>> Patch is welcome or if you can wait until Saturday I will take a look
>>>>> at
>>>>> it.
>>>>>
>>>>> -Andy
>>>>>
>>>>>   Thanks a lot
>>>>>
>>>>>>
>>>>>>
>>>>>> ------------------------------------------------------------
>>>>>> ------------
>>>>>>
>>>>>> _______________________________________________
>>>>>> Libwebsockets mailing list
>>>>>> Libwebsockets at ml.libwebsockets.org
>>>>>> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20140320/6bcd8d85/attachment-0001.html>


More information about the Libwebsockets mailing list