diff --git a/src/builder/b-conf.c b/src/builder/b-conf.c
index 70025f0..b343609 100644
--- a/src/builder/b-conf.c
+++ b/src/builder/b-conf.c
@@ -71,6 +71,7 @@ static const char * const paths[] = {
"platforms[].env[].*",
"platforms[].env[]",
"platforms[].servers",
+ "platforms[].job-limit",
"platforms[]",
};
@@ -80,6 +81,7 @@ enum enum_paths {
LEJPM_PLATFORMS_ENV_ITEM,
LEJPM_PLATFORMS_ENV,
LEJPM_PLATFORMS_SERVERS,
+ LEJPM_PLATFORMS_JOB_LIMIT,
LEJPM_PLATFORMS,
};
@@ -116,6 +118,8 @@ saib_conf_cb(struct lejp_ctx *ctx, char reason)
lws_strncpy(a->sai_plat->lws_hash, LWS_BUILD_HASH,
sizeof(a->sai_plat->lws_hash));
+ a->sai_plat->job_limit = 0;
+
lws_dll2_add_tail(&a->sai_plat->sai_plat_list,
&a->builder->sai_plat_owner);
break;
@@ -132,6 +136,10 @@ saib_conf_cb(struct lejp_ctx *ctx, char reason)
if (!(reason & LEJP_FLAG_CB_IS_VALUE) || !ctx->path_match)
return 0;
+ if (ctx->path_match - 1 == LEJPM_PLATFORMS_JOB_LIMIT) {
+ a->sai_plat->job_limit = (unsigned int)atoi(ctx->buf);
+ lwsl_err("%s: LEJPM_PLATFORMS_JOB_LIMIT %u\n", __func__, a->sai_plat->job_limit);
+ }
if (reason != LEJPCB_VAL_STR_END)
return 0;
diff --git a/src/builder/b-task.c b/src/builder/b-task.c
index 85a8a00..188a793 100644
--- a/src/builder/b-task.c
+++ b/src/builder/b-task.c
@@ -193,7 +193,7 @@ saib_can_accept_task(sai_task_t *task, sai_plat_t *sp)
*/
#endif
- if (sp->nspawn_owner.count > 6)
+ if (sp->nspawn_owner.count >= (sp->job_limit ? sp->job_limit : 6u))
return 1; /* nope */
return 0; /* acceptable */
@@ -660,7 +660,7 @@ saib_ws_json_rx_builder(struct sai_plat_server *spm, const void *in, size_t len)
sai_cancel_t *can;
sai_rebuild_t *reb;
sai_task_t *task;
- int n, m;
+ int n, m, en;
char *p;
/*
@@ -927,22 +927,33 @@ saib_ws_json_rx_builder(struct sai_plat_server *spm, const void *in, size_t len)
n += lws_snprintf(ns->inp + n, sizeof(ns->inp) - (unsigned int)n, "jobs%c",
csep);
lws_filename_purify_inplace(ns->inp);
- if (mkdir(ns->inp, 0755) && errno != EEXIST)
+ if (mkdir(ns->inp, 0755) && errno != EEXIST) {
+ en = errno;
+ lwsl_err("%s: mkdir %s -> errno %d\n", __func__, ns->inp, en);
goto ebail;
+ }
n += lws_snprintf(ns->inp + n, sizeof(ns->inp) - (unsigned int)n, "%s%c",
ns->fsm.ovname, csep);
lws_filename_purify_inplace(ns->inp);
- if (mkdir(ns->inp, 0755) && errno != EEXIST)
+ if (mkdir(ns->inp, 0755) && errno != EEXIST) {
+ en = errno;
+ lwsl_err("%s: mkdir %s -> errno %d\n", __func__, ns->inp, en);
+
goto ebail;
+ }
/*
* Create a pending upload dir to mv artifacts into while
* we get on with the next job.
*/
lws_snprintf(ns->inp + n, sizeof(ns->inp) - (unsigned int)n, "../.sai-uploads");
- if (mkdir(ns->inp, 0755) && errno != EEXIST)
+ if (mkdir(ns->inp, 0755) && errno != EEXIST) {
+ en = errno;
+ lwsl_err("%s: mkdir %s -> errno %d\n", __func__, ns->inp, en);
+
goto ebail;
+ }
/*
* Snip that last bit off so ns->inp is the fully qualified
* builder instance base dir
diff --git a/src/common/include/private.h b/src/common/include/private.h
index e088f87..89561ee 100644
--- a/src/common/include/private.h
+++ b/src/common/include/private.h
@@ -438,6 +438,7 @@ typedef struct sai_plat {
uint64_t last_seen; /* unix time */
int powering_up; /* 1 = sai-power is booting it */
int powering_down;
+ unsigned int job_limit;
char windows;
diff --git a/src/server/s-notification.c b/src/server/s-notification.c
index cab06c0..cbe44b3 100644
--- a/src/server/s-notification.c
+++ b/src/server/s-notification.c
@@ -638,6 +638,17 @@ sai_saifile_lejp_cb(struct lejp_ctx *ctx, char reason)
return 0;
}
+ if (ctx->path_match - 1 == LEJPNSAIF_PLAT_BUILD_STAGE &&
+ reason == LEJPCB_VAL_STR_START) {
+ n = strlen(sn->platbuild);
+
+ if (n && n < sizeof(sn->platbuild) - 2) {
+ sn->platbuild[n++] = '\n';
+ sn->platbuild[n] = '\0';
+ }
+ return 0;
+ }
+
/* we only match on the prepared path strings */
if (!(reason & LEJP_FLAG_CB_IS_VALUE) || !ctx->path_match)
return 0;
@@ -701,20 +712,13 @@ sai_saifile_lejp_cb(struct lejp_ctx *ctx, char reason)
* The overall build script for this platform
* is appended into the temp sn.platbuild
*/
- if (reason != LEJPCB_VAL_STR_END)
- break;
lwsl_err("%s: LEJPNSAIF_PLAT_BUILD_STAGE: %.*s\n", __func__, (int)ctx->npos, (const char *)ctx->buf);
n = strlen(sn->platbuild);
- if (n < sizeof(sn->platbuild) - 2) {
- if (n) {
- sn->platbuild[n++] = '\n';
- sn->platbuild[n] = '\0';
- }
+ if (n < sizeof(sn->platbuild) - 2 && ctx->npos)
lws_strnncpy(sn->platbuild + n, ctx->buf, ctx->npos,
sizeof(sn->platbuild) - n);
- }
break;
case LEJPNSAIF_PLAT_BUILD_ELEMENT:
diff --git a/src/server/s-task.c b/src/server/s-task.c
index 1ee0e38..28408c0 100644
--- a/src/server/s-task.c
+++ b/src/server/s-task.c
@@ -1072,6 +1072,9 @@ sais_activity_cb(lws_sorted_usec_list_t *sul)
lws_start_foreach_dll(struct lws_dll2 *, dt, o_tasks.head) {
sai_task_t *t = lws_container_of(dt, sai_task_t, list);
+ if (lws_ptr_diff_size_t(end, p) < 100)
+ break;
+
if (now - (lws_usec_t)(t->last_updated * LWS_US_PER_SEC) > 10 * LWS_US_PER_SEC)
cat = 1;
else if (now - (lws_usec_t)(t->last_updated * LWS_US_PER_SEC) > 3 * LWS_US_PER_SEC)
diff --git a/src/server/s-websrv.c b/src/server/s-websrv.c
index 16e2fa8..a0a4635 100644
--- a/src/server/s-websrv.c
+++ b/src/server/s-websrv.c
@@ -767,21 +767,12 @@ websrvss_ws_tx(void *userobj, lws_ss_tx_ordinal_t ord, uint8_t *buf,
if (!used)
return LWSSSSRET_TX_DONT_SEND;
- // if (!eom) {
- // lwsl_err("%s: eom is not set on bltx buflist!\n", __func__);
- // lwsl_hexdump_notice(buf, (size_t)used);
- // }
-
- if ((size_t)used < fsl) {
- lwsl_ss_warn(m->ss, "srv->web: clearing eom since used %d < fsl %d\n", (int)used, (int)fsl);
+ if ((size_t)used < fsl)
eom = 0; /* because we still be back */
- }
*flags = (som ? LWSSS_FLAG_SOM : 0) | (eom ? LWSSS_FLAG_EOM : 0);
*len = (size_t)used;
- lwsl_ss_warn(m->ss, "srv -> web: len %d flags %d", (int)*len, (int)*flags);
-
if (m->bltx)
return lws_ss_request_tx(m->ss);