Commit dd9fdf60 authored by Ivan Vilata-i-Balaguer's avatar Ivan Vilata-i-Balaguer
Browse files

Better rounding of UPnP pauses, avoid gaps in mapping availability.

parent c1ba8f64
......@@ -133,13 +133,14 @@ private:
// but only if we just got to add mappings to buggy IGDs.
if (!earlier_buggy_timeout) return failure_wait_time;
auto now = steady_clock::now();
if (*earlier_buggy_timeout <= now) return timeout_pause;
return duration_cast<seconds>(*earlier_buggy_timeout - now + timeout_pause);
auto buggy_refresh = *earlier_buggy_timeout + timeout_pause;
if (buggy_refresh < now) return seconds(0);
return ceil<seconds>(buggy_refresh - now);
// Wait until a little before mappings would time out to refresh them.
auto round_elapsed = steady_clock::now() - round_begin;
if (round_elapsed >= success_wait_time) return seconds(0);
return success_wait_time - duration_cast<seconds>(round_elapsed);
return duration_cast<seconds>(success_wait_time - round_elapsed);
async_sleep(exec, wait_time, cancel, yield);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment