mirror of
https://github.com/transmission/transmission
synced 2024-12-27 01:57:52 +00:00
(trunk libT) resolve thread condition in libtransmission by moving the `waiting' state variable to the stack in tr_sessionSet() and tr_sessionInit()
This commit is contained in:
parent
283b6d6a36
commit
696aa7aba6
2 changed files with 7 additions and 7 deletions
|
@ -499,6 +499,7 @@ struct init_data
|
||||||
{
|
{
|
||||||
tr_session * session;
|
tr_session * session;
|
||||||
const char * configDir;
|
const char * configDir;
|
||||||
|
tr_bool done;
|
||||||
tr_bool messageQueuingEnabled;
|
tr_bool messageQueuingEnabled;
|
||||||
tr_benc * clientSettings;
|
tr_benc * clientSettings;
|
||||||
};
|
};
|
||||||
|
@ -535,13 +536,13 @@ tr_sessionInit( const char * tag,
|
||||||
assert( session->events != NULL );
|
assert( session->events != NULL );
|
||||||
|
|
||||||
/* run the rest in the libtransmission thread */
|
/* run the rest in the libtransmission thread */
|
||||||
++session->waiting;
|
data.done = FALSE;
|
||||||
data.session = session;
|
data.session = session;
|
||||||
data.configDir = configDir;
|
data.configDir = configDir;
|
||||||
data.messageQueuingEnabled = messageQueuingEnabled;
|
data.messageQueuingEnabled = messageQueuingEnabled;
|
||||||
data.clientSettings = clientSettings;
|
data.clientSettings = clientSettings;
|
||||||
tr_runInEventThread( session, tr_sessionInitImpl, &data );
|
tr_runInEventThread( session, tr_sessionInitImpl, &data );
|
||||||
while( session->waiting > 0 )
|
while( !data.done )
|
||||||
tr_wait_msec( 100 );
|
tr_wait_msec( 100 );
|
||||||
|
|
||||||
return session;
|
return session;
|
||||||
|
@ -639,7 +640,6 @@ tr_sessionInitImpl( void * vdata )
|
||||||
tr_statsInit( session );
|
tr_statsInit( session );
|
||||||
|
|
||||||
session->web = tr_webInit( session );
|
session->web = tr_webInit( session );
|
||||||
--session->waiting;
|
|
||||||
|
|
||||||
tr_sessionSet( session, &settings );
|
tr_sessionSet( session, &settings );
|
||||||
|
|
||||||
|
@ -650,6 +650,7 @@ tr_sessionInitImpl( void * vdata )
|
||||||
|
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
tr_bencFree( &settings );
|
tr_bencFree( &settings );
|
||||||
|
data->done = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -805,20 +806,20 @@ sessionSetImpl( void * vdata )
|
||||||
else if( tr_bencDictFindBool( settings, TR_PREFS_KEY_ALT_SPEED_ENABLED, &boolVal ) )
|
else if( tr_bencDictFindBool( settings, TR_PREFS_KEY_ALT_SPEED_ENABLED, &boolVal ) )
|
||||||
useAltSpeed( session, boolVal, FALSE );
|
useAltSpeed( session, boolVal, FALSE );
|
||||||
|
|
||||||
--session->waiting;
|
data->done = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tr_sessionSet( tr_session * session, struct tr_benc * settings )
|
tr_sessionSet( tr_session * session, struct tr_benc * settings )
|
||||||
{
|
{
|
||||||
struct init_data data;
|
struct init_data data;
|
||||||
|
data.done = FALSE;
|
||||||
data.session = session;
|
data.session = session;
|
||||||
data.clientSettings = settings;
|
data.clientSettings = settings;
|
||||||
|
|
||||||
/* run the rest in the libtransmission thread */
|
/* run the rest in the libtransmission thread */
|
||||||
++session->waiting;
|
|
||||||
tr_runInEventThread( session, sessionSetImpl, &data );
|
tr_runInEventThread( session, sessionSetImpl, &data );
|
||||||
while( session->waiting > 0 )
|
while( !data.done )
|
||||||
tr_wait_msec( 100 );
|
tr_wait_msec( 100 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ struct tr_session
|
||||||
|
|
||||||
tr_benc removedTorrents;
|
tr_benc removedTorrents;
|
||||||
|
|
||||||
int waiting;
|
|
||||||
int umask;
|
int umask;
|
||||||
|
|
||||||
int speedLimit[2];
|
int speedLimit[2];
|
||||||
|
|
Loading…
Reference in a new issue