forked from lei.chen/myxce
fix: capture am_i_primary() result once; set ha->role before phase2; cluster_init wrapper cleanup on failure
- myapp.c: capture am_i_primary() into is_primary (avoids redundant second probe call); after load_primary_config() succeeds, record CTRL_PRIMARY role via atomic_store_explicit so cluster_init_phase2() sees the correct role (ha_init() defaults to CTRL_STANDBY) - myapp.c: add #include "ha.h" for CTRL_PRIMARY, atomic_store_explicit, and memory_order_release - cluster.c: cluster_init() wrapper now calls cluster_fini(c) before returning on create_ssl_context failure, hook failure, and cluster_init_phase2 failure — prevents SSL ctx and phase1 resource leak
This commit is contained in:
parent
6b06aa02d9
commit
93b8616f11
2 changed files with 20 additions and 4 deletions
|
|
@ -785,6 +785,7 @@ int cluster_init(cluster_t* c)
|
|||
c->myconf->keyfile);
|
||||
if (ssl_ctx == NULL) {
|
||||
ERROR("create_ssl_context failed");
|
||||
cluster_fini(c);
|
||||
return -errno;
|
||||
}
|
||||
c->ha.ssl_ctx = ssl_ctx;
|
||||
|
|
@ -794,11 +795,18 @@ int cluster_init(cluster_t* c)
|
|||
if (c->myconf->cluster_config == NULL) {
|
||||
rc = xce_run_hooks(&(c->hooksys), XCE_CONTROLLER_HOOK_CLUSTER,
|
||||
HOOK_BEFORE_EVENT, HOOK_DETAIL_CLUSTER_INIT, c);
|
||||
if (rc < 0)
|
||||
if (rc < 0) {
|
||||
cluster_fini(c);
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
return cluster_init_phase2(c);
|
||||
rc = cluster_init_phase2(c);
|
||||
if (rc != 0) {
|
||||
cluster_fini(c);
|
||||
return rc;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int make_heartbeat(cluster_t* c, endpoint_t* ep)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue