[Libwebsockets] close changes between 2.2 and 2.3 stable

Mario Theodoridis mario.theodoridis at regify.com
Thu Aug 24 15:16:39 CEST 2017


Hello everyone,

i just upgraded to the v2.3-stable branch from v2.2-stable and am 
noticing some changes on the close behaviour of lwsws.

I have the following code in my callback

     ....snip...
     case LWS_CALLBACK_RECEIVE:
         stat = handleRequest(s, in, len);
         if (stat != LWS_CLOSE_STATUS_NOSTATUS) {
             lws_close_reason(wsi, stat, CLOSE_ERROR, CLOSE_ERROR_LEN);
             return -1;
         }
         break;
     ....snip...
     return 0;


In 2.2 this replied with a close and things worked. In 2.3 the close 
frame is never sent and the connection seems to just get closed instead.

Am i doing my closes wrong, or is there something else i need to make 
this work again?

2.2 server log looks like

interpret_incoming_packet has bailed
sending close indication...
lws_set_timeout: 0x987ecc8: 1 secs
sent close indication, awaiting ack
lws_uv_idle: done stop
lws_read: incoming len 28  state 9
lws_interpret_incoming_packet: received 28 byte packet
spill on lws-regibox-protocol
seen client close ack
interpret_incoming_packet has bailed
lws_close_free_wsi: shutting down connection: 0x987ecc8 (sock 11, state 9)
lws_close_free_wsi: real just_kill_connection: 0x987ecc8 (sockfd 11)
remove_wsi_socket_from_fds: removing same prot wsi 0x987ecc8
have prev 0x984a1bc, setting him to our next (nil)
remove_wsi_socket_from_fds: wsi=0x987ecc8, sock=11, fds pos=2, end guy 
pos=3, endfd=0
lws_close_free_wsi: doing LWS_CALLBACK_HTTP_DROP_PROTOCOL for 0x987ecc8 
prot lws-regibox-protocol
callback_lws_regibox: LWS_OTHER_code 50
calling back CLOSED
closeCon: LWS_CALLBACK_CLOSED
lws_close_free_wsi: lws_libuv_closehandle: wsi 0x987ecc8
ah det due to close
lws_header_table_detach: wsi 0x987ecc8: ah (nil) (tsi=0, count = 0)
lws_header_table_detach: wsi 0x987ecc8: ah (nil) (tsi=0, count = 0)
lws_free_wsi: 0x987ecc8, remaining wsi 2
lws_uv_idle: done stop

while 2.3 looks like


interpret_incoming_packet has bailed
lws_close_free_wsi: 0x9d48b90
sending close indication...
waiting for chance to send close
lws_set_timeout: 0x9d48b90: 2 secs
xxx
sending close packet
lws_set_timeout: 0x9d48b90: 1 secs
sent close indication, awaiting ack
lws_uv_timeout_cb
lws_uv_timeout_cb
wsi 0x9d48b90: TIMEDOUT WAITING on 6 (did hdr 1, ah (nil), wl 0, pfd 
events 5) 1503579082 vs 1503579081
lws_close_free_wsi: 0x9d48b90
lws_close_free_wsi: real just_kill_connection: 0x9d48b90 (sockfd 15)
lws_same_vh_protocol_remove: removing same prot wsi 0x9d48b90
have prev 0x9d1b374, setting him to our next (nil)
remove_wsi_socket_from_fds: wsi=0x9d48b90, sock=15, fds pos=2, end guy 
pos=3, endfd=0
lws_close_free_wsi: doing LWS_CALLBACK_HTTP_DROP_PROTOCOL for 0x9d48b90 
prot lws-regibox-protocol
callback_lws_regibox: LWS_OTHER_code 50
calling back CLOSED
closeCon: LWS_CALLBACK_CLOSED
lws_close_free_wsi: lws_libuv_closehandle: wsi 0x9d48b90
ah det due to close
lws_free_wsi: 0x9d48b90, remaining wsi 2

I already diffed the 2 branches, but was a little overwhelmed with the 
code changes to find an answer there.


-- 
Mit Freundlichen Grüßen / Regards

Mario Theodoridis

regify GmbH
Römerstrasse 39 | D-78183 Hüfingen
Amtsgericht Freiburg HRB 709343
Telefon: +49 771 8978 4238



More information about the Libwebsockets mailing list