[Libwebsockets] libuv and clean shutdown

Mateusz Stępień mateusz.stepien at netrounds.com
Fri Mar 1 14:34:57 CET 2019


On 3/1/19 12:51 PM, Andy Green wrote:
> I pushed a one-line patch on master that should fix it.
Thank you for the quick response, that fixes the issue with SIGTERM 
handling.

However, I can't seem to find a way to cleanly close the process from 
within the callback. In case of lws-minimal-ws-client-echo example, if 
there's no server to be connected to, or if the server closed the 
connection, I would like the process to exit in a clean way. Instead I 
can see that there's a 1 sec timer still keeping the event loop busy:

     ERR: CLIENT_CONNECTION_ERROR: (null)
     INFO: lws_cancel_service
     DEBUG: __lws_close_free_wsi: real just_kill_connection: 
0x56523085c5b0 (sockfd 12)
     DEBUG: elops_io_uv: 0x56523085c5b0: -2147483637
     DEBUG: __remove_wsi_socket_from_fds: wsi=0x56523085c5b0, skt=12, 
fds pos=1, end guy pos=2, endfd=0
     DEBUG: elops_io_uv: 0x56523085c5b0: 11
     DEBUG: lwsi_set_state(0x56523085c5b0, 0x1000001e)
     DEBUG: elops_wsi_logical_close_uv: lws_libuv_closehandle: wsi 
0x56523085c5b0
     DEBUG: lws_libuv_closehandle: 0x56523085c5b0
     INFO: __lws_close_free_wsi: 0x56523085c5b0: caller: 
close_and_handled uv repeat test
     INFO: lws_libuv_closewsi: 0x56523085c5b0
     DEBUG: __lws_close_free_wsi_final: wsi 0x56523085c5b0: fd 12
     INFO: __lws_header_table_detach: wsi 0x56523085c5b0: ah 
0x565230896bc0 (tsi=0, count = 1)
     INFO: __lws_header_table_detach: nobody usable waiting
     INFO: _lws_destroy_ah: freed ah 0x565230896bc0 : pool length 0
     INFO: __lws_header_table_detach: wsi 0x56523085c5b0: ah 
0x565230896bc0 (tsi=0, count = 0)
     INFO: rops_destroy_role_h1: ah det due to close
     INFO: lws_vhost_unbind_wsi: vh default: count_bound_wsi 0
     DEBUG: __lws_free_wsi: 0x56523085c5b0, remaining wsi 1
     INFO: lws_libuv_closewsi: sa left 8: dyn left: 1 (rk 0)
     DEBUG: lws_uv_timeout_cb
     DEBUG: lws_uv_timeout_cb
     DEBUG: lws_uv_timeout_cb
     ...

Is there any lws API available to close the event loop?

Thanks,
Mateusz


More information about the Libwebsockets mailing list