diff --git a/README.coding.md b/README.coding.md index 1e3f171f..a4da4db7 100644 --- a/README.coding.md +++ b/README.coding.md @@ -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. diff --git a/lib/output.c b/lib/output.c index 3398fd13..f14a4a3f 100644 --- a/lib/output.c +++ b/lib/output.c @@ -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;