mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
lws_write escalate pending truncated to make the
Signed-off-by: Andy Green <andy@warmcat.com>
This commit is contained in:
parent
602d884028
commit
d5466c97ae
2 changed files with 16 additions and 1 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue