[Libwebsockets] stuck in lws_serve_http_file()

Andy Green andy at warmcat.com
Thu Nov 9 23:26:47 CET 2017



On 11/10/2017 04:17 AM, Srikar Vadlamani wrote:
> After calling*lws_serve_http_file() *from LWS_CALLBACK_HTTP_WRITEABLE, the application 
> is stuck in an infinite loop, below is debug log.
> 
> I am on 2.1-stable latest.

If you think it's a bug in lws (I am not yet sure about that) best to 
try current master or v2.4-stable.

> One thing I can see obviously can cause an issue is the first 
> LWS_CALLBACK_HTTP_FILE_COMPLETION has not been triggered, and I am 
> trying to send another file,

... trying to send another file on another wsi / connection?  That is fine.

You can't ask for a second file on the same connection using http, even 
if you did wait for COMPLETION, sending the file needs to send headers 
and they are gone by then.

-Andy

> logRet0 has been modified between both calls to http_serve_file,
> 
> Let me know if there is something obviously wrong I am doing, or is 
> there an actual bug.
> 
> LOGS BELOW
> 
> *****************************************
> 
> {1003b400,0,29} http unhandled callback
> 
> {1003b400,0,19} http unhandled callback
> 
> inserted SSL accept into fds, trying SSL_accept
> 
> lws_header_table_attach: wsi 0x1003b400: ah (nil) (tsi 0, count = 1) in
> 
> lws_header_table_attach: wsi 0x1003b400: ah 0x10027604: count 2 (on exit)
> 
> No upgrade
> 
> lws_ensure_user_space: 0x1003b400 protocol 0x1001e380
> 
> Method: POST request for '/'
> 
> {1003b400,10042dc0,1}LWS_CALLBACK_FILTER_HTTP_CONNECTION
> 
> no hit
> 
> {1003b400,10042dc0}LWS_CALLBACK_HTTP_DROP_PROTOCOL
> 
> lws_ensure_user_space: 0x1003b400 protocol 0x1001e380
> 
> {1003b400,10042dc0}LWS_CALLBACK_HTTP
> 
> {1003b400,10042dc0}LWS_CALLBACK_HTTP_BODY: {len 545}
> 
> LWS_CALLBACK_HTTP_BODY_COMPLETION
> 
> -------------
> 
> {1003b7a0,1003bac0,1}LWS_CALLBACK_HTTP_FILE_COMPLETION
> 
> HTTPQ:Remove & Free Socket:1003bac0
> 
> [09/Nov/2017:13:13:30 -0600] "POST / http/1.1" 200 71402
> 
>   []: lws_http_transaction_completed: wsi 0x1003b7a0
> 
> lws_http_transaction_completed: 0x1003b7a0: close connection
> 
> completed
> 
> lws_close_free_wsi: shutting down connection: 0x1003b7a0 (sock 9, state 0)
> 
> lws_server_socket_service: wsi 0x1003b7a0 read 0
> 
> lws_server_socket_service: read 0 len
> 
> lws_close_free_wsi: real just_kill_connection: 0x1003b7a0 (sockfd 9)
> 
> remove_wsi_socket_from_fds: removing same prot wsi 0x1003b7a0
> 
> {1003b7a0,1003bac0}LWS_CALLBACK_CLOSED_HTTP
> 
> {1003b7a0,1003bac0,30} http unhandled callback
> 
> ah det due to close
> 
> lws_header_table_detach: wsi 0x1003b7a0: ah 0x10026830 (tsi=0, count = 2)
> 
> lws_header_table_detach: wsi 0x1003b7a0: ah 0x10026830 (tsi=0, count = 1)
> 
> []: {1003ac00,0,17} http unhandled callback
> 
> Accepted 0x1003b5c0 to tsi 0
> 
> {1003b5c0,0,29} http unhandled callback
> 
> []: {1003b5c0,0,19} http unhandled callback
> 
> inserted SSL accept into fds, trying SSL_accept
> 
> lws_header_table_attach: wsi 0x1003b5c0: ah (nil) (tsi 0, count = 1) in
> 
> lws_header_table_attach: wsi 0x1003b5c0: ah 0x10026830: count 2 (on exit)
> 
> (1003b400,10042dc0,0}LWS_CALLBACK_HTTP_WRITEABLE
> 
> (1003b400,10042dc0}LWS_CALLBACK_HTTP_WRITEABLE:sending /opt/logRet0
> 
> []: No upgrade
> 
> lws_ensure_user_space: 0x1003b5c0 protocol 0x1001e380
> 
> Method: POST request for '/'
> 
> {1003b5c0,1003bac0,1}LWS_CALLBACK_FILTER_HTTP_CONNECTION
> 
> no hit
> 
> {1003b5c0,1003bac0}LWS_CALLBACK_HTTP_DROP_PROTOCOL
> 
> []: lws_ensure_user_space: 0x1003b5c0 protocol 0x1001e380
> 
> {1003b5c0,1003bac0}LWS_CALLBACK_HTTP
> 
> {1003b5c0,1003bac0}LWS_CALLBACK_HTTP_BODY: {len 1902}
> 
> lws_read: read_ok, used 2048
> 
> lws_server_socket_service: wsi 0x1003b5c0 read 9
> 
> {1003b5c0,1003bac0}LWS_CALLBACK_HTTP_BODY: {len 9}
> 
> {1003b5c0,1003bac0,1}LWS_CALLBACK_HTTP_BODY_COMPLETION:
> 
> lws_read: read_ok, used 9
> 
> (1003b5c0,1003bac0,0}LWS_CALLBACK_HTTP_WRITEABLE
> 
> (1003b5c0,1003bac0}LWS_CALLBACK_HTTP_WRITEABLE:sending /opt/logRet0
> 
> ********************************* STUCK at 
> lws_send_pipe_choked*************************
> 
> #1  0x0fe8867c in lws_send_pipe_choked (wsi=0x1003b400)
> 
>      at 
> /home/target/libwebsockets-02ad98dbd00c5d15c7768a70a3d1eec24e07714e/lib/lws-plat-unix.c:42
> 
>          fds = {fd = 11, events = 4, revents = 4}
> 
> #2  0x0fe7fdbc in lws_serve_http_file_fragment (wsi=0x1003b400)
> 
>      at 
> /home/target/libwebsockets-02ad98dbd00c5d15c7768a70a3d1eec24e07714e/lib/output.c:567
> 
>         context = (struct lws_context *) 0x1001f010
> 
>          pt = (struct lws_context_per_thread *) 0x1001f030
> 
>          args = {p = 0x1001f030 "", len = 11, max_len = 1, final = 5}
> 
>          amount = 0
> 
> **********************************************************************
> 
> *Srikar Vadlamani*
> 
> 
> 
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> https://libwebsockets.org/mailman/listinfo/libwebsockets
> 



More information about the Libwebsockets mailing list