Skip to content

Commit

Permalink
Merge pull request #397 from openziti/fix_crash_on_disable_enable
Browse files Browse the repository at this point in the history
fix for the crash that occurs when the ztx is disabled, because the t…
  • Loading branch information
ekoby authored Jun 20, 2022
2 parents 80ee30b + 9e1a869 commit f041506
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions library/ziti.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,19 @@ static void ziti_start_internal(ziti_context ztx, void *init_req) {
uv_prepare_start(ztx->reaper, grim_reaper);
ziti_ctrl_get_version(&ztx->controller, version_cb, ztx);
ziti_set_unauthenticated(ztx);

// if the ztx is disabled, api_session_timer and service_refresh_timer will be null
ztx->api_session_timer = calloc(1, sizeof(uv_timer_t));
uv_timer_init(ztx->loop, ztx->api_session_timer);
ztx->api_session_timer->data = ztx;

ztx->service_refresh_timer = calloc(1, sizeof(uv_timer_t));
uv_timer_init(ztx->loop, ztx->service_refresh_timer);
if (ztx->opts->refresh_interval == 0) {
uv_unref((uv_handle_t *) ztx->service_refresh_timer);
}
ztx->service_refresh_timer->data = ztx;

ziti_re_auth(ztx);
}
}
Expand Down Expand Up @@ -1142,6 +1155,10 @@ void ziti_services_refresh(uv_timer_t *t) {
ZTX_LOG(DEBUG, "service refresh stopped, outstanding auth queries");
return;
}
if (!ztx->enabled) {
ZTX_LOG(DEBUG, "service refresh stopped, ztx is disabled");
return;
}

if (ztx->no_service_updates_api) {
ziti_ctrl_get_services(&ztx->controller, update_services, ztx);
Expand Down

0 comments on commit f041506

Please sign in to comment.