[Libwebsockets] I may find a bug on lws_write behaviour

雷 鸣 sorayuki at live.com
Fri Feb 28 08:50:47 CET 2020


According to the comment of function 'lws_write' I found it says that

  * The OS may not accept everything you asked to write on the connection.
  * Posix defines POLLOUT indication from poll() to show that the connection
  * will accept more write data, but it doesn't specifiy how much.  It may  
  * accept one byte of whatever you wanted to send.
  * LWS will buffer the remainder automatically, and send it out  
  * During that time, WRITABLE callbacks will be suppressed.

But I found the callback comes when last output buffer block is sent.

I build libwebsockets with libuv and mbedtls in Windows 7 x64, VS2019 by  
   arguments of

I have been with this library for three days in learning how to build a  
   I try limiting the transfer speed to simulate FLV live streaming, using
   lws_set_timer_usecs to control the send-flow.

I found it works with lws_write 1024 bytes per call, but runs into wrong if
   I did it with 65536 bytes per call.

I traced the program flow and found it  ALWAYS request another writeable
   notify (core-net/output.c, line 178) regardless buffered_out is just
   consumed up.

I doubt that it should check buffered_out again before requesting writable
   notify here. And user may or may not request a writeable notify after
   calling lws_write with large block of data.

Could you staff have a look at the logic whether works as expected?

Feb 28th, 2020

More information about the Libwebsockets mailing list