diff options
Diffstat (limited to 'src')
-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"); |