diff options
Diffstat (limited to 'src/providers')
-rw-r--r-- | src/providers/data_provider_fo.c | 11 | ||||
-rw-r--r-- | src/providers/fail_over.c | 9 | ||||
-rw-r--r-- | src/providers/fail_over.h | 2 |
3 files changed, 20 insertions, 2 deletions
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c index ddb348f64..f1e1e137c 100644 --- a/src/providers/data_provider_fo.c +++ b/src/providers/data_provider_fo.c @@ -42,6 +42,7 @@ struct be_svc_data { struct fo_service *fo_service; struct fo_server *last_good_srv; + time_t last_status_change; bool run_callbacks; struct be_svc_callback *callbacks; @@ -400,6 +401,7 @@ static void be_resolve_server_done(struct tevent_req *subreq) struct be_resolve_server_state); struct be_svc_callback *callback; int ret; + time_t srv_status_change; ret = fo_resolve_service_recv(subreq, &state->srv); talloc_zfree(subreq); @@ -461,10 +463,15 @@ static void be_resolve_server_done(struct tevent_req *subreq) fo_get_server_name(state->srv), ipaddr)); } + srv_status_change = fo_get_server_hostname_last_change(state->srv); + /* now call all svc callbacks if server changed or if it is explicitly - * requested */ - if (state->srv != state->svc->last_good_srv || state->svc->run_callbacks) { + * requested or if the server is the same but changed status since last time*/ + if (state->srv != state->svc->last_good_srv || + state->svc->run_callbacks || + srv_status_change > state->svc->last_status_change) { state->svc->last_good_srv = state->srv; + state->svc->last_status_change = srv_status_change; state->svc->run_callbacks = false; DLIST_FOR_EACH(callback, state->svc->callbacks) { diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c index 92089226b..4967e195c 100644 --- a/src/providers/fail_over.c +++ b/src/providers/fail_over.c @@ -1386,6 +1386,15 @@ fo_get_server_hostent(struct fo_server *server) return server->common->hostent; } +time_t +fo_get_server_hostname_last_change(struct fo_server *server) +{ + if (server->common == NULL) { + return 0; + } + return server->common->last_status_change.tv_sec; +} + void fo_reset_services(struct fo_ctx *fo_ctx) { struct fo_service *service; diff --git a/src/providers/fail_over.h b/src/providers/fail_over.h index 6e52d3c66..54141e9c8 100644 --- a/src/providers/fail_over.h +++ b/src/providers/fail_over.h @@ -171,6 +171,8 @@ const char *fo_get_server_name(struct fo_server *server); struct hostent *fo_get_server_hostent(struct fo_server *server); +time_t fo_get_server_hostname_last_change(struct fo_server *server); + int fo_is_srv_lookup(struct fo_server *s); void fo_reset_services(struct fo_ctx *fo_ctx); |