[Libwebsockets] Segfault

"Andy Green (林安廸)" andy at warmcat.com
Tue Jan 29 12:20:45 CET 2013


On 29/01/13 19:12, the mail apparently from Jack Mitchell included:
>
>> No worries, I am wondering if the broadcast and forked service stuff
>> is leading people down the wrong path at the moment and should get
>> removed, so it will be interesting to see how you go.
>>
>> -Andy
>
> Sorry to snip this short but I couldn't cope with all the indentation.
>
> I have now implemented a ring buffer but something odd is happening.
> With 1 page open it performs fine, however when I open an additional
> page only some of the data makes it through the socket? I check for a

It seems that when you send data to one websocket client, you mark it at 
that time "done" from your ringbuffer?  Actually it's only "consumed" 
when you sent it to everybody who cares.

-Andy

> choked socket in my LWS_CALLBACK_SERVER_WRITEABLE case but it never
> flags so I don't think it is a choked socket. Do you have any ideas?
>
> So the first page continues to work as expected, the second page only
> receives snippets of data. My code is similar to the following:
>
> Polling loop:
>
> while (1)
>      {
>
>          usleep(50000);
>
>          libwebsocket_service(websocketContext, 0);
>
>           if (!ringBuffer_isEmpty(buff)
>          {
>
>          libwebsocket_callback_on_writable_all_protocol(
>             webSocketProtocol[PROTOCOL_SEND_RECIEVE]);
>
>          }
>      }
>
> LWS_CALLBACK
>
>        case LWS_CALLBACK_SERVER_WRITEABLE:
>
>           do {
>
>              if (lws_send_pipe_choked(wsi))
>              {
>
>                 printf("Pipe was choked, giving it some breathing
> space!\n");
>                 break;
>
>              }
>
>              allConsumed = ringBuffer_consume(psd_sr->buff, jsonString);
>
>              n = sprintf((char*)p, "%s", jsonString);
>
>              n = libwebsocket_write(wsi, p, n, LWS_WRITE_TEXT);
>
>              if (n < 0)
>              {
>
>                 handleError(DB_ERR_SOCKET,"Failed to write to socket!
> (LWS_CALLBACK_SERVER_WRITEABLE)", __FUNCTION__);
>                 return 1;
>
>              }
>
>           } while ( allConsumed != 1 );
>
>           break;
>
> Cheers,
>




More information about the Libwebsockets mailing list