diff --git a/src/villas-hook.cpp b/src/villas-hook.cpp index 31d8cf6dc..4a3b5e8ce 100644 --- a/src/villas-hook.cpp +++ b/src/villas-hook.cpp @@ -45,16 +45,8 @@ using namespace villas; -int cnt; - static std::atomic stop(false); -static Logger logger = logging.get("hook"); - -struct pool p = { .state = STATE_DESTROYED }; -struct hook h = { .state = STATE_DESTROYED }; -struct io io = { .state = STATE_DESTROYED }; - static void quit(int signal, siginfo_t *sinfo, void *ctx) { stop = true; @@ -89,13 +81,19 @@ static void usage() int main(int argc, char *argv[]) { - int ret, recv, sent; + int ret, recv, sent, cnt; const char *format = "villas.human"; struct format_type *ft; struct hook_type *ht; struct sample **smps; + Logger logger = logging.get("hook"); + + struct pool p = { .state = STATE_DESTROYED }; + struct hook h = { .state = STATE_DESTROYED }; + struct io io = { .state = STATE_DESTROYED }; + /* Default values */ cnt = 1; diff --git a/src/villas-node.cpp b/src/villas-node.cpp index dd04c7acf..8a9bfeba5 100644 --- a/src/villas-node.cpp +++ b/src/villas-node.cpp @@ -54,9 +54,6 @@ using namespace villas; using namespace villas::node; using namespace villas::plugin; -static SuperNode sn; -static Logger logger = logging.get("node"); - static std::atomic stop(false); static void quit(int signal, siginfo_t *sinfo, void *ctx) @@ -110,6 +107,9 @@ int main(int argc, char *argv[]) { int ret; + SuperNode sn; + Logger logger = logging.get("node"); + try { /* Check arguments */ diff --git a/src/villas-pipe.cpp b/src/villas-pipe.cpp index ab20f3e25..6620d4530 100644 --- a/src/villas-pipe.cpp +++ b/src/villas-pipe.cpp @@ -51,9 +51,6 @@ using namespace villas; using namespace villas::node; -static SuperNode sn; /**< The global configuration */ -static Logger logger = logging.get("pipe"); - class Direction { public: @@ -77,6 +74,8 @@ static std::atomic stop(false); static void quit(int signal, siginfo_t *sinfo, void *ctx) { + Logger logger = logging.get("pipe"); + if (signal == SIGALRM) logger->info("Reached timeout. Terminating..."); @@ -107,6 +106,7 @@ static void usage() static void * send_loop(void *ctx) { Direction *d = static_cast(ctx); + Logger logger = logging.get("pipe"); unsigned last_sequenceno = 0, release; int ret, scanned, sent, allocated, cnt = 0; @@ -180,6 +180,7 @@ leave: if (io_eof(d->io)) { static void * recv_loop(void *ctx) { Direction *d = static_cast(ctx); + Logger logger = logging.get("pipe"); int recv, ret, cnt = 0, allocated = 0; unsigned release; @@ -235,6 +236,9 @@ int main(int argc, char *argv[]) Direction sendd(&io); Direction recvv(&io); + SuperNode sn; /**< The global configuration */ + Logger logger = logging.get("pipe"); + json_t *cfg_cli = json_object(); int c; diff --git a/src/villas-signal.cpp b/src/villas-signal.cpp index 3e65f8f44..0ae25d92b 100644 --- a/src/villas-signal.cpp +++ b/src/villas-signal.cpp @@ -43,18 +43,12 @@ using namespace villas; -/* Some default values */ -struct node n; -struct io io; -struct pool q; -struct sample *t; - -static Logger logger = logging.get("signal"); - static std::atomic stop(false); json_t * parse_cli(int argc, char *argv[]) { + Logger logger = logging.get("signal"); + /* Default values */ double rate = 10; double frequency = 1; @@ -177,6 +171,13 @@ int main(int argc, char *argv[]) const char *format = "villas.human"; /** @todo hardcoded for now */ + struct node n; + struct io io; + struct pool q; + struct sample *t; + + Logger logger = logging.get("signal"); + ret = utils::signals_init(quit); if (ret) throw new RuntimeError("Failed to intialize signals"); diff --git a/src/villas-test-rtt.cpp b/src/villas-test-rtt.cpp index 836bca065..980577356 100644 --- a/src/villas-test-rtt.cpp +++ b/src/villas-test-rtt.cpp @@ -46,9 +46,6 @@ using namespace villas; using namespace villas::node; -static SuperNode sn; -static Logger logger = logging.get("test-rtt"); - static std::atomic stop(false); void quit(int signal, siginfo_t *sinfo, void *ctx) @@ -84,6 +81,9 @@ int main(int argc, char *argv[]) struct node *node; + SuperNode sn; + Logger logger = logging.get("test-rtt"); + /* Test options */ int count = -1; /**< Amount of messages which should be sent (default: -1 for unlimited) */