mirror of
https://github.com/transmission/transmission
synced 2024-12-25 17:17:31 +00:00
move the gateway discovery from init() to start() so that tr_init() doesn't block.
This commit is contained in:
parent
e168cf3f69
commit
4792788d24
1 changed files with 14 additions and 7 deletions
|
@ -29,6 +29,7 @@ struct tr_upnp
|
||||||
char lanaddr[16];
|
char lanaddr[16];
|
||||||
unsigned int isForwarding : 1;
|
unsigned int isForwarding : 1;
|
||||||
unsigned int isEnabled : 1;
|
unsigned int isEnabled : 1;
|
||||||
|
unsigned int hasDiscovered : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,13 +40,7 @@ tr_upnp*
|
||||||
tr_upnpInit( void )
|
tr_upnpInit( void )
|
||||||
{
|
{
|
||||||
tr_upnp * ret = tr_new0( tr_upnp, 1 );
|
tr_upnp * ret = tr_new0( tr_upnp, 1 );
|
||||||
struct UPNPDev * devlist = upnpDiscover( 2000, NULL );
|
|
||||||
if( UPNP_GetValidIGD( devlist, &ret->urls, &ret->data, ret->lanaddr, sizeof(ret->lanaddr))) {
|
|
||||||
tr_dbg( "Found Internet Gateway Device '%s'", ret->urls.controlURL );
|
|
||||||
tr_dbg( "Local LAN IP Address is '%s'", ret->lanaddr );
|
|
||||||
}
|
|
||||||
ret->port = -1;
|
ret->port = -1;
|
||||||
freeUPNPDevlist( devlist );
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +48,8 @@ void
|
||||||
tr_upnpClose( tr_upnp * handle )
|
tr_upnpClose( tr_upnp * handle )
|
||||||
{
|
{
|
||||||
tr_upnpStop( handle );
|
tr_upnpStop( handle );
|
||||||
FreeUPNPUrls( &handle->urls );
|
if( handle->hasDiscovered )
|
||||||
|
FreeUPNPUrls( &handle->urls );
|
||||||
tr_free( handle );
|
tr_free( handle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +60,17 @@ tr_upnpClose( tr_upnp * handle )
|
||||||
void
|
void
|
||||||
tr_upnpStart( tr_upnp * handle )
|
tr_upnpStart( tr_upnp * handle )
|
||||||
{
|
{
|
||||||
|
if( !handle->hasDiscovered )
|
||||||
|
{
|
||||||
|
struct UPNPDev * devlist = upnpDiscover( 2000, NULL );
|
||||||
|
if( UPNP_GetValidIGD( devlist, &handle->urls, &handle->data, handle->lanaddr, sizeof(handle->lanaddr))) {
|
||||||
|
tr_dbg( "Found Internet Gateway Device '%s'", handle->urls.controlURL );
|
||||||
|
tr_dbg( "Local LAN IP Address is '%s'", handle->lanaddr );
|
||||||
|
}
|
||||||
|
freeUPNPDevlist( devlist );
|
||||||
|
handle->hasDiscovered = 1;
|
||||||
|
}
|
||||||
|
|
||||||
handle->isEnabled = 1;
|
handle->isEnabled = 1;
|
||||||
|
|
||||||
if( handle->port >= 0 )
|
if( handle->port >= 0 )
|
||||||
|
|
Loading…
Reference in a new issue