fix portmapping crash.

This commit is contained in:
Charles Kerr 2007-11-22 06:13:57 +00:00
parent 87d4bcd278
commit 6df942138b
1 changed files with 26 additions and 3 deletions

View File

@ -182,10 +182,33 @@ tr_globalIsLocked( const struct tr_handle * handle )
***********************************************************************
*
**********************************************************************/
void tr_setBindPort( tr_handle * h, int port )
struct bind_port_data
{
h->isPortSet = 1;
tr_sharedSetPort( h->shared, port );
tr_handle * handle;
int port;
};
static void
tr_setBindPortImpl( void * vdata )
{
struct bind_port_data * data = vdata;
tr_handle * handle = data->handle;
const int port = data->port;
handle->isPortSet = 1;
tr_sharedSetPort( handle->shared, port );
tr_free( data );
}
void
tr_setBindPort( tr_handle * handle, int port )
{
struct bind_port_data * data = tr_new( struct bind_port_data, 1 );
data->handle = handle;
data->port = port;
tr_runInEventThread( handle, tr_setBindPortImpl, data );
}
int