mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-30 00:00:11 +01:00
do not throw dynamically allocated exceptions
This commit is contained in:
parent
caf3e45960
commit
a63b15609a
12 changed files with 133 additions and 133 deletions
|
@ -74,7 +74,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize signals");
|
||||
throw RuntimeError("Failed to initialize signals");
|
||||
|
||||
char *wname = argv[1];
|
||||
char *rname = argv[2];
|
||||
|
@ -82,7 +82,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
ret = shmem_int_open(wname, rname, &shm, &conf);
|
||||
if (ret < 0)
|
||||
throw new RuntimeError("Failed to open shared-memory interface");
|
||||
throw RuntimeError("Failed to open shared-memory interface");
|
||||
|
||||
struct sample *insmps[vectorize], *outsmps[vectorize];
|
||||
|
||||
|
@ -119,7 +119,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
ret = shmem_int_close(&shm);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close shared-memory interface");
|
||||
throw RuntimeError("Failed to close shared-memory interface");
|
||||
|
||||
logger->info(CLR_GRN("Goodbye!"));
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ protected:
|
|||
logger->info("Restart instance: config={}", cfg);
|
||||
ret = execvp("/proc/self/exe", (char **) argv);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to restart");
|
||||
throw SystemError("Failed to restart");
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -58,7 +58,7 @@ void Server::start()
|
|||
|
||||
sd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sd < 0)
|
||||
throw new SystemError("Failed to create Api socket");
|
||||
throw SystemError("Failed to create Api socket");
|
||||
|
||||
pollfd pfd = {
|
||||
.fd = sd,
|
||||
|
@ -90,18 +90,18 @@ void Server::start()
|
|||
|
||||
ret = unlink(socketPath.c_str());
|
||||
if (ret && errno != ENOENT)
|
||||
throw new SystemError("Failed to unlink API socket");
|
||||
throw SystemError("Failed to unlink API socket");
|
||||
|
||||
strncpy(sun.sun_path, socketPath.c_str(), sizeof(sun.sun_path) - 1);
|
||||
#endif
|
||||
|
||||
ret = bind(sd, (struct sockaddr *) &sun, sizeof(struct sockaddr_un));
|
||||
if (ret)
|
||||
throw new SystemError("Failed to bind API socket");
|
||||
throw SystemError("Failed to bind API socket");
|
||||
|
||||
ret = listen(sd, 5);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to listen on API socket");
|
||||
throw SystemError("Failed to listen on API socket");
|
||||
|
||||
state = STATE_STARTED;
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ void Server::stop()
|
|||
|
||||
ret = close(sd);
|
||||
if (ret)
|
||||
throw new SystemError("Failed to close API socket");;
|
||||
throw SystemError("Failed to close API socket");;
|
||||
|
||||
state = STATE_STOPPED;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ void Server::run(int timeout)
|
|||
|
||||
ret = poll(pfds.data(), pfds.size(), timeout);
|
||||
if (ret < 0)
|
||||
throw new SystemError("Failed to poll on API socket");;
|
||||
throw SystemError("Failed to poll on API socket");;
|
||||
|
||||
for (unsigned i = 0; i < pfds.size(); i++) {
|
||||
auto &pfd = pfds[i];
|
||||
|
|
|
@ -83,7 +83,7 @@ int SuperNode::parseUri(const std::string &u)
|
|||
|
||||
af = afopen(u.c_str(), "r");
|
||||
if (!af)
|
||||
throw new RuntimeError("Failed to open configuration from: {}", u);
|
||||
throw RuntimeError("Failed to open configuration from: {}", u);
|
||||
|
||||
f = af->file;
|
||||
}
|
||||
|
@ -130,11 +130,11 @@ int SuperNode::parseUri(const std::string &u)
|
|||
|
||||
json = config_to_json(json_root);
|
||||
if (json == nullptr)
|
||||
throw new RuntimeError("Failed to convert JSON to configuration file");
|
||||
throw RuntimeError("Failed to convert JSON to configuration file");
|
||||
|
||||
config_destroy(&cfg);
|
||||
#else
|
||||
throw new JsonError(err, "Failed to parse configuration file");
|
||||
throw JsonError(err, "Failed to parse configuration file");
|
||||
#endif /* LIBCONFIG_FOUND */
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ int SuperNode::parseJson(json_t *j)
|
|||
"name", &nme
|
||||
);
|
||||
if (ret)
|
||||
throw new JsonError(err, "Failed to parse global configuration");
|
||||
throw JsonError(err, "Failed to parse global configuration");
|
||||
|
||||
if (nme)
|
||||
name = nme;
|
||||
|
@ -195,7 +195,7 @@ int SuperNode::parseJson(json_t *j)
|
|||
/* Parse plugins */
|
||||
if (json_plugins) {
|
||||
if (!json_is_array(json_plugins))
|
||||
throw new ConfigError(json_plugins, "node-config-plugins", "Setting 'plugins' must be a list of strings");
|
||||
throw ConfigError(json_plugins, "node-config-plugins", "Setting 'plugins' must be a list of strings");
|
||||
|
||||
size_t i;
|
||||
json_t *json_plugin;
|
||||
|
@ -204,11 +204,11 @@ int SuperNode::parseJson(json_t *j)
|
|||
|
||||
ret = plugin_init(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize plugin");
|
||||
throw RuntimeError("Failed to initialize plugin");
|
||||
|
||||
ret = plugin_parse(p, json_plugin);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse plugin");
|
||||
throw RuntimeError("Failed to parse plugin");
|
||||
|
||||
list_push(&plugins, p);
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ int SuperNode::parseJson(json_t *j)
|
|||
/* Parse nodes */
|
||||
if (json_nodes) {
|
||||
if (!json_is_object(json_nodes))
|
||||
throw new ConfigError(json_nodes, "node-config-nodes", "Setting 'nodes' must be a group with node name => group mappings.");
|
||||
throw ConfigError(json_nodes, "node-config-nodes", "Setting 'nodes' must be a group with node name => group mappings.");
|
||||
|
||||
const char *name;
|
||||
json_t *json_node;
|
||||
|
@ -227,21 +227,21 @@ int SuperNode::parseJson(json_t *j)
|
|||
|
||||
ret = json_unpack_ex(json_node, &err, 0, "{ s: s }", "type", &type);
|
||||
if (ret)
|
||||
throw new JsonError(err, "Failed to parse node");
|
||||
throw JsonError(err, "Failed to parse node");
|
||||
|
||||
nt = node_type_lookup(type);
|
||||
if (!nt)
|
||||
throw new RuntimeError("Invalid node type: {}", type);
|
||||
throw RuntimeError("Invalid node type: {}", type);
|
||||
|
||||
auto *n = (struct node *) alloc(sizeof(struct node));
|
||||
|
||||
ret = node_init(n, nt);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize node");
|
||||
throw RuntimeError("Failed to initialize node");
|
||||
|
||||
ret = node_parse(n, json_node, name);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse node");
|
||||
throw RuntimeError("Failed to parse node");
|
||||
|
||||
list_push(&nodes, n);
|
||||
}
|
||||
|
@ -259,11 +259,11 @@ int SuperNode::parseJson(json_t *j)
|
|||
|
||||
ret = path_init(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize path");
|
||||
throw RuntimeError("Failed to initialize path");
|
||||
|
||||
ret = path_parse(p, json_path, &nodes);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse path");
|
||||
throw RuntimeError("Failed to parse path");
|
||||
|
||||
list_push(&paths, p);
|
||||
|
||||
|
@ -272,11 +272,11 @@ int SuperNode::parseJson(json_t *j)
|
|||
|
||||
ret = path_init(r);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to init path");
|
||||
throw RuntimeError("Failed to init path");
|
||||
|
||||
ret = path_reverse(p, r);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to reverse path {}", path_name(p));
|
||||
throw RuntimeError("Failed to reverse path {}", path_name(p));
|
||||
|
||||
list_push(&paths, r);
|
||||
}
|
||||
|
@ -301,7 +301,7 @@ int SuperNode::check()
|
|||
|
||||
ret = node_check(n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Invalid configuration for node {}", node_name(n));
|
||||
throw RuntimeError("Invalid configuration for node {}", node_name(n));
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < list_length(&paths); i++) {
|
||||
|
@ -309,7 +309,7 @@ int SuperNode::check()
|
|||
|
||||
ret = path_check(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Invalid configuration for path {}", path_name(p));
|
||||
throw RuntimeError("Invalid configuration for path {}", path_name(p));
|
||||
}
|
||||
|
||||
state = STATE_CHECKED;
|
||||
|
@ -340,7 +340,7 @@ int SuperNode::start()
|
|||
|
||||
ret = node_type_start(n->_vt, reinterpret_cast<super_node *>(this));
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node-type: {}", node_type_name(n->_vt));
|
||||
throw RuntimeError("Failed to start node-type: {}", node_type_name(n->_vt));
|
||||
}
|
||||
|
||||
logger->info("Starting nodes");
|
||||
|
@ -349,13 +349,13 @@ int SuperNode::start()
|
|||
|
||||
ret = node_init2(n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to prepare node: {}", node_name(n));
|
||||
throw RuntimeError("Failed to prepare node: {}", node_name(n));
|
||||
|
||||
int refs = list_count(&paths, (cmp_cb_t) path_uses_node, n);
|
||||
if (refs > 0) {
|
||||
ret = node_start(n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node: {}", node_name(n));
|
||||
throw RuntimeError("Failed to start node: {}", node_name(n));
|
||||
}
|
||||
else
|
||||
logger->warn("No path is using the node {}. Skipping...", node_name(n));
|
||||
|
@ -368,11 +368,11 @@ int SuperNode::start()
|
|||
if (p->enabled) {
|
||||
ret = path_init2(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to prepare path: {}", path_name(p));
|
||||
throw RuntimeError("Failed to prepare path: {}", path_name(p));
|
||||
|
||||
ret = path_start(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start path: {}", path_name(p));
|
||||
throw RuntimeError("Failed to start path: {}", path_name(p));
|
||||
}
|
||||
else
|
||||
logger->warn("Path {} is disabled. Skipping...", path_name(p));
|
||||
|
@ -384,7 +384,7 @@ int SuperNode::start()
|
|||
|
||||
ret = task_init(&task, 1.0 / stats, CLOCK_REALTIME);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to create stats timer");
|
||||
throw RuntimeError("Failed to create stats timer");
|
||||
}
|
||||
#endif /* WITH_HOOKS */
|
||||
|
||||
|
@ -403,7 +403,7 @@ int SuperNode::stop()
|
|||
|
||||
ret = task_destroy(&task);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop stats timer");
|
||||
throw RuntimeError("Failed to stop stats timer");
|
||||
}
|
||||
#endif /* WITH_HOOKS */
|
||||
|
||||
|
@ -413,7 +413,7 @@ int SuperNode::stop()
|
|||
|
||||
ret = path_stop(p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop path: {}", path_name(p));
|
||||
throw RuntimeError("Failed to stop path: {}", path_name(p));
|
||||
}
|
||||
|
||||
logger->info("Stopping nodes");
|
||||
|
@ -422,7 +422,7 @@ int SuperNode::stop()
|
|||
|
||||
ret = node_stop(n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node: {}", node_name(n));
|
||||
throw RuntimeError("Failed to stop node: {}", node_name(n));
|
||||
}
|
||||
|
||||
logger->info("Stopping node-types");
|
||||
|
@ -432,7 +432,7 @@ int SuperNode::stop()
|
|||
if (p->type == PLUGIN_TYPE_NODE) {
|
||||
ret = node_type_stop(&p->node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node-type: {}", node_type_name(&p->node));
|
||||
throw RuntimeError("Failed to stop node-type: {}", node_type_name(&p->node));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -206,7 +206,7 @@ int Web::parse(json_t *cfg)
|
|||
"enabled", &enabled
|
||||
);
|
||||
if (ret)
|
||||
throw new JsonError(err, "Failed to http section of configuration file");
|
||||
throw JsonError(err, "Failed to http section of configuration file");
|
||||
|
||||
if (cert)
|
||||
ssl_cert = cert;
|
||||
|
@ -248,7 +248,7 @@ void Web::start()
|
|||
|
||||
context = lws_create_context(&ctx_info);
|
||||
if (context == nullptr)
|
||||
throw new RuntimeError("Failed to initialize server context");
|
||||
throw RuntimeError("Failed to initialize server context");
|
||||
|
||||
for (int tries = 10; tries > 0; tries--) {
|
||||
vhost = lws_create_vhost(context, &ctx_info);
|
||||
|
@ -260,7 +260,7 @@ void Web::start()
|
|||
}
|
||||
|
||||
if (vhost == NULL)
|
||||
throw new RuntimeError("Failed to initialize virtual host");
|
||||
throw RuntimeError("Failed to initialize virtual host");
|
||||
|
||||
/* Start thread */
|
||||
running = true;
|
||||
|
|
|
@ -101,19 +101,19 @@ int main(int argc, char *argv[])
|
|||
for (unsigned i = 0; i < ARRAY_LEN(dirs); i++) {
|
||||
fmt = format_type_lookup(dirs[i].name);
|
||||
if (!fmt)
|
||||
throw new RuntimeError("Invalid format: {}", dirs[i].name);
|
||||
throw RuntimeError("Invalid format: {}", dirs[i].name);
|
||||
|
||||
ret = io_init_auto(dirs[i].io, fmt, DEFAULT_SAMPLE_LENGTH, SAMPLE_HAS_ALL);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize IO: {}", dirs[i].name);
|
||||
throw RuntimeError("Failed to initialize IO: {}", dirs[i].name);
|
||||
|
||||
ret = io_check(dirs[i].io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to validate IO configuration");
|
||||
throw RuntimeError("Failed to validate IO configuration");
|
||||
|
||||
ret = io_open(dirs[i].io, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to open IO");
|
||||
throw RuntimeError("Failed to open IO");
|
||||
}
|
||||
|
||||
struct sample *smp = sample_alloc_mem(DEFAULT_SAMPLE_LENGTH);
|
||||
|
@ -131,11 +131,11 @@ int main(int argc, char *argv[])
|
|||
for (unsigned i = 0; i < ARRAY_LEN(dirs); i++) {
|
||||
ret = io_close(dirs[i].io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close IO");
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(dirs[i].io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy IO");
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -122,7 +122,7 @@ int main(int argc, char *argv[])
|
|||
case 'o':
|
||||
ret = json_object_extend_str(cfg_cli, optarg);
|
||||
if (ret)
|
||||
throw new RuntimeError("Invalid option: {}", optarg);
|
||||
throw RuntimeError("Invalid option: {}", optarg);
|
||||
break;
|
||||
|
||||
case '?':
|
||||
|
@ -134,7 +134,7 @@ int main(int argc, char *argv[])
|
|||
continue;
|
||||
|
||||
check: if (optarg == endptr)
|
||||
throw new RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
throw RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
|
||||
}
|
||||
|
||||
|
@ -147,66 +147,66 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to intialize signals");
|
||||
throw RuntimeError("Failed to intialize signals");
|
||||
|
||||
if (cnt < 1)
|
||||
throw new RuntimeError("Vectorize option must be greater than 0");
|
||||
throw RuntimeError("Vectorize option must be greater than 0");
|
||||
|
||||
ret = memory_init(DEFAULT_NR_HUGEPAGES);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize memory");
|
||||
throw RuntimeError("Failed to initialize memory");
|
||||
|
||||
smps = new struct sample*[cnt];
|
||||
|
||||
ret = pool_init(&p, 10 * cnt, SAMPLE_LENGTH(DEFAULT_SAMPLE_LENGTH), &memory_hugepage);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initilize memory pool");
|
||||
throw RuntimeError("Failed to initilize memory pool");
|
||||
|
||||
/* Initialize IO */
|
||||
ft = format_type_lookup(format);
|
||||
if (!ft)
|
||||
throw new RuntimeError("Unknown IO format '{}'", format);
|
||||
throw RuntimeError("Unknown IO format '{}'", format);
|
||||
|
||||
ret = io_init_auto(&io, ft, DEFAULT_SAMPLE_LENGTH, SAMPLE_HAS_ALL);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize IO");
|
||||
throw RuntimeError("Failed to initialize IO");
|
||||
|
||||
ret = io_check(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to validate IO configuration");
|
||||
throw RuntimeError("Failed to validate IO configuration");
|
||||
|
||||
ret = io_open(&io, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to open IO");
|
||||
throw RuntimeError("Failed to open IO");
|
||||
|
||||
/* Initialize hook */
|
||||
ht = hook_type_lookup(hook);
|
||||
if (!ht)
|
||||
throw new RuntimeError("Unknown hook function '{}'", hook);
|
||||
throw RuntimeError("Unknown hook function '{}'", hook);
|
||||
|
||||
ret = hook_init(&h, ht, nullptr, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize hook");
|
||||
throw RuntimeError("Failed to initialize hook");
|
||||
|
||||
ret = hook_parse(&h, cfg_cli);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse hook config");
|
||||
throw RuntimeError("Failed to parse hook config");
|
||||
|
||||
ret = hook_start(&h);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start hook");
|
||||
throw RuntimeError("Failed to start hook");
|
||||
|
||||
while (!stop) {
|
||||
ret = sample_alloc_many(&p, smps, cnt);
|
||||
if (ret != cnt)
|
||||
throw new RuntimeError("Failed to allocate %d smps from pool", cnt);
|
||||
throw RuntimeError("Failed to allocate %d smps from pool", cnt);
|
||||
|
||||
recv = io_scan(&io, smps, cnt);
|
||||
if (recv < 0) {
|
||||
if (io_eof(&io))
|
||||
break;
|
||||
|
||||
throw new RuntimeError("Failed to read from stdin");
|
||||
throw RuntimeError("Failed to read from stdin");
|
||||
}
|
||||
|
||||
logger->debug("Read {} smps from stdin", recv);
|
||||
|
@ -217,26 +217,26 @@ check: if (optarg == endptr)
|
|||
|
||||
sent = io_print(&io, smps, send);
|
||||
if (sent < 0)
|
||||
throw new RuntimeError("Failed to write to stdout");
|
||||
throw RuntimeError("Failed to write to stdout");
|
||||
|
||||
sample_free_many(smps, cnt);
|
||||
}
|
||||
|
||||
ret = hook_stop(&h);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop hook");
|
||||
throw RuntimeError("Failed to stop hook");
|
||||
|
||||
ret = hook_destroy(&h);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy hook");
|
||||
throw RuntimeError("Failed to destroy hook");
|
||||
|
||||
ret = io_close(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close IO");
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy IO");
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
|
||||
sample_free_many(smps, cnt);
|
||||
|
||||
|
@ -244,7 +244,7 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = pool_destroy(&p);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy memory pool");
|
||||
throw RuntimeError("Failed to destroy memory pool");
|
||||
|
||||
logger->info(CLR_GRN("Goodbye!"));
|
||||
|
||||
|
|
|
@ -152,35 +152,35 @@ int main(int argc, char *argv[])
|
|||
/* Checks system requirements*/
|
||||
auto required = utils::Version(KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN);
|
||||
if (kernel::getVersion() < required)
|
||||
throw new RuntimeError("Your kernel version is to old: required >= {}.{}", KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN);
|
||||
throw RuntimeError("Your kernel version is to old: required >= {}.{}", KERNEL_VERSION_MAJ, KERNEL_VERSION_MIN);
|
||||
#endif /* __linux__ */
|
||||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize signal subsystem");
|
||||
throw RuntimeError("Failed to initialize signal subsystem");
|
||||
|
||||
if (uri) {
|
||||
ret = sn.parseUri(uri);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse command line arguments");
|
||||
throw RuntimeError("Failed to parse command line arguments");
|
||||
}
|
||||
else
|
||||
logger->warn("No configuration file specified. Starting unconfigured. Use the API to configure this instance.");
|
||||
|
||||
ret = sn.check();
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to verify configuration");
|
||||
throw RuntimeError("Failed to verify configuration");
|
||||
|
||||
ret = sn.start();
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start super node");
|
||||
throw RuntimeError("Failed to start super node");
|
||||
|
||||
while (!stop)
|
||||
sn.run();
|
||||
|
||||
ret = sn.stop();
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop super node");
|
||||
throw RuntimeError("Failed to stop super node");
|
||||
|
||||
logger->info(CLR_GRN("Goodbye!"));
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@ static void * send_loop(void *ctx)
|
|||
while (!io_eof(dirs->send.io)) {
|
||||
allocated = sample_alloc_many(&dirs->send.pool, smps, dirs->send.node->out.vectorize);
|
||||
if (ret < 0)
|
||||
throw new RuntimeError("Failed to get {} samples out of send pool ({}).", dirs->send.node->out.vectorize, ret);
|
||||
throw RuntimeError("Failed to get {} samples out of send pool ({}).", dirs->send.node->out.vectorize, ret);
|
||||
else if (allocated < dirs->send.node->out.vectorize)
|
||||
logger->warn("Send pool underrun");
|
||||
|
||||
|
@ -207,7 +207,7 @@ static void * recv_loop(void *ctx)
|
|||
for (;;) {
|
||||
allocated = sample_alloc_many(&dirs->recv.pool, smps, dirs->recv.node->in.vectorize);
|
||||
if (allocated < 0)
|
||||
throw new RuntimeError("Failed to allocate {} samples from receive pool.", dirs->recv.node->in.vectorize);
|
||||
throw RuntimeError("Failed to allocate {} samples from receive pool.", dirs->recv.node->in.vectorize);
|
||||
else if (allocated < dirs->recv.node->in.vectorize)
|
||||
logger->warn("Receive pool underrun: allocated only {} of {} samples", allocated, dirs->recv.node->in.vectorize);
|
||||
|
||||
|
@ -292,7 +292,7 @@ int main(int argc, char *argv[])
|
|||
case 'o':
|
||||
ret = json_object_extend_str(cfg_cli, optarg);
|
||||
if (ret)
|
||||
throw new RuntimeError("Invalid option: {}", optarg);
|
||||
throw RuntimeError("Invalid option: {}", optarg);
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
|
@ -308,7 +308,7 @@ int main(int argc, char *argv[])
|
|||
continue;
|
||||
|
||||
check: if (optarg == endptr)
|
||||
throw new RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
throw RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
}
|
||||
|
||||
if (argc != optind + 2) {
|
||||
|
@ -324,35 +324,35 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize signals");
|
||||
throw RuntimeError("Failed to initialize signals");
|
||||
|
||||
if (uri) {
|
||||
ret = sn.parseUri(uri);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse configuration");
|
||||
throw RuntimeError("Failed to parse configuration");
|
||||
}
|
||||
else
|
||||
logger->warn("No configuration file specified. Starting unconfigured. Use the API to configure this instance.");
|
||||
|
||||
fmt = format_type_lookup(format);
|
||||
if (!fmt)
|
||||
throw new RuntimeError("Invalid format: {}", format);
|
||||
throw RuntimeError("Invalid format: {}", format);
|
||||
|
||||
ret = io_init_auto(&io, fmt, DEFAULT_SAMPLE_LENGTH, SAMPLE_HAS_ALL);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize IO");
|
||||
throw RuntimeError("Failed to initialize IO");
|
||||
|
||||
ret = io_check(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to validate IO configuration");
|
||||
throw RuntimeError("Failed to validate IO configuration");
|
||||
|
||||
ret = io_open(&io, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to open IO");
|
||||
throw RuntimeError("Failed to open IO");
|
||||
|
||||
node = sn.getNode(nodestr);
|
||||
if (!node)
|
||||
throw new RuntimeError("Node {} does not exist!", nodestr);
|
||||
throw RuntimeError("Node {} does not exist!", nodestr);
|
||||
|
||||
<<<<<<< HEAD
|
||||
#ifdef LIBWEBSOCKETS_FOUND
|
||||
|
@ -375,19 +375,19 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = node_type_start(node->_vt, reinterpret_cast<super_node *>(&sn));
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to intialize node type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
throw RuntimeError("Failed to intialize node type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
|
||||
ret = node_check(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Invalid node configuration");
|
||||
throw RuntimeError("Invalid node configuration");
|
||||
|
||||
ret = node_init2(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
|
||||
ret = node_start(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
|
||||
/* Start threads */
|
||||
if (dirs.recv.enabled) {
|
||||
|
@ -417,7 +417,7 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = node_stop(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to stop node {}: reason={}", node_name(node), ret);
|
||||
|
||||
ret = node_type_stop(node->_vt);
|
||||
if (ret)
|
||||
|
@ -437,11 +437,11 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = io_close(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close IO");
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy IO");
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
|
||||
logger->info(CLR_GRN("Goodbye!"));
|
||||
|
||||
|
|
|
@ -180,21 +180,21 @@ int main(int argc, char *argv[])
|
|||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to intialize signals");
|
||||
throw RuntimeError("Failed to intialize signals");
|
||||
|
||||
ft = format_type_lookup(format);
|
||||
if (!ft)
|
||||
throw new RuntimeError("Invalid output format '{}'", format);
|
||||
throw RuntimeError("Invalid output format '{}'", format);
|
||||
|
||||
memory_init(0); // Otherwise, ht->size in hash_table_hash() will be zero
|
||||
|
||||
nt = node_type_lookup("signal");
|
||||
if (!nt)
|
||||
throw new RuntimeError("Signal generation is not supported.");
|
||||
throw RuntimeError("Signal generation is not supported.");
|
||||
|
||||
ret = node_init(&n, nt);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize node");
|
||||
throw RuntimeError("Failed to initialize node");
|
||||
|
||||
cfg = parse_cli(argc, argv);
|
||||
if (!cfg) {
|
||||
|
@ -211,35 +211,35 @@ int main(int argc, char *argv[])
|
|||
// nt == n._vt
|
||||
ret = node_type_start(nt, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize node type: {}", node_type_name(nt));
|
||||
throw RuntimeError("Failed to initialize node type: {}", node_type_name(nt));
|
||||
|
||||
ret = node_check(&n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to verify node configuration");
|
||||
throw RuntimeError("Failed to verify node configuration");
|
||||
|
||||
ret = pool_init(&q, 16, SAMPLE_LENGTH(list_length(&n.signals)), &memory_heap);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize pool");
|
||||
throw RuntimeError("Failed to initialize pool");
|
||||
|
||||
ret = node_init2(&n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(&n), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(&n), ret);
|
||||
|
||||
ret = node_start(&n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(&n), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(&n), ret);
|
||||
|
||||
ret = io_init(&io, ft, &n.signals, IO_FLUSH | (SAMPLE_HAS_ALL & ~SAMPLE_HAS_OFFSET));
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize output");
|
||||
throw RuntimeError("Failed to initialize output");
|
||||
|
||||
ret = io_check(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to validate IO configuration");
|
||||
throw RuntimeError("Failed to validate IO configuration");
|
||||
|
||||
ret = io_open(&io, nullptr);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to open output");
|
||||
throw RuntimeError("Failed to open output");
|
||||
|
||||
while (!stop) {
|
||||
t = sample_alloc(&q);
|
||||
|
@ -255,23 +255,23 @@ int main(int argc, char *argv[])
|
|||
|
||||
ret = node_stop(&n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node");
|
||||
throw RuntimeError("Failed to stop node");
|
||||
|
||||
ret = node_destroy(&n);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy node");
|
||||
throw RuntimeError("Failed to destroy node");
|
||||
|
||||
ret = io_close(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close IO");
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy IO");
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
|
||||
ret = pool_destroy(&q);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy pool");
|
||||
throw RuntimeError("Failed to destroy pool");
|
||||
|
||||
logger->info(CLR_GRN("Goodbye!"));
|
||||
|
||||
|
|
|
@ -56,19 +56,19 @@ public:
|
|||
io.state = STATE_DESTROYED;
|
||||
ret = io_init_auto(&io, format, DEFAULT_SAMPLE_LENGTH, 0);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize IO");
|
||||
throw RuntimeError("Failed to initialize IO");
|
||||
|
||||
ret = io_check(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to validate IO configuration");
|
||||
throw RuntimeError("Failed to validate IO configuration");
|
||||
|
||||
ret = io_open(&io, path.c_str());
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to open file: {}", path);
|
||||
throw RuntimeError("Failed to open file: {}", path);
|
||||
|
||||
sample = sample_alloc(p);
|
||||
if (!sample)
|
||||
throw new RuntimeError("Failed to allocate samples");
|
||||
throw RuntimeError("Failed to allocate samples");
|
||||
}
|
||||
|
||||
~Side() noexcept(false)
|
||||
|
@ -77,11 +77,11 @@ public:
|
|||
|
||||
ret = io_close(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to close IO");
|
||||
throw RuntimeError("Failed to close IO");
|
||||
|
||||
ret = io_destroy(&io);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy IO");
|
||||
throw RuntimeError("Failed to destroy IO");
|
||||
|
||||
sample_decref(sample);
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ int main(int argc, char *argv[])
|
|||
continue;
|
||||
|
||||
check: if (optarg == endptr)
|
||||
throw new RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
throw RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
}
|
||||
|
||||
if (argc - optind < 2) {
|
||||
|
@ -178,15 +178,15 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = memory_init(0);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize memory system");
|
||||
throw RuntimeError("Failed to initialize memory system");
|
||||
|
||||
ret = pool_init(&pool, n, SAMPLE_LENGTH(DEFAULT_SAMPLE_LENGTH), &memory_heap);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize pool");
|
||||
throw RuntimeError("Failed to initialize pool");
|
||||
|
||||
struct format_type *fmt = format_type_lookup(format);
|
||||
if (!fmt)
|
||||
throw new RuntimeError("Invalid IO format: {}", format);
|
||||
throw RuntimeError("Invalid IO format: {}", format);
|
||||
|
||||
/* Open files */
|
||||
for (int i = 0; i < n; i++)
|
||||
|
@ -239,7 +239,7 @@ out: for (int i = 0; i < n; i++)
|
|||
|
||||
ret = pool_destroy(&pool);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy pool");
|
||||
throw RuntimeError("Failed to destroy pool");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
|
|
@ -135,7 +135,7 @@ int main(int argc, char *argv[])
|
|||
continue;
|
||||
|
||||
check: if (optarg == endptr)
|
||||
throw new RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
throw RuntimeError("Failed to parse parse option argument '-{} {}'", c, optarg);
|
||||
}
|
||||
|
||||
if (argc != optind + 2) {
|
||||
|
@ -148,35 +148,35 @@ check: if (optarg == endptr)
|
|||
|
||||
ret = utils::signals_init(quit);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize signals subsystem");
|
||||
throw RuntimeError("Failed to initialize signals subsystem");
|
||||
|
||||
if (uri) {
|
||||
ret = sn.parseUri(uri);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to parse configuration");
|
||||
throw RuntimeError("Failed to parse configuration");
|
||||
}
|
||||
else
|
||||
logger->warn("No configuration file specified. Starting unconfigured. Use the API to configure this instance.");
|
||||
|
||||
node = sn.getNode(nodestr);
|
||||
if (!node)
|
||||
throw new RuntimeError("There's no node with the name '{}'", nodestr);
|
||||
throw RuntimeError("There's no node with the name '{}'", nodestr);
|
||||
|
||||
ret = node_type_start(node->_vt, reinterpret_cast<super_node *>(&sn));
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node-type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
throw RuntimeError("Failed to start node-type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
|
||||
ret = node_init2(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
|
||||
ret = node_start(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to start node {}: reason={}", node_name(node), ret);
|
||||
|
||||
ret = hist_init(&hist, hist_buckets, hist_warmup);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to initialize histogram");
|
||||
throw RuntimeError("Failed to initialize histogram");
|
||||
|
||||
/* Print header */
|
||||
fprintf(stdout, "%17s%5s%10s%10s%10s%10s%10s\n", "timestamp", "seq", "rtt", "min", "max", "mean", "stddev");
|
||||
|
@ -216,21 +216,21 @@ check: if (optarg == endptr)
|
|||
fclose(f);
|
||||
}
|
||||
else
|
||||
throw new RuntimeError("Invalid file descriptor: {}", fd);
|
||||
throw RuntimeError("Invalid file descriptor: {}", fd);
|
||||
|
||||
hist_print(&hist, 1);
|
||||
|
||||
ret = hist_destroy(&hist);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to destroy histogram");
|
||||
throw RuntimeError("Failed to destroy histogram");
|
||||
|
||||
ret = node_stop(node);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node {}: reason={}", node_name(node), ret);
|
||||
throw RuntimeError("Failed to stop node {}: reason={}", node_name(node), ret);
|
||||
|
||||
ret = node_type_stop(node->_vt);
|
||||
if (ret)
|
||||
throw new RuntimeError("Failed to stop node-type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
throw RuntimeError("Failed to stop node-type {}: reason={}", node_type_name(node->_vt), ret);
|
||||
|
||||
delete smp_send;
|
||||
delete smp_recv;
|
||||
|
|
Loading…
Add table
Reference in a new issue