diff options
author | Christian Pointner <equinox@helsinki.at> | 2015-07-27 01:44:34 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@helsinki.at> | 2015-07-27 01:44:34 (GMT) |
commit | 03df0e0cd3657e5bc31bfec26beaaa73ae7cdd71 (patch) | |
tree | f0ceaf4b784840069643b0eb9a735825b42ab582 | |
parent | 2e0dddda92011c07a8a803c86d12789a3f926d7a (diff) |
manual mode switch honor heartbeat now
-rw-r--r-- | src/switchctl.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/switchctl.c b/src/switchctl.c index 5366a00..4be2313 100644 --- a/src/switchctl.c +++ b/src/switchctl.c @@ -103,7 +103,7 @@ void send_usage(int fd) send_response(fd, " type set client type, one of: master, standby, hb_master, hb_standby"); send_response(fd, " channel switch to channel main or music"); send_response(fd, " client type master and standby only"); - send_response(fd, " mode switch to mode master or standby"); + send_response(fd, " mode switch to mode master or standby (add -forced to override heartbeat control)"); send_response(fd, " heartbeat update heartbeat status for master or standby"); send_response(fd, " status get actual status from switch"); send_response(fd, " health get health info"); @@ -422,10 +422,26 @@ int process_cmd_mode(const char* param, int fd, cmd_t **cmd_q, client_t* client_ switchctl_mode_t old_mode = state_.mode_; if(param) { - if(!strncmp(param, "master", 6)) + if(!strncmp(param, "master-forced", 13)) state_.mode_ = MODE_MASTER; - else if(!strncmp(param, "standby", 7)) + else if(!strncmp(param, "master", 6)) { + if(!state_.hb_state_master_) { + log_printf(DEBUG, "mode switch to master denied because missing heartbeat", param); + send_response(fd, "EEE: mode: no heartbeat, use 'mode master-forced' to override"); + return 0; + } + state_.mode_ = MODE_MASTER; + } + else if(!strncmp(param, "standby-forced", 14)) state_.mode_ = MODE_STANDBY; + else if(!strncmp(param, "standby", 7)) { + if(!state_.hb_state_standby_) { + log_printf(DEBUG, "mode switch to standby denied because missing heartbeat", param); + send_response(fd, "EEE: mode: no heartbeat, use 'mode standby-forced' to override"); + return 0; + } + state_.mode_ = MODE_STANDBY; + } else { log_printf(DEBUG, "unkown mode '%s'", param); send_response(fd, "EEE: mode: unknown mode"); |