Changeset 9880


Ignore:
Timestamp:
Jan 4, 2010, 11:06:34 PM (11 years ago)
Author:
charles
Message:

(1.7x) backport to 1.7x: r9642 #1663 "Crashes on shutdown if libevent loop doesn't exit soon enough"

Location:
branches/1.7x
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/1.7x/gtk/main.c

    r9358 r9880  
    628628}
    629629
    630 static gpointer
    631 quitThreadFunc( gpointer gdata )
     630static gboolean
     631onSessionClosed( gpointer gdata )
    632632{
    633633    struct cbdata * cbdata = gdata;
    634     gdk_threads_enter( );
    635 
    636     tr_core_close( cbdata->core );
    637634
    638635    /* shutdown the gui */
     
    659656
    660657    gtk_main_quit( );
     658
     659    return FALSE;
     660}
     661
     662static gpointer
     663sessionCloseThreadFunc( gpointer gdata )
     664{
     665    /* since tr_sessionClose() is a blocking function,
     666     * call it from another thread... when it's done,
     667     * punt the GUI teardown back to the GTK+ thread */
     668    struct cbdata * cbdata = gdata;
     669    gdk_threads_enter( );
     670    tr_core_close( cbdata->core );
     671    gtr_idle_add( onSessionClosed, gdata );
    661672    gdk_threads_leave( );
    662 
    663673    return NULL;
    664674}
     
    727737
    728738    /* shut down libT */
    729     g_thread_create( quitThreadFunc, vdata, TRUE, NULL );
     739    g_thread_create( sessionCloseThreadFunc, vdata, TRUE, NULL );
    730740}
    731741
  • branches/1.7x/libtransmission/session.c

    r8967 r9880  
    15051505}
    15061506
    1507 #define SHUTDOWN_MAX_SECONDS 30
     1507#define SHUTDOWN_MAX_SECONDS 20
    15081508
    15091509void
     
    15211521    while( !session->isClosed && !deadlineReached( deadline ) )
    15221522    {
    1523         dbgmsg(
    1524             "waiting for the shutdown commands to run in the main thread" );
     1523        dbgmsg( "waiting for the libtransmission thread to finish" );
    15251524        tr_wait( 100 );
    15261525    }
     
    15421541    /* close the libtransmission thread */
    15431542    tr_eventClose( session );
    1544     while( session->events && !deadlineReached( deadline ) )
    1545     {
    1546         dbgmsg( "waiting for the libevent thread to shutdown cleanly" );
     1543    while( session->events != NULL )
     1544    {
     1545        static tr_bool forced = FALSE;
     1546        dbgmsg( "waiting for libtransmission thread to finish" );
    15471547        tr_wait( 100 );
     1548        if( deadlineReached( deadline ) && !forced )
     1549        {
     1550            event_loopbreak( );
     1551            forced = TRUE;
     1552        }
    15481553    }
    15491554
Note: See TracChangeset for help on using the changeset viewer.