feat(election-iomgr-refactor): add on_connected fire-once callback to endpoint_t

Add void (*on_connected)(endpoint_t *ep) field to endpoint_t with
endpoint_set_on_connected() helper. io_handler fires it exactly once
immediately after ssl_handshake_done=1 then nulls the pointer.

Enables ha_start_election_async to send OP_requestVote as soon as
the TLS handshake with a peer completes — no blocking SSL_connect.

6 new unit tests pass; controller suite 1/1 OK.
This commit is contained in:
Rongsong Shen 2026-05-30 07:34:08 +00:00
parent 4737b0f8a3
commit c3caab49a6
5 changed files with 205 additions and 1 deletions

View file

@ -64,7 +64,7 @@ typedef struct {
size_t iocount;
} io_fsm_t;
typedef struct {
typedef struct endpoint_t {
mylock_t lock;
iomgr_t* iomgr;
SSL* ssl;
@ -85,6 +85,7 @@ typedef struct {
err_handler_t err_handler;
time_t ts_last_in;
time_t ts_last_out;
void (*on_connected)(struct endpoint_t *ep); /* fire-once; called in iomgr thread after ssl_handshake_done=1 */
} endpoint_t;
#define INVOKE_MSG_HANDLER(ep) \
@ -126,6 +127,7 @@ extern int endpoint_is_task_blocked(endpoint_t*);
extern int endpoint_set_owner(endpoint_t*, void*);
extern int endpoint_set_msg_handler(endpoint_t*, msg_handler_t);
extern int endpoint_set_err_handler(endpoint_t*, err_handler_t);
extern int endpoint_set_on_connected(endpoint_t*, void (*cb)(endpoint_t *));
extern void endpoint_fini(endpoint_t*);
extern int endpoint_set_peer(endpoint_t*, xce_peerinfo_t*);