diff --git a/include/villas/node.hpp b/include/villas/node.hpp index f09c7fd74..8bc52de20 100644 --- a/include/villas/node.hpp +++ b/include/villas/node.hpp @@ -237,9 +237,9 @@ public: } virtual - int getNetemFDs(int fds[]) + std::vector getNetemFDs() { - return 0; + return {}; } virtual diff --git a/include/villas/node_compat.hpp b/include/villas/node_compat.hpp index 8c2dcfc10..fcf744eeb 100644 --- a/include/villas/node_compat.hpp +++ b/include/villas/node_compat.hpp @@ -166,7 +166,7 @@ public: * @return The number of file descriptors which have been put into \p sds. */ virtual - int getNetemFDs(int fds[]); + std::vector getNetemFDs(); /** Return a memory allocator which should be used for sample pools passed to this node. */ virtual diff --git a/lib/node.cpp b/lib/node.cpp index 61068e632..111200722 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -254,12 +254,7 @@ int Node::start() #ifdef __linux__ /* Set fwmark for outgoing packets if netem is enabled for this node */ if (fwmark >= 0) { - int fds[16]; - int num_sds = getNetemFDs(fds); - - for (int i = 0; i < num_sds; i++) { - int fd = fds[i]; - + for (auto fd : getNetemFDs()) { ret = setsockopt(fd, SOL_SOCKET, SO_MARK, &fwmark, sizeof(fwmark)); if (ret) throw RuntimeError("Failed to set FW mark for outgoing packets"); diff --git a/lib/node_compat.cpp b/lib/node_compat.cpp index c1f81431a..b7d63f33c 100644 --- a/lib/node_compat.cpp +++ b/lib/node_compat.cpp @@ -217,11 +217,19 @@ std::vector NodeCompat::getPollFDs() return {}; } -int NodeCompat::getNetemFDs(int fds[]) +std::vector NodeCompat::getNetemFDs() { - return _vt->netem_fds - ? _vt->netem_fds(this, fds) - : -1; + if (_vt->netem_fds) { + int ret, fds[16]; + + ret = _vt->netem_fds(this, fds); + if (ret < 0) + return {}; + + return std::vector(fds, fds+ret); + } + + return {}; } struct memory::Type * NodeCompat::getMemoryType()