[Libwebsockets] Truncated send handled by user not working as expected

Roger Light roger at atchoo.org
Mon Aug 18 11:00:17 CEST 2014


Hi,

>>libwebsockets was handling truncates and consequent calls to fail
>>assertion at line 112.
>
> I don't see why it fails that assertion though, did you understand why during
> your debugging?  Not having sent anything and buffer the whole thing should
> have been okay.

I believe I could trigger the assert easily on Linux by calling
libwebsocket_write() without checking lws_send_pipe_choked() first. I
was checking that the socket was available to write, then attempting
to write as much as possible until it blocked. So crudely, and iirc:

case LWS_CALLBACK_SERVER_WRITEABLE:
    /* Gives assert */
    while(have_data){
        count = libwebsockets_write(len);
        if(count < 0) return 0;
        if(wlen != len) break;
    }

case LWS_CALLBACK_SERVER_WRITEABLE:
    /* No assert */
    while(have_data && !lws_send_pipe_choked()){
        count = libwebsockets_write(len);
        if(count < 0) return 0;
        if(wlen != len) break;
    }

I've been meaning to send an email about it but hadn't got round to
it, sorry. I've just done some quick testing haven't been able to
reproduce it, but I do remember that the problem occurred more
frequently on my slower box that I was connecting to over wifi,
compared to the powerful box I'm using now and connecting to
localhost. I can jump back through history to try and isolate the
problem if necessary.

Cheers,

Roger



More information about the Libwebsockets mailing list