Skip to content
Snippets Groups Projects
Commit d5466c97 authored by Andy Green's avatar Andy Green
Browse files

lws_write escalate pending truncated to make the


Signed-off-by: default avatarAndy Green <andy@warmcat.com>
parent 602d8840
No related branches found
No related tags found
No related merge requests found
......@@ -36,6 +36,19 @@ with the socket closing and the `wsi` freed.
Websocket write activities should only take place in the
`LWS_CALLBACK_SERVER_WRITEABLE` callback as described below.
[This network-programming necessity to link the issue of new data to
the peer taking the previous data is not obvious to all users so let's
repeat that in other words:
***ONLY DO LWS_WRITE FROM THE WRITEABLE CALLBACK***
There is another network-programming truism that surprises some people which
is if the sink for the data cannot accept more:
***YOU MUST PERFORM RX FLOW CONTROL***
See the mirror protocol implementations for example code.
Only live connections appear in the user callbacks, so this removes any
possibility of trying to used closed and freed wsis.
......
......@@ -109,7 +109,9 @@ int lws_issue_raw(struct lws *wsi, unsigned char *buf, size_t len)
if (wsi->trunc_len && (buf < wsi->trunc_alloc ||
buf > (wsi->trunc_alloc + wsi->trunc_len +
wsi->trunc_offset))) {
lwsl_err("****** %x Sending new, pending truncated ...\n", wsi);
lwsl_err("****** %p: Sending new, pending truncated ...\n"
" It's illegal to do an lws_write outside of\n"
" the writable callback: fix your code", wsi);
assert(0);
return -1;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment