Project homepage Mailing List  Warmcat.com  API Docs  Github Mirror 
    npro  
 Modern all-safe Rust Network Protocol library supporting h1, h2, h3, ws, wt sans-IO and with socket IO + tls
git clone https://npro.rs/repo/npro
 
root / assets / tc-wmbedtlsmsvc.svg
Author[]Andy Green <andy@warmcat.com> 2025-09-04 04:34 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-09-04 08:43 UTC
Treef3d27d394a02cd0e81522b0866ff3a70fd53093b   Raw Patch
 
ws: continue to ask for writable even if buflist full
ws: continue to ask for writable even if buflist full
diff --git a/src/web/w-websrv.c b/src/web/w-websrv.c index 9372dbf..6a555b6 100644 --- a/src/web/w-websrv.c +++ b/src/web/w-websrv.c @@ -50,6 +50,37 @@ enum { SAIS_WS_WEBSRV_RX_TASKACTIVITY, }; +/* + * This allows other parts of sai-web to queue a raw buffer to be sent to + * all connected browsers, eg, for load reports. + * + * The flags are lws_write() flags. + */ +void +saiw_ws_broadcast_raw(struct vhd *vhd, const void *buf, size_t len, unsigned int api_ver_min, enum lws_write_protocol flags) +{ + int eff = 0; + + lws_start_foreach_dll(struct lws_dll2 *, p, vhd->browsers.head) { + struct pss *pss = lws_container_of(p, struct pss, same); + int *pi = (int *)((const char *)buf - sizeof(int)); + + eff++; + *pi = (int)flags; + + if (lws_buflist_append_segment(&pss->raw_tx, buf - sizeof(int), len + sizeof(int)) < 0) + lwsl_wsi_err(pss->wsi, "unable to buflist_append"); /* still ask to drain */ + + lws_callback_on_writable(pss->wsi); + + } lws_end_foreach_dll(p); +} + + +/* + * Queue messages to send from sai-web to sai-server + */ + int saiw_websrv_queue_tx(struct lws_ss_handle *h, void *buf, size_t len, unsigned int ss_flags) { @@ -58,13 +89,11 @@ saiw_websrv_queue_tx(struct lws_ss_handle *h, void *buf, size_t len, unsigned in *pi = ss_flags; - // lwsl_ss_notice(h, "sai-web: Queuing from browser -> sai-server"); + // lwsl_ss_notice(h, "sai-web: Queuing sai-web -> sai-server"); // lwsl_hexdump_notice(buf, len); - if (lws_buflist_append_segment(&m->wbltx, buf - sizeof(int), len + sizeof(int)) < 0) { - lwsl_ss_err(h, "failed to append"); - return 1; - } + if (lws_buflist_append_segment(&m->wbltx, buf - sizeof(int), len + sizeof(int)) < 0) + lwsl_ss_err(h, "failed to append"); /* still ask to drain */ if (lws_ss_request_tx(h)) lwsl_ss_err(h, "failed to request tx"); diff --git a/src/web/w-ws-browser.c b/src/web/w-ws-browser.c index ee1f1d4..0489d3d 100644 --- a/src/web/w-ws-browser.c +++ b/src/web/w-ws-browser.c @@ -127,36 +127,6 @@ enum sai_overview_state { SOS_TASKS, }; -/* - * This allows other parts of sai-web to queue a raw buffer to be sent to - * all connected browsers, eg, for load reports. - * - * The flags are lws_write() flags. - */ -void -saiw_ws_broadcast_raw(struct vhd *vhd, const void *buf, size_t len, unsigned int api_ver_min, enum lws_write_protocol flags) -{ - int eff = 0; - - lws_start_foreach_dll(struct lws_dll2 *, p, vhd->browsers.head) { - struct pss *pss = lws_container_of(p, struct pss, same); - int *pi = (int *)((const char *)buf - sizeof(int)); - - // if (pss->js_api_version >= api_ver_min) - { - eff++; - *pi = (int)flags; - - if (lws_buflist_append_segment(&pss->raw_tx, buf - sizeof(int), len + sizeof(int)) < 0) - lwsl_wsi_err(pss->wsi, "unable to buflist_append"); - else { - lws_callback_on_writable(pss->wsi); - } - } - - } lws_end_foreach_dll(p); -} - int sai_sql3_get_uint64_cb(void *user, int cols, char **values, char **name)
Page fetched 0s ago, creation time: 3ms (vhost etag hits: 0%, cache hits: 0%)