mirror of
https://git.rwth-aachen.de/acs/public/villas/node/
synced 2025-03-09 00:00:00 +01:00
node: align Node::getPollFDs() with Node::getNetemFDs()
This commit is contained in:
parent
d0a6af8fe6
commit
b98f455752
4 changed files with 16 additions and 13 deletions
|
@ -237,9 +237,9 @@ public:
|
|||
}
|
||||
|
||||
virtual
|
||||
int getNetemFDs(int fds[])
|
||||
std::vector<int> getNetemFDs()
|
||||
{
|
||||
return 0;
|
||||
return {};
|
||||
}
|
||||
|
||||
virtual
|
||||
|
|
|
@ -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<int> getNetemFDs();
|
||||
|
||||
/** Return a memory allocator which should be used for sample pools passed to this node. */
|
||||
virtual
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -217,11 +217,19 @@ std::vector<int> NodeCompat::getPollFDs()
|
|||
return {};
|
||||
}
|
||||
|
||||
int NodeCompat::getNetemFDs(int fds[])
|
||||
std::vector<int> 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<int>(fds, fds+ret);
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
struct memory::Type * NodeCompat::getMemoryType()
|
||||
|
|
Loading…
Add table
Reference in a new issue