1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

Merge pull request #630 from VILLASframework/node-socket-no-supernode

fix segfaults if nodes are initialized without a super-node
This commit is contained in:
Steffen Vogel 2022-12-24 15:05:21 +01:00 committed by GitHub
commit d3a9375e78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 34 additions and 18 deletions

View file

@ -102,6 +102,9 @@ int villas::node::ethercat_type_start(villas::node::SuperNode *sn)
int ret;
json_error_t err;
if (sn == nullptr)
throw RuntimeError("EtherCAT node-type requires super-node");
json_t *json = sn->getConfig();
if (json) {
ret = json_unpack_ex(json, &err, 0, "{ s?: i, s?:i, s?: { s?: { s?: i, s?: i, s?: i } } }",

View file

@ -577,7 +577,8 @@ int villas::node::ngsi_type_start(villas::node::SuperNode *sn)
CRYPTO_set_id_callback(curl_ssl_thread_id_function);
CRYPTO_set_locking_callback(curl_ssl_locking_function);
sn->getLogger()->info("Setup libcurl/openssl locking primitives");
auto logger = logging.get("curl");
logger->info("Setup libcurl/openssl locking primitives");
#endif /* CURL_SSL_REQUIRES_LOCKING */
return curl_global_init(CURL_GLOBAL_ALL);

View file

@ -467,16 +467,18 @@ int villas::node::rtp_type_start(villas::node::SuperNode *sn)
return ret;
#ifdef WITH_NETEM
/* Gather list of used network interfaces */
for (auto *n : ncp.instances) {
auto *nc = dynamic_cast<NodeCompat *>(n);
auto *r = nc->getData<struct rtp>();
Interface *j = Interface::getEgress(&r->out.saddr_rtp.u.sa, sn);
if (sn != nullptr) {
// Gather list of used network interfaces
for (auto *n : ncp.instances) {
auto *nc = dynamic_cast<NodeCompat *>(n);
auto *r = nc->getData<struct rtp>();
Interface *j = Interface::getEgress(&r->out.saddr_rtp.u.sa, sn);
if (!j)
throw RuntimeError("Failed to find egress interface");
if (!j)
throw RuntimeError("Failed to find egress interface");
j->addNode(n);
j->addNode(n);
}
}
#endif /* WITH_NETEM */

View file

@ -40,18 +40,20 @@ static NodeCompatFactory ncp(&p);
int villas::node::socket_type_start(villas::node::SuperNode *sn)
{
#ifdef WITH_NETEM
/* Gather list of used network interfaces */
for (auto *n : ncp.instances) {
auto *nc = dynamic_cast<NodeCompat *>(n);
auto *s = nc->getData<struct Socket>();
if (sn != nullptr) {
// Gather list of used network interfaces
for (auto *n : ncp.instances) {
auto *nc = dynamic_cast<NodeCompat *>(n);
auto *s = nc->getData<struct Socket>();
if (s->layer == SocketLayer::UNIX)
continue;
if (s->layer == SocketLayer::UNIX)
continue;
/* Determine outgoing interface */
Interface *j = Interface::getEgress((struct sockaddr *) &s->out.saddr, sn);
/* Determine outgoing interface */
Interface *j = Interface::getEgress((struct sockaddr *) &s->out.saddr, sn);
j->addNode(n);
j->addNode(n);
}
}
#endif /* WITH_NETEM */

View file

@ -9,6 +9,7 @@
#include <villas/node_compat.hpp>
#include <villas/nodes/stats.hpp>
#include <villas/exceptions.hpp>
#include <villas/hook.hpp>
#include <villas/stats.hpp>
#include <villas/super_node.hpp>
@ -71,6 +72,9 @@ invalid_format:
int villas::node::stats_node_type_start(villas::node::SuperNode *sn)
{
if (sn == nullptr)
throw RuntimeError("Stats node-type requires super-node");
nodes = sn->getNodes();
return 0;

View file

@ -14,6 +14,7 @@
#include <libwebsockets.h>
#include <villas/timing.hpp>
#include <villas/exceptions.hpp>
#include <villas/utils.hpp>
#include <villas/node_compat.hpp>
#include <villas/nodes/websocket.hpp>
@ -333,6 +334,9 @@ int villas::node::websocket_protocol_cb(struct lws *wsi, enum lws_callback_reaso
int villas::node::websocket_type_start(villas::node::SuperNode *sn)
{
if (sn == nullptr)
throw RuntimeError("WebSocket node-type requires super-node");
web = sn->getWeb();
if (!web->isEnabled())
return -1;