Skip to content

Commit

Permalink
fix flaky calltype test
Browse files Browse the repository at this point in the history
  • Loading branch information
olofkallander committed Nov 16, 2024
1 parent 880ddeb commit 4e01e0d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 1 addition & 4 deletions test/integration/emulator/FakeUdpEndpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ bool FakeUdpEndpoint::openPort(uint16_t port)
}

_localPort.setPort(port);
logger::info("adding %s to network", "FakeUdpEndpoint", _localPort.toString().c_str());
_network->addLocal(this);
_state = Endpoint::State::CREATED;
return true;
Expand Down Expand Up @@ -341,10 +342,6 @@ void FakeUdpEndpoint::onReceive(fakenet::Protocol protocol,

bool FakeUdpEndpoint::hasIp(const transport::SocketAddress& target)
{
if (_state != State::CONNECTED)
{
return false;
}
return target == _localPort;
}

Expand Down
18 changes: 16 additions & 2 deletions test/transport/FakeNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,18 @@ void Internet::process(const uint64_t timestamp)
packet->data,
packet->length,
timestamp);
packet.reset();
break;
}
}
if (packet)
{
logger::debug("no destination for %s, %zuB, nodes %zu",
"Internet",
packet->target.toString().c_str(),
packet->length,
_nodes.size());
}
}

{
Expand Down Expand Up @@ -276,7 +285,7 @@ void Firewall::dispatchNAT(const Packet& packet, const uint64_t timestamp)
toString(packet.protocol),
packet.source.toString().c_str(),
packet.target.toString().c_str(),
mapping.first.toString().c_str());
portPair->lanPort.ipToString().c_str());
endpoint->onReceive(packet.protocol,
packet.source,
portPair->lanPort,
Expand Down Expand Up @@ -373,7 +382,9 @@ transport::SocketAddress Firewall::acquirePortMapping(const Protocol protocol, c
}

auto publicAddress = (source.getFamily() == AF_INET6 ? _publicIpv6 : _publicIpv4);
while (portMap.contains(transport::SocketAddress(publicAddress, ++_portCount))) {}
while (portMap.contains(transport::SocketAddress(publicAddress, ++_portCount)))
{
}

return addPortMapping(protocol, source, _portCount);
}
Expand Down Expand Up @@ -521,6 +532,7 @@ std::shared_ptr<Internet> InternetRunner::getNetwork()
void InternetRunner::internetThreadRun()
{
concurrency::setThreadName("Internet");
logger::info("internet thread started at interval %" PRIu64, "InternetRunner", _tickInterval);
while (_command != quit)
{
if (_command == State::running)
Expand All @@ -531,12 +543,14 @@ void InternetRunner::internetThreadRun()
}
else if (_command == paused)
{
logger::info("internet thread paused...", "InternetRunner");
_state = paused;
while (_command == paused)
{
// check in to TimeTurner if enabled
utils::Time::nanoSleep(utils::Time::ms * 10);
}
logger::info("internet thread resumed...", "InternetRunner");
}
}
}
Expand Down

0 comments on commit 4e01e0d

Please sign in to comment.