Traversal: update pending-packet time on socket timeout

Pending traversal packets were only expired after receive events. If a
client did not acknowledge a response and no more packets arrived, the
server retained the pending entry indefinitely.

Update the current time before handling socket timeouts. Pending packets
will then retry and expire while the server is idle.
This commit is contained in:
Acts1631 committed 2026-09-27 19:06:43 -04:00
1 parent bb3558a70e
commit 93097f65ea
1 file changed
+3 -3
+3 -3
View File
@@ -470,6 +470,9 @@ int main()
FD_SET(sock, &readSet);
FD_SET(sockAlt, &readSet);
rv = select(std::max(sock, sockAlt) + 1, &readSet, nullptr, nullptr, &tv);
currentTime = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::steady_clock::now().time_since_epoch())
.count();
if (rv < 0)
{
if (errno != EINTR && errno != EAGAIN)
@@ -499,9 +502,6 @@ int main()
// note: switch to recvmmsg (yes, mmsg) if this becomes
// expensive
rv = recvfrom(recvsock, &packet, sizeof(packet), 0, (sockaddr*)&raddr, &addrLen);
currentTime = std::chrono::duration_cast<std::chrono::microseconds>(
std::chrono::system_clock::now().time_since_epoch())
.count();
if (rv < 0)
{
if (errno != EINTR && errno != EAGAIN)