code review: explicitly list all states to start discovering from
This commit is contained in:
parent
effc776e1a
commit
4f4831a82b
|
@ -96,7 +96,7 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled)
|
|||
}
|
||||
}
|
||||
|
||||
if (state_ <= State::Err && is_mapped_ && (!is_enabled || local_port_ != local_port))
|
||||
if ((state_ == State::Idle || state_ == State::Err) && is_mapped_ && (!is_enabled || local_port_ != local_port))
|
||||
{
|
||||
state_ = State::SendUnmap;
|
||||
}
|
||||
|
@ -140,7 +140,8 @@ tr_natpmp::PulseResult tr_natpmp::pulse(tr_port local_port, bool is_enabled)
|
|||
}
|
||||
}
|
||||
|
||||
if (state_ <= State::Err && (is_mapped_ ? tr_time() >= renew_time_ : is_enabled && has_discovered_))
|
||||
if ((state_ == State::Idle || state_ == State::Err) &&
|
||||
(is_mapped_ ? tr_time() >= renew_time_ : is_enabled && has_discovered_))
|
||||
{
|
||||
state_ = State::SendMap;
|
||||
}
|
||||
|
|
|
@ -306,7 +306,7 @@ tr_port_forwarding_state tr_upnpPulse(
|
|||
freeUPNPDevlist(devlist);
|
||||
}
|
||||
|
||||
if (handle->state <= UpnpState::Failed && handle->isMapped &&
|
||||
if ((handle->state == UpnpState::Idle || handle->state == UpnpState::Failed) && handle->isMapped &&
|
||||
(!is_enabled || handle->advertised_port != advertised_port || handle->local_port != local_port))
|
||||
{
|
||||
handle->state = UpnpState::WillUnmap;
|
||||
|
@ -339,7 +339,7 @@ tr_port_forwarding_state tr_upnpPulse(
|
|||
handle->local_port = {};
|
||||
}
|
||||
|
||||
if (handle->state <= UpnpState::Failed && is_enabled && !handle->isMapped)
|
||||
if ((handle->state == UpnpState::Idle || handle->state == UpnpState::Failed) && is_enabled && !handle->isMapped)
|
||||
{
|
||||
handle->state = UpnpState::WillMap;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue