diff --git a/libtransmission/natpmp.c b/libtransmission/natpmp.c index d205eabbd..ff487c864 100644 --- a/libtransmission/natpmp.c +++ b/libtransmission/natpmp.c @@ -167,11 +167,14 @@ tr_natpmpPulse( struct tr_natpmp * nat, logVal( "readnatpmpresponseorretry", val ); if( val >= 0 ) { - tr_ninf( getKey( ), _( - "no longer forwarding port %d" ), nat->port ); - nat->state = TR_NATPMP_IDLE; - nat->port = -1; - nat->isMapped = 0; + const int port = resp.pnu.newportmapping.privateport; + tr_ninf( getKey( ), _( "no longer forwarding port %d" ), port ); + if( nat->port == port ) + { + nat->port = -1; + nat->state = TR_NATPMP_IDLE; + nat->isMapped = 0; + } } else if( val != NATPMP_TRYAGAIN ) {