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

Adjust wait for UPnP announcement round with actual spent time.

Adding mappings to several IGDs and then checking whether they have already
added the mapping can delay the wait too much and make existing mappings
expire, so play safe by subtracting actual spent time from the wait.
parent 51d41799
......@@ -67,6 +67,8 @@ private:
while (true)
auto round_begin = steady_clock::now();
auto r_igds = upnp::igd::discover(exec, yield);
if (cancel) return;
......@@ -112,7 +114,9 @@ private:
auto wait_time = [&] () -> seconds {
if (success_cnt == 0) return failure_wait_time;
return success_wait_time;
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);
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