MCPcopy Create free account
hub / github.com/corosync/corosync / wd_config_changed

Function wd_config_changed

exec/wd.c:272–333  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

270}
271
272static void wd_config_changed (struct cs_fsm* fsm, int32_t event, void * data)
273{
274 char *state;
275 uint64_t tmp_value;
276 uint64_t next_timeout;
277 struct resource *ref = (struct resource*)data;
278 char key_name[ICMAP_KEYNAME_MAXLEN];
279
280 next_timeout = ref->check_timeout;
281
282 if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "poll_period") >= ICMAP_KEYNAME_MAXLEN) ||
283 (icmap_get_uint64(ref->res_path, &tmp_value) == CS_OK)) {
284 if (tmp_value >= WD_MIN_TIMEOUT_MS && tmp_value <= WD_MAX_TIMEOUT_MS) {
285 log_printf (LOGSYS_LEVEL_DEBUG,
286 "poll_period changing from:%"PRIu64" to %"PRIu64".",
287 ref->check_timeout, tmp_value);
288 /*
289 * To easy in the transition between poll_period's we are going
290 * to make the first timeout the bigger of the new and old value.
291 * This is to give the monitoring system time to adjust.
292 */
293 next_timeout = CS_MAX(tmp_value, ref->check_timeout);
294 ref->check_timeout = tmp_value;
295 } else {
296 log_printf (LOGSYS_LEVEL_WARNING,
297 "Could NOT use poll_period:%"PRIu64" ms for resource %s",
298 tmp_value, ref->name);
299 }
300 }
301
302 if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "recovery") >= ICMAP_KEYNAME_MAXLEN) ||
303 (icmap_get_string(key_name, &ref->recovery) != CS_OK)) {
304 /* key does not exist.
305 */
306 log_printf (LOGSYS_LEVEL_WARNING,
307 "resource %s missing a recovery key.", ref->name);
308 cs_fsm_state_set(&ref->fsm, WD_S_STOPPED, ref, wd_fsm_cb);
309 return;
310 }
311 if ((snprintf(key_name, ICMAP_KEYNAME_MAXLEN, "%s%s", ref->res_path, "state") >= ICMAP_KEYNAME_MAXLEN) ||
312 (icmap_get_string(key_name, &state) != CS_OK)) {
313 /* key does not exist.
314 */
315 log_printf (LOGSYS_LEVEL_WARNING,
316 "resource %s missing a state key.", ref->name);
317 cs_fsm_state_set(&ref->fsm, WD_S_STOPPED, ref, wd_fsm_cb);
318 return;
319 }
320 if (ref->check_timer) {
321 api->timer_delete(ref->check_timer);
322 ref->check_timer = 0;
323 }
324
325 if (strcmp(wd_stopped_str, state) == 0) {
326 cs_fsm_state_set(&ref->fsm, WD_S_STOPPED, ref, wd_fsm_cb);
327 } else {
328 api->timer_add_duration(next_timeout * MILLI_2_NANO_SECONDS,
329 ref, wd_resource_check_fn, &ref->check_timer);

Callers

nothing calls this directly

Calls 3

icmap_get_uint64Function · 0.85
icmap_get_stringFunction · 0.85
cs_fsm_state_setFunction · 0.85

Tested by

no test coverage detected