This commit is contained in:
Roland Jax
2014-11-11 20:16:44 +01:00
parent e8d4fbaff5
commit 162681bb9f
3 changed files with 17 additions and 17 deletions
+7 -7
View File
@@ -27,36 +27,36 @@ extern Appl& A;
BaseLoop::BaseLoop() BaseLoop::BaseLoop()
{ {
// create Commands DB // create commands DB
m_commands = ConfigCommands(A.getParam<const char*>("p_ebusconfdir"), CSV).getCommands(); m_commands = ConfigCommands(A.getParam<const char*>("p_ebusconfdir"), CSV).getCommands();
L.log(bas, trace, "ebus configuration dir: %s", A.getParam<const char*>("p_ebusconfdir")); L.log(bas, trace, "ebus configuration dir: %s", A.getParam<const char*>("p_ebusconfdir"));
L.log(bas, event, "commands DB: %d ", m_commands->sizeCmdDB()); L.log(bas, event, "commands DB: %d ", m_commands->sizeCmdDB());
L.log(bas, event, " cycle DB: %d ", m_commands->sizeCycDB()); L.log(bas, event, " cycle DB: %d ", m_commands->sizeCycDB());
L.log(bas, event, " polling DB: %d ", m_commands->sizePolDB()); L.log(bas, event, " polling DB: %d ", m_commands->sizePolDB());
// create EBusLoop // create ebusloop
m_ebusloop = new EBusLoop(m_commands); m_ebusloop = new EBusLoop(m_commands);
m_ebusloop->start("ebusloop"); m_ebusloop->start("ebusloop");
// create Network // create network
m_network = new Network(A.getParam<bool>("p_localhost"), &m_msgQueue); m_network = new Network(A.getParam<bool>("p_localhost"), &m_msgQueue);
m_network->start("network"); m_network->start("network");
} }
BaseLoop::~BaseLoop() BaseLoop::~BaseLoop()
{ {
// free Network // free network
if (m_network != NULL) if (m_network != NULL)
delete m_network; delete m_network;
// free EBusLoop // free ebusloop
if (m_ebusloop != NULL) { if (m_ebusloop != NULL) {
m_ebusloop->stop(); m_ebusloop->stop();
m_ebusloop->join(); m_ebusloop->join();
delete m_ebusloop; delete m_ebusloop;
} }
// free Commands DB // free commands DB
if (m_commands != NULL) if (m_commands != NULL)
delete m_commands; delete m_commands;
} }
@@ -343,7 +343,7 @@ std::string BaseLoop::decodeMessage(const std::string& data)
} }
{ {
// create Commands DB // create commands DB
Commands* commands = ConfigCommands(A.getParam<const char*>("p_ebusconfdir"), CSV).getCommands(); Commands* commands = ConfigCommands(A.getParam<const char*>("p_ebusconfdir"), CSV).getCommands();
L.log(bas, trace, "ebus configuration dir: %s", A.getParam<const char*>("p_ebusconfdir")); L.log(bas, trace, "ebus configuration dir: %s", A.getParam<const char*>("p_ebusconfdir"));
L.log(bas, event, "commands DB: %d ", m_commands->sizeCmdDB()); L.log(bas, event, "commands DB: %d ", m_commands->sizeCmdDB());
+9 -9
View File
@@ -29,11 +29,11 @@ Network::Network(const bool localhost, WQueue<Message*>* msgQueue)
: m_msgQueue(msgQueue), m_listening(false), m_running(false) : m_msgQueue(msgQueue), m_listening(false), m_running(false)
{ {
if (localhost == true) if (localhost == true)
m_Server = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1"); m_tcpServer = new TCPServer(A.getParam<int>("p_port"), "127.0.0.1");
else else
m_Server = new TCPServer(A.getParam<int>("p_port"), "0.0.0.0"); m_tcpServer = new TCPServer(A.getParam<int>("p_port"), "0.0.0.0");
if (m_Server != NULL && m_Server->start() == 0) if (m_tcpServer != NULL && m_tcpServer->start() == 0)
m_listening = true; m_listening = true;
} }
@@ -51,7 +51,7 @@ Network::~Network()
if (m_running == true) if (m_running == true)
stop(); stop();
delete m_Server; delete m_tcpServer;
} }
void* Network::run() void* Network::run()
@@ -67,10 +67,10 @@ void* Network::run()
FD_ZERO(&checkfds); FD_ZERO(&checkfds);
FD_SET(m_notify.notifyFD(), &checkfds); FD_SET(m_notify.notifyFD(), &checkfds);
FD_SET(m_Server->getFD(), &checkfds); FD_SET(m_tcpServer->getFD(), &checkfds);
(m_notify.notifyFD() > m_Server->getFD()) ? (m_notify.notifyFD() > m_tcpServer->getFD()) ?
(maxfd = m_notify.notifyFD()) : (maxfd = m_Server->getFD()); (maxfd = m_notify.notifyFD()) : (maxfd = m_tcpServer->getFD());
for (;;) { for (;;) {
fd_set readfds; fd_set readfds;
@@ -96,8 +96,8 @@ void* Network::run()
} }
// new data from socket // new data from socket
if (FD_ISSET(m_Server->getFD(), &readfds)) { if (FD_ISSET(m_tcpServer->getFD(), &readfds)) {
TCPSocket* socket = m_Server->newSocket(); TCPSocket* socket = m_tcpServer->newSocket();
if (socket == NULL) if (socket == NULL)
continue; continue;
+1 -1
View File
@@ -35,7 +35,7 @@ public:
private: private:
std::list<Connection*> m_connections; std::list<Connection*> m_connections;
WQueue<Message*>* m_msgQueue; WQueue<Message*>* m_msgQueue;
TCPServer* m_Server; TCPServer* m_tcpServer;
Notify m_notify; Notify m_notify;
bool m_listening; bool m_listening;
bool m_running; bool m_running;