- errnox.h: add E_XCE_NOT_READY and E_XCE_STANDBY error codes with extern int XCE_ERR_NOT_READY / XCE_ERR_STANDBY runtime variables - ha.h: declare ha_dispatch_gate(ha_state_t *, int opcode) - ha.c: define XCE_ERR_* variables; initialize heartbeat_seen semaphore and primary_ctrl_fd = -1 in ha_init(); sem_destroy in ha_fini(); implement ha_dispatch_gate() with allowlist for CTRL_INIT/CTRL_ELECTING (only OP_requestVote and OP_probeConfigTag pass) and CTRL_STANDBY (replication, election, and housekeeping ops pass; primary-only ops return -XCE_ERR_STANDBY) - cluster.c: wire ha_dispatch_gate() in myreq_handler() before opcode switch; gate failure sends error reply and returns early All 393 unit tests pass. Satisfies requirements 1.3 and 1.4.
34 lines
984 B
C
34 lines
984 B
C
#if !defined(__XCE_ERRNOX_H__)
|
|
|
|
#define __XCE_ERRNOX_H__ 1
|
|
|
|
#include <errno.h>
|
|
#include <stddef.h>
|
|
#include <string.h>
|
|
|
|
#define XCE_ERRNO_BASE (10001)
|
|
|
|
enum {
|
|
E_XCE_BAD_JOB = XCE_ERRNO_BASE,
|
|
E_XCE_BAD_WORKER,
|
|
E_XCE_DUP_JOB,
|
|
E_XCE_DUP_WORKER,
|
|
E_XCE_BAD_OPCODE,
|
|
E_XCE_BAD_ROLE,
|
|
E_XCE_BAD_RES,
|
|
E_XCE_BAD_QUEUE,
|
|
E_XCE_BAD_GROUP,
|
|
E_XCE_INTERNAL,
|
|
E_XCE_NOMASTER, /* Standby has no known primary — client should retry */
|
|
E_XCE_REDIRECT, /* Standby is redirecting client to primary */
|
|
E_XCE_NOT_READY, /* Controller in CTRL_INIT or CTRL_ELECTING state */
|
|
E_XCE_STANDBY, /* Controller in CTRL_STANDBY; op is primary-only */
|
|
E_XCE_MAX
|
|
};
|
|
|
|
/* HA dispatch gate error variables — defined in ha.c, declared here so all
|
|
* dispatch call sites that include errnox.h get the right names. */
|
|
extern int XCE_ERR_NOT_READY; /* == E_XCE_NOT_READY */
|
|
extern int XCE_ERR_STANDBY; /* == E_XCE_STANDBY */
|
|
|
|
#endif
|