Changeset 9642


Ignore:
Timestamp:
Nov 30, 2009, 4:58:03 AM (11 years ago)
Author:
charles
Message:

(trunk) #1663 "crashes on shutdown if libevent loop doesn't exit soon enough" -- maybe crash less frequently now.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r9634 r9642  
    702702}
    703703
    704 static gpointer
    705 quitThreadFunc( gpointer gdata )
     704static gboolean
     705onSessionClosed( gpointer gdata )
    706706{
    707707    struct cbdata * cbdata = gdata;
    708     gdk_threads_enter( );
    709 
    710     tr_core_close( cbdata->core );
    711708
    712709    /* shutdown the gui */
     
    733730
    734731    gtk_main_quit( );
     732
     733    return FALSE;
     734}
     735
     736static gpointer
     737sessionCloseThreadFunc( gpointer gdata )
     738{
     739    /* since tr_sessionClose() is a blocking function,
     740     * call it from another thread... when it's done,
     741     * punt the GUI teardown back to the GTK+ thread */
     742    struct cbdata * cbdata = gdata;
     743    gdk_threads_enter( );
     744    tr_core_close( cbdata->core );
     745    gtr_idle_add( onSessionClosed, gdata );
    735746    gdk_threads_leave( );
    736 
    737747    return NULL;
    738748}
     
    801811
    802812    /* shut down libT */
    803     g_thread_create( quitThreadFunc, vdata, TRUE, NULL );
     813    g_thread_create( sessionCloseThreadFunc, vdata, TRUE, NULL );
    804814}
    805815
  • trunk/libtransmission/session.c

    r9604 r9642  
    15871587}
    15881588
    1589 #define SHUTDOWN_MAX_SECONDS 30
     1589#define SHUTDOWN_MAX_SECONDS 20
    15901590
    15911591void
     
    16031603    while( !session->isClosed && !deadlineReached( deadline ) )
    16041604    {
    1605         dbgmsg(
    1606             "waiting for the shutdown commands to run in the main thread" );
     1605        dbgmsg( "waiting for the libtransmission thread to finish" );
    16071606        tr_wait( 100 );
    16081607    }
     
    16241623    /* close the libtransmission thread */
    16251624    tr_eventClose( session );
    1626     while( session->events && !deadlineReached( deadline ) )
    1627     {
    1628         dbgmsg( "waiting for the libevent thread to shutdown cleanly" );
     1625    while( session->events != NULL )
     1626    {
     1627        static tr_bool forced = FALSE;
     1628        dbgmsg( "waiting for libtransmission thread to finish" );
    16291629        tr_wait( 100 );
     1630        if( deadlineReached( deadline ) && !forced )
     1631        {
     1632            event_loopbreak( );
     1633            forced = TRUE;
     1634        }
    16301635    }
    16311636
Note: See TracChangeset for help on using the changeset viewer.