Changeset 9850


Ignore:
Timestamp:
Jan 1, 2010, 10:35:49 PM (12 years ago)
Author:
charles
Message:

(trunk libT) resolve thread condition in libtransmission by moving the `waiting' state variable to the stack in tr_sessionSet() and tr_sessionInit()

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/session.c

    r9849 r9850  
    500500    tr_session  * session;
    501501    const char  * configDir;
     502    tr_bool       done;
    502503    tr_bool       messageQueuingEnabled;
    503504    tr_benc     * clientSettings;
     
    536537
    537538    /* run the rest in the libtransmission thread */
    538     ++session->waiting;
     539    data.done = FALSE;
    539540    data.session = session;
    540541    data.configDir = configDir;
     
    542543    data.clientSettings = clientSettings;
    543544    tr_runInEventThread( session, tr_sessionInitImpl, &data );
    544     while( session->waiting > 0 )
     545    while( !data.done )
    545546        tr_wait_msec( 100 );
    546547
     
    640641
    641642    session->web = tr_webInit( session );
    642     --session->waiting;
    643643
    644644    tr_sessionSet( session, &settings );
     
    651651    /* cleanup */
    652652    tr_bencFree( &settings );
     653    data->done = TRUE;
    653654}
    654655
     
    806807        useAltSpeed( session, boolVal, FALSE );
    807808
    808     --session->waiting;
     809    data->done = TRUE;
    809810}
    810811
     
    813814{
    814815    struct init_data data;
     816    data.done = FALSE;
    815817    data.session = session;
    816818    data.clientSettings = settings;
    817819
    818820    /* run the rest in the libtransmission thread */
    819     ++session->waiting;
    820821    tr_runInEventThread( session, sessionSetImpl, &data );
    821     while( session->waiting > 0 )
     822    while( !data.done )
    822823        tr_wait_msec( 100 );
    823824}
  • trunk/libtransmission/session.h

    r9847 r9850  
    5858    tr_benc                      removedTorrents;
    5959
    60     int                          waiting;
    6160    int                          umask;
    6261
Note: See TracChangeset for help on using the changeset viewer.