fix(controller): set c->running in cluster_run so HA primary streams joblist/workerlist

cluster_start (which set c->running) is orphaned on the HA myapp_run path, so
the running flag was never set on HA nodes — check_controller() treated the
primary as shutting down and zeroed joblist/workerlist reply chunks. Own the
flag lifecycle in cluster_run, symmetric with the c->running=0 on shutdown.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rongsong Shen 2026-06-16 03:38:55 +00:00
parent a735a880ae
commit 646aa69aa8
3 changed files with 47 additions and 0 deletions

View file

@ -240,6 +240,14 @@ int xce_decode(io_packet_t* pkt, xce_request_t* req)
void init_reply_by_req(xce_reply_t* reply, xce_request_t* req)
{
/* Zero the whole reply first. Callers declare `xce_reply_t reply;` on the
* stack and only populate the fields they need (status / data_which / data),
* leaving the common trailer fields (redirect_host, redirect_port) untouched.
* The generated encode_RequestReply reads redirect_host unconditionally
* (gated only on != NULL), so a stale stack value there is dereferenced via
* strlen() — a heap-use-after-free when the garbage aliases a freed capnp
* segment. Clearing here makes every reply path safe by construction. */
memset(reply, 0, sizeof(*reply));
reply->seq = req->seq;
reply->opcode = req->opcode;
}