mirror of
https://github.com/transmission/transmission
synced 2024-12-26 01:27:28 +00:00
(trunk libT) #2416 "crash in event_queue_insert" -- instead of freeing libevent's event objects, pool and reuse them. *sigh*
This commit is contained in:
parent
1eb0cdd7c6
commit
6151881a03
1 changed files with 17 additions and 5 deletions
|
@ -55,14 +55,23 @@ struct tr_web
|
||||||
tr_session * session;
|
tr_session * session;
|
||||||
tr_address addr;
|
tr_address addr;
|
||||||
struct event timer_event;
|
struct event timer_event;
|
||||||
tr_list * freeme;
|
tr_list * active_events;
|
||||||
|
tr_list * inactive_events;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void
|
||||||
|
event_list_node_free( void * event )
|
||||||
|
{
|
||||||
|
event_del( event );
|
||||||
|
tr_free( event );
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
web_free( tr_web * g )
|
web_free( tr_web * g )
|
||||||
{
|
{
|
||||||
curl_multi_cleanup( g->multi );
|
curl_multi_cleanup( g->multi );
|
||||||
tr_list_free( &g->freeme, tr_free );
|
tr_list_free( &g->active_events, event_list_node_free );
|
||||||
|
tr_list_free( &g->inactive_events, event_list_node_free );
|
||||||
evtimer_del( &g->timer_event );
|
evtimer_del( &g->timer_event );
|
||||||
memset( g, TR_MEMORY_TRASH, sizeof( struct tr_web ) );
|
memset( g, TR_MEMORY_TRASH, sizeof( struct tr_web ) );
|
||||||
tr_free( g );
|
tr_free( g );
|
||||||
|
@ -294,7 +303,8 @@ sock_cb( CURL * e UNUSED, curl_socket_t fd, int action,
|
||||||
if( io_event != NULL )
|
if( io_event != NULL )
|
||||||
{
|
{
|
||||||
event_del( io_event );
|
event_del( io_event );
|
||||||
tr_list_append( &web->freeme, io_event );
|
tr_list_remove_data( &web->active_events, io_event );
|
||||||
|
tr_list_append( &web->inactive_events, io_event );
|
||||||
curl_multi_assign( web->multi, fd, NULL );
|
curl_multi_assign( web->multi, fd, NULL );
|
||||||
/*fprintf( stderr, "-1 io_events to %d\n", --num_events );*/
|
/*fprintf( stderr, "-1 io_events to %d\n", --num_events );*/
|
||||||
}
|
}
|
||||||
|
@ -308,8 +318,11 @@ sock_cb( CURL * e UNUSED, curl_socket_t fd, int action,
|
||||||
if( io_event != NULL )
|
if( io_event != NULL )
|
||||||
event_del( io_event );
|
event_del( io_event );
|
||||||
else {
|
else {
|
||||||
io_event = tr_new0( struct event, 1 );
|
io_event = tr_list_pop_front( &web->inactive_events );
|
||||||
|
if( io_event == NULL )
|
||||||
|
io_event = tr_new0( struct event, 1 );
|
||||||
curl_multi_assign( web->multi, fd, io_event );
|
curl_multi_assign( web->multi, fd, io_event );
|
||||||
|
tr_list_append( &web->active_events, io_event );
|
||||||
/*fprintf( stderr, "+1 io_events to %d\n", ++num_events );*/
|
/*fprintf( stderr, "+1 io_events to %d\n", ++num_events );*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +341,6 @@ static void
|
||||||
libevent_timer_cb( int fd UNUSED, short what UNUSED, void * vg )
|
libevent_timer_cb( int fd UNUSED, short what UNUSED, void * vg )
|
||||||
{
|
{
|
||||||
tr_web * g = vg;
|
tr_web * g = vg;
|
||||||
tr_list_free( &g->freeme, tr_free );
|
|
||||||
dbgmsg( "libevent timer is done" );
|
dbgmsg( "libevent timer is done" );
|
||||||
tr_multi_perform( g, CURL_SOCKET_TIMEOUT, 0 );
|
tr_multi_perform( g, CURL_SOCKET_TIMEOUT, 0 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue