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 / scripts / usr-local-svc-method-sai_builder-Solaris
Author[]Andy Green <andy@warmcat.com> 2025-09-03 15:46 UTC
Committer[]Andy Green <andy@warmcat.com> 2025-09-04 08:43 UTC
Treec6cdb80d9ea9954574a025562feaae08b939cf4d   Raw Patch
 
server: central: abandoned task 3m
server: central: abandoned task 3m
diff --git a/src/builder/b-task.c b/src/builder/b-task.c index 0fb8c71..5a00ae3 100644 --- a/src/builder/b-task.c +++ b/src/builder/b-task.c @@ -28,7 +28,7 @@ #include "b-private.h" static int -saib_can_accept_task(sai_task_t *task) +saib_can_accept_task(sai_task_t *task, sai_plat_t *sp) { #if 0 unsigned int free_ram = saib_get_free_ram_kib(); @@ -58,6 +58,10 @@ saib_can_accept_task(sai_task_t *task) } */ #endif + + if (sp->nspawn_owner.count > 6) + return 1; /* nope */ + return 0; /* acceptable */ } @@ -627,7 +631,7 @@ saib_ws_json_rx_builder(struct sai_plat_server *spm, const void *in, size_t len) ns = xns; } lws_end_foreach_dll_safe(d, d1); - if (saib_can_accept_task(task)) { /* not accepted */ + if (saib_can_accept_task(task, sp)) { /* not accepted */ if (saib_queue_task_status_update(sp, spm, task->uuid)) return -1; return 0; diff --git a/src/server/s-central.c b/src/server/s-central.c index 5f30bbb..8f87585 100644 --- a/src/server/s-central.c +++ b/src/server/s-central.c @@ -177,7 +177,7 @@ sais_central_cb(lws_sorted_usec_list_t *sul) if (!vhd->last_check_abandoned_tasks || lws_now_usecs() > (vhd->last_check_abandoned_tasks + - (20 * LWS_USEC_PER_SEC))) { + (3 * 60 * LWS_USEC_PER_SEC))) { sais_central_clean_abandoned(vhd); diff --git a/src/web/w-ws-browser.c b/src/web/w-ws-browser.c index ecd67f4..ee1f1d4 100644 --- a/src/web/w-ws-browser.c +++ b/src/web/w-ws-browser.c @@ -30,36 +30,6 @@ #include "w-private.h" -/* - * 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); -} - extern const lws_struct_map_t lsm_load_report_members[7]; /* @@ -157,6 +127,37 @@ 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) { @@ -821,9 +822,7 @@ again: int *pi = (int *)lws_buflist_get_frag_start_or_NULL(&pss->raw_tx), depi = *pi; char som, eom, rb[1200]; int used, final = 1; - size_t fsl; - - fsl = lws_buflist_next_segment_len(&pss->raw_tx, NULL); + size_t fsl = lws_buflist_next_segment_len(&pss->raw_tx, NULL); /* this is the only buflist user on pss->raw_tx */ used = lws_buflist_fragment_use(&pss->raw_tx, (uint8_t *)rb, sizeof(rb), &som, &eom); @@ -833,9 +832,9 @@ again: final = 0; if (lws_write(pss->wsi, (uint8_t *)rb + ((size_t)som * sizeof(int)), - (size_t)used - ((size_t)som * sizeof(int)), - lws_write_ws_flags((((enum lws_write_protocol)depi) & 0xf), som, final) - ) < 0) { + (size_t)used - ((size_t)som * sizeof(int)), + (lws_ws_sending_multifragment(pss->wsi) ? LWS_WRITE_CONTINUATION : LWS_WRITE_TEXT) | + (!final * LWS_WRITE_NO_FIN)) < 0) { lwsl_wsi_err(pss->wsi, "attempt to write %d failed", (int)used - (int)sizeof(int)); return -1; @@ -1164,7 +1163,6 @@ so_finish: LWS_ARRAY_SIZE(lsm_schema_map_plat_simple), 0, b); if (!js) { - lwsl_err("a\n"); lwsac_unreference(&vhd->builders); return 1; }
Page fetched 0s ago, creation time: 3ms (vhost etag hits: 0%, cache hits: 0%)