diff --git a/src/scheduler/src/scheduler.c b/src/scheduler/src/scheduler.c index 812a611a..6bdf5aea 100644 --- a/src/scheduler/src/scheduler.c +++ b/src/scheduler/src/scheduler.c @@ -445,6 +445,7 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config, rc = xcecli_start(sched->apictx); if (rc < 0) { + xcecli_ctx_fini(sched->apictx); /* free before next attempt */ continue; } @@ -454,8 +455,9 @@ int sched_init(xce_scheduler_t* sched, xce_client_config_t* config, break; } - /* Standby replied — try next candidate */ + /* Standby replied — tear down fully before next attempt */ xcecli_stop(sched->apictx); + xcecli_ctx_fini(sched->apictx); } if (!joined) { diff --git a/src/worker/src/controller_connector.c b/src/worker/src/controller_connector.c index fed44dd3..566bb4a2 100755 --- a/src/worker/src/controller_connector.c +++ b/src/worker/src/controller_connector.c @@ -265,6 +265,7 @@ int xcecd_join_cluster(hostattrs_t* attrs) XCECD_LOG(XCE_LOG_WARN, "xcecd_join_cluster: connect to %s:%d failed (rc=%d)", host, port, rc); + xcecli_ctx_fini(xcecli_ctx); /* free context before next attempt */ continue; } @@ -282,6 +283,7 @@ int xcecd_join_cluster(hostattrs_t* attrs) "(likely standby redirect), trying next", host, port, rc); xcecli_stop(xcecli_ctx); + xcecli_ctx_fini(xcecli_ctx); /* free context before next attempt */ } XCECD_LOG(XCE_LOG_ERROR,