mirror of
https://github.com/transmission/transmission
synced 2024-12-25 01:03:01 +00:00
(trunk libT) add more assertions to make Biiaru crash more^H^H^H^H^H^H^H^H^H^H^H^H^H^H^H^Hhelp track down the cause of Biiaru's crashes
This commit is contained in:
parent
8ec25a2fdb
commit
8c9d5359b5
3 changed files with 21 additions and 8 deletions
|
@ -420,7 +420,10 @@ static void
|
|||
io_dtor( void * vio )
|
||||
{
|
||||
tr_peerIo * io = vio;
|
||||
|
||||
assert( tr_isPeerIo( io ) );
|
||||
assert( tr_amInEventThread( io->session ) );
|
||||
assert( io->session->events != NULL );
|
||||
|
||||
dbgmsg( io, "in tr_peerIo destructor" );
|
||||
event_del( &io->event_read );
|
||||
|
@ -844,6 +847,8 @@ tr_peerIoFlush( tr_peerIo * io, tr_direction dir, size_t limit )
|
|||
static void
|
||||
event_enable( tr_peerIo * io, short event )
|
||||
{
|
||||
assert( tr_amInEventThread( io->session ) );
|
||||
assert( io->session->events != NULL );
|
||||
assert( event_initialized( &io->event_read ) );
|
||||
assert( event_initialized( &io->event_write ) );
|
||||
|
||||
|
@ -865,6 +870,8 @@ event_enable( tr_peerIo * io, short event )
|
|||
static void
|
||||
event_disable( struct tr_peerIo * io, short event )
|
||||
{
|
||||
assert( tr_amInEventThread( io->session ) );
|
||||
assert( io->session->events != NULL );
|
||||
assert( event_initialized( &io->event_read ) );
|
||||
assert( event_initialized( &io->event_write ) );
|
||||
|
||||
|
@ -893,6 +900,8 @@ tr_peerIoSetEnabled( tr_peerIo * io,
|
|||
|
||||
assert( tr_isPeerIo( io ) );
|
||||
assert( tr_isDirection( dir ) );
|
||||
assert( tr_amInEventThread( io->session ) );
|
||||
assert( io->session->events != NULL );
|
||||
|
||||
if( isEnabled )
|
||||
event_enable( io, event );
|
||||
|
|
|
@ -455,10 +455,8 @@ tr_sessionInit( const char * tag,
|
|||
tr_setConfigDir( session, configDir );
|
||||
|
||||
tr_netInit( ); /* must go before tr_eventInit */
|
||||
|
||||
tr_eventInit( session );
|
||||
while( !session->events )
|
||||
tr_wait( 50 );
|
||||
assert( session->events != NULL );
|
||||
|
||||
session->peerMgr = tr_peerMgrNew( session );
|
||||
|
||||
|
|
|
@ -232,7 +232,6 @@ static void
|
|||
libeventThreadFunc( void * veh )
|
||||
{
|
||||
tr_event_handle * eh = veh;
|
||||
|
||||
tr_dbg( "Starting libevent thread" );
|
||||
|
||||
#ifndef WIN32
|
||||
|
@ -240,16 +239,18 @@ libeventThreadFunc( void * veh )
|
|||
signal( SIGPIPE, SIG_IGN );
|
||||
#endif
|
||||
|
||||
eh->base = event_init( );
|
||||
eh->session->events = eh;
|
||||
|
||||
/* listen to the pipe's read fd */
|
||||
event_set( &eh->pipeEvent, eh->fds[0], EV_READ | EV_PERSIST,
|
||||
readFromPipe,
|
||||
veh );
|
||||
event_set( &eh->pipeEvent, eh->fds[0], EV_READ | EV_PERSIST, readFromPipe, veh );
|
||||
event_add( &eh->pipeEvent, NULL );
|
||||
event_set_log_callback( logFunc );
|
||||
|
||||
/* loop until all the events are done */
|
||||
event_dispatch( );
|
||||
|
||||
/* shut down the thread */
|
||||
tr_lockFree( eh->lock );
|
||||
event_base_free( eh->base );
|
||||
eh->session->events = NULL;
|
||||
|
@ -262,12 +263,17 @@ tr_eventInit( tr_session * session )
|
|||
{
|
||||
tr_event_handle * eh;
|
||||
|
||||
session->events = NULL;
|
||||
|
||||
eh = tr_new0( tr_event_handle, 1 );
|
||||
eh->lock = tr_lockNew( );
|
||||
pipe( eh->fds );
|
||||
eh->session = session;
|
||||
eh->base = event_init( );
|
||||
eh->thread = tr_threadNew( libeventThreadFunc, eh );
|
||||
|
||||
/* wait until the libevent thread is running */
|
||||
while( session->events == NULL )
|
||||
tr_wait( 100 );
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in a new issue