Problem
CGI modules need to read the server's quiesce/shutdown state so long-running
handlers can drain promptly at P HTTPD. mvsMF now does this
(mvslovers/mvsmf#179, PR mvslovers/mvsmf#180: the console poll loops check the
flag and return 503 when the server is quiescing).
But struct httpd is opaque to CGIs — httpcgi.h forward-declares it
(typedef struct httpd HTTPD; /* opaque */) and does not expose the flag field
or its masks. So mvsMF reads the flag byte by a hardcoded ABI offset:
#define HTTPD_OFF_FLAG 0x2C /* httpd/include/httpd.h: volatile UCHAR flag */
*(volatile unsigned char *)((char *)httpd + HTTPD_OFF_FLAG) & (0x40 | 0x80)
This mirrors the existing http_get_httpx(h) idiom (*(HTTPX **)((char *)(h) + 8)),
but offset 0x08 is documented in httpcgi.h as an ABI commitment, whereas
offset 0x2C for flag is not. struct httpd has already churned (unused_1c
"was: FILE *stats"). If any field before flag is reordered or resized, every
CGI that hardcodes 0x2C silently reads the wrong byte — missing shutdown (a
worker parks → the SA03 in #122) or spuriously returning 503 in normal
operation.
Proposal
Publish an ABI-committed accessor in httpcgi.h, alongside http_get_httpx:
/* flag is at offset 0x2C in struct httpd -- ABI commitment (like httpx @ 0x08). */
#define http_get_flag(h) (*(volatile unsigned char *)((char *)(h) + 0x2C))
#define HTTPD_FLAG_QUIESCE 0x40 /* stop accepting new requests */
#define HTTPD_FLAG_SHUTDOWN 0x80 /* shutting down now */
(or an equivalent inline/exported function). Then mvsMF drops its local
HTTPD_OFF_FLAG/mask duplication and reads through the committed accessor, so a
future struct httpd layout change updates one place instead of silently
breaking every CGI.
Scope
include/httpcgi.h: add the accessor + masks, and note the ABI commitment in
the comment (as offset 0x08 already is).
- No behavior change in httpd itself; consumers migrate opportunistically.
References
Problem
CGI modules need to read the server's quiesce/shutdown state so long-running
handlers can drain promptly at
P HTTPD. mvsMF now does this(mvslovers/mvsmf#179, PR mvslovers/mvsmf#180: the console poll loops check the
flag and return 503 when the server is quiescing).
But
struct httpdis opaque to CGIs —httpcgi.hforward-declares it(
typedef struct httpd HTTPD; /* opaque */) and does not expose the flag fieldor its masks. So mvsMF reads the flag byte by a hardcoded ABI offset:
This mirrors the existing
http_get_httpx(h)idiom (*(HTTPX **)((char *)(h) + 8)),but offset
0x08is documented inhttpcgi.has an ABI commitment, whereasoffset
0x2Cforflagis not.struct httpdhas already churned (unused_1c"was: FILE *stats"). If any field before
flagis reordered or resized, everyCGI that hardcodes
0x2Csilently reads the wrong byte — missing shutdown (aworker parks → the
SA03in #122) or spuriously returning 503 in normaloperation.
Proposal
Publish an ABI-committed accessor in
httpcgi.h, alongsidehttp_get_httpx:(or an equivalent inline/exported function). Then mvsMF drops its local
HTTPD_OFF_FLAG/mask duplication and reads through the committed accessor, so afuture
struct httpdlayout change updates one place instead of silentlybreaking every CGI.
Scope
include/httpcgi.h: add the accessor + masks, and note the ABI commitment inthe comment (as offset
0x08already is).References
http_get_httpx()ininclude/httpcgi.h