summaryrefslogtreecommitdiff
path: root/switchctl.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2009-11-04 18:27:28 (GMT)
committerChristian Pointner <equinox@helsinki.at>2009-11-04 18:27:28 (GMT)
commit09702cb66d0063b95d8a870a8ce10bc847a80bf6 (patch)
tree32eac6c9163c56ba9075d350ad3bba70c8e7a996 /switchctl.c
parent148eb9ed5edf34b0090f86893b30be5dbb37e05e (diff)
added command for client type and mode
Diffstat (limited to 'switchctl.c')
-rw-r--r--switchctl.c46
1 files changed, 45 insertions, 1 deletions
diff --git a/switchctl.c b/switchctl.c
index f961f31..9bf0612 100644
--- a/switchctl.c
+++ b/switchctl.c
@@ -86,6 +86,10 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, op
cmd_id_t cmd_id;
if(!strncmp(cmd, "switch", 6))
cmd_id = SWITCH;
+ else if(!strncmp(cmd, "type", 4))
+ cmd_id = TYPE;
+ else if(!strncmp(cmd, "mode", 4))
+ cmd_id = MODE;
else if(!strncmp(cmd, "status", 6))
cmd_id = STATUS;
else if(!strncmp(cmd, "log", 3))
@@ -121,7 +125,7 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, op
}
switch(cmd_id) {
- case SWITCH:
+ case SWITCH:
case STATUS: {
char* tmp = key_value_storage_find(&opt->alias_table_, param);
int ret = cmd_push(cmd_q, fd, cmd_id, tmp != NULL ? tmp : param);
@@ -131,6 +135,46 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, op
log_printf(NOTICE, "command: %s", cmd);
break;
}
+ case TYPE: {
+ if(param) {
+ client_t* client = client_find(client_lst, fd);
+ if(client) {
+ if(!strncmp(param, "master", 6))
+ client->type = MASTER;
+ else if(!strncmp(param, "standby", 7))
+ client->type = STANDBY;
+ else if(!strncmp(param, "heartbeat", 9))
+ client->type = HEARTBEAT;
+ else {
+ log_printf(DEBUG, "unkown client type '%s'", param);
+ break;
+ }
+ log_printf(DEBUG, "client %d type set to %s", fd, param);
+ }
+ else
+ log_printf(ERROR, "unable to set client type for %d: client not found", fd);
+ }
+ else
+ log_printf(ERROR, "unable to set client type for %d: empty parameter", fd);
+
+ break;
+ }
+ case MODE: {
+ if(param) {
+ if(!strncmp(param, "master", 6))
+ opt->mode_ = MODE_MASTER;
+ else if(!strncmp(param, "standby", 7))
+ opt->mode_ = MODE_STANDBY;
+ else {
+ log_printf(DEBUG, "unkown mode '%s'", param);
+ break;
+ }
+ }
+ else
+ log_printf(ERROR, "unable to set mode: empty parameter", fd);
+
+ break;
+ }
case LOG: {
if(param && param[0])
log_printf(NOTICE, "ext msg: %s", param);