From 5b5a0e9950fa7e191a67cacabe55f1780fed5b5e Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Sun, 10 Jan 2010 16:17:47 +0000 Subject: new listener type: mode switched to version 1.0 RC1 cleanups diff --git a/client_list.c b/client_list.c index 4ee2559..8c3a73d 100644 --- a/client_list.c +++ b/client_list.c @@ -48,6 +48,7 @@ int client_add(client_t** first, int fd) new_client->fd = fd; new_client->type = DEFAULT; new_client->request_listener = 0; + new_client->mode_listener = 0; new_client->status_listener = 0; new_client->gpi_listener = 0; new_client->oc_listener = 0; diff --git a/client_list.h b/client_list.h index 00d741d..428188e 100644 --- a/client_list.h +++ b/client_list.h @@ -31,6 +31,7 @@ struct client_struct { int fd; client_type_t type; int request_listener; + int mode_listener; int status_listener; int gpi_listener; int oc_listener; diff --git a/heartbeatclient.c b/heartbeatclient.c index f95c335..82546b1 100644 --- a/heartbeatclient.c +++ b/heartbeatclient.c @@ -145,7 +145,7 @@ int main_loop(int serial_fd, int cmd_fd, options_t* opt) log_printf(WARNING, "timeout reached, switching to standby"); send_string(cmd_fd, "mode standby\n"); active = 0; - log_printf(WARNING, "deactivated timeout"); + log_printf(NOTICE, "deactivated timeout"); time = 0; } continue; diff --git a/openwrt/rhctl/Makefile b/openwrt/rhctl/Makefile index 5a88216..e7124ff 100644 --- a/openwrt/rhctl/Makefile +++ b/openwrt/rhctl/Makefile @@ -12,13 +12,13 @@ include $(TOPDIR)/rules.mk PKG_NAME:=rhctl -PKG_VERSION:=0.3 +PKG_VERSION:=1.0_RC1 PKG_RELEASE:=1 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=http://localhost/ -PKG_MD5SUM:=a09815ee33dd76f43c277ca80a770073 +PKG_MD5SUM:=0db71d3155aa44e6027918a135a6becf PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install diff --git a/openwrt/rhctl/files/rhctl.config b/openwrt/rhctl/files/rhctl.config index 3245618..ef8c617 100644 --- a/openwrt/rhctl/files/rhctl.config +++ b/openwrt/rhctl/files/rhctl.config @@ -1,5 +1,5 @@ config 'switchctl' - option log 'syslog:5,switchctl,daemon' + option log 'syslog:3,switchctl,daemon' option command_sock '/var/run/rhctl/switchctl.sock' option baudrate '19200' option device '/dev/audioswitch' @@ -10,7 +10,7 @@ config 'switchctl' config 'serialclient' # option disabled 1 option name 'master' - option log 'syslog:5,serialclient-master,daemon' + option log 'syslog:3,serialclient-master,daemon' option command_sock '/var/run/rhctl/switchctl.sock' option baudrate '38400' option device '/dev/ttyMaster' @@ -19,15 +19,15 @@ config 'serialclient' config 'serialclient' # option disabled 1 option name 'standby' - option log 'syslog:5,serialclient-standby,daemon' + option log 'syslog:3,serialclient-standby,daemon' option command_sock '/var/run/rhctl/switchctl.sock' option baudrate '38400' option device '/dev/ttyStandby' option type 'standby' config 'heartbeatclient' - option log 'syslog:5,heartbeatclient,daemon' + option log 'syslog:3,heartbeatclient,daemon' option command_sock '/var/run/rhctl/switchctl.sock' option baudrate '38400' option device '/dev/ttyHeartbeat' - option timeout '50' + option timeout '15' diff --git a/switchctl.c b/switchctl.c index 6d5c42c..9b704bb 100644 --- a/switchctl.c +++ b/switchctl.c @@ -340,7 +340,7 @@ void process_cmd_type(const char* param, int fd, client_t* client_lst) } } -int process_cmd_mode(const char* param, int fd, cmd_t **cmd_q, options_t* opt) +int process_cmd_mode(const char* param, int fd, cmd_t **cmd_q, options_t* opt, client_t* client_lst) { mode_t old_mode = opt->mode_; @@ -402,8 +402,23 @@ int process_cmd_mode(const char* param, int fd, cmd_t **cmd_q, options_t* opt) send_response(fd, "EEE: mode: missing parameter"); } - if(old_mode != opt->mode_) - log_printf(NOTICE, "new mode: %s", opt->mode_ == MODE_MASTER ? "master" : "standby"); + if(old_mode != opt->mode_) { + char* mode_str; + asprintf(&mode_str, "new Mode: %s", opt->mode_ == MODE_MASTER ? "master" : "standby"); + if(mode_str) { + log_printf(NOTICE, "%s", mode_str); + client_t* client; + int listener_cnt = 0; + for(client = client_lst; client; client = client->next) + if(client->mode_listener && client->fd != fd) { + send_response(client->fd, mode_str); + listener_cnt++; + } + free(mode_str); + log_printf(DEBUG, "sent new mode to %d additional listeners", listener_cnt); + } + + } return 0; } @@ -414,6 +429,7 @@ void process_cmd_listen(const char* param, int fd, client_t* client_lst) if(listener) { if(!param) { listener->request_listener = 1; + listener->mode_listener = 1; listener->status_listener = 1; listener->gpi_listener = 1; listener->oc_listener = 1; @@ -423,6 +439,8 @@ void process_cmd_listen(const char* param, int fd, client_t* client_lst) else { if(!strncmp(param, "request", 7)) listener->request_listener = 1; + else if(!strncmp(param, "mode", 6)) + listener->mode_listener = 1; else if(!strncmp(param, "status", 6)) listener->status_listener = 1; else if(!strncmp(param, "gpi", 3)) @@ -435,6 +453,7 @@ void process_cmd_listen(const char* param, int fd, client_t* client_lst) listener->silence_listener = 1; else if(!strncmp(param, "none", 4)) { listener->request_listener = 0; + listener->mode_listener = 0; listener->status_listener = 0; listener->gpi_listener = 0; listener->oc_listener = 0; @@ -522,7 +541,7 @@ int process_cmd(const char* cmd, int fd, cmd_t **cmd_q, client_t* client_lst, op } case TYPE: process_cmd_type(param, fd, client_lst); break; case MODE: { - int ret = process_cmd_mode(param, fd, cmd_q, opt); + int ret = process_cmd_mode(param, fd, cmd_q, opt, client_lst); if(ret) return ret; break; -- cgit v0.10.2