Changeset 5579


Ignore:
Timestamp:
Apr 10, 2008, 7:02:24 PM (15 years ago)
Author:
charles
Message:

#853: transmission-(daemon|gtk) segfault when querying status

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/server.c

    r5514 r5579  
    487487        if( TORRENT_ID_VALID( tor ) )
    488488        {
    489             const tr_info * inf = torrent_info( tor );
    490             if( 0 > ipc_addinfo( added, tor, inf, 0 ) )
     489            if( 0 > ipc_addinfo( added, tor, torrent_handle( tor ), 0 ) )
    491490            {
    492491                errnomsg( "failed to build message" );
     
    545544    if( TORRENT_ID_VALID( tor ) )
    546545    {
    547         const tr_info * inf;
    548546        val = ipc_initval( client->ipc, IPC_MSG_INFO, tag, &pk, TYPE_LIST );
    549547        if( NULL == val )
     
    553551            return;
    554552        }
    555         inf = torrent_info( tor );
    556         if( 0 > ipc_addinfo( val, tor, inf, 0 ) )
     553        if( 0 > ipc_addinfo( val, tor, torrent_handle( tor ), 0 ) )
    557554        {
    558555            errnomsg( "failed to build message" );
     
    768765addinfo( benc_val_t * list, int id, int types )
    769766{
    770     const tr_info * inf = torrent_info( id );
    771     return inf ? ipc_addinfo( list, id, inf, types ) : 0;
     767    tr_torrent * tor = torrent_handle( id );
     768    return tor ? ipc_addinfo( list, id, tor, types ) : 0;
    772769}
    773770
     
    775772addstat( benc_val_t * list, int id, int types )
    776773{
    777     const tr_stat * st = torrent_stat( id );
    778     return st ? ipc_addstat( list, id, st, types ) : 0;
     774    tr_torrent * tor = torrent_handle( id );
     775    return tor ? ipc_addstat( list, id, tor, types ) : 0;
    779776}
    780777
     
    879876    for( ii = 0; val->val.l.count > ii; ii++ )
    880877    {
    881         const tr_info * inf;
    882878        hash = &val->val.l.vals[ii];
    883879        if( !tr_bencIsString(hash) || SHA_DIGEST_LENGTH * 2 != hash->val.s.i )
     
    892888            continue;
    893889        }
    894         inf = torrent_info( found );
    895         assert( NULL != inf );
    896         if( 0 > ipc_addinfo( pkinf, found, inf, IPC_INF_HASH ) )
     890        if( 0 > ipc_addinfo( pkinf, found, torrent_handle( found ), IPC_INF_HASH ) )
    897891        {
    898892            errnomsg( "failed to build message" );
  • trunk/daemon/torrents.c

    r5517 r5579  
    231231}
    232232
     233tr_torrent *
     234torrent_handle( int id )
     235{
     236    const struct tor * tor = idlookup( id );
     237    return tor ? tor->tor : NULL;
     238}
     239   
    233240const tr_info *
    234241torrent_info( int id )
    235242{
    236     const struct tor * tor = idlookup( id );
    237     return tor ? tr_torrentInfo( tor->tor ) : NULL;
     243    return tr_torrentInfo( torrent_handle( id ) );
    238244}
    239245
     
    241247torrent_stat( int id )
    242248{
    243     struct tor * tor = idlookup( id );
    244     return tor ? tr_torrentStat( tor->tor ) : NULL;
     249    return tr_torrentStat( torrent_handle( id ) );
    245250}
    246251
  • trunk/daemon/torrents.h

    r5143 r5579  
    3939void         torrent_verify              ( int );
    4040void         torrent_remove              ( int );
    41 const tr_info  * torrent_info          ( int );
    42 const tr_stat  * torrent_stat          ( int );
     41tr_torrent     * torrent_handle          ( int );
     42const tr_info  * torrent_info            ( int );
     43const tr_stat  * torrent_stat            ( int );
    4344int          torrent_lookup              ( const uint8_t * );
    4445void       * torrent_iter                ( void *, int * );
  • trunk/gtk/ipc.c

    r5506 r5579  
    619619
    620620static int
    621 addinfo( TrTorrent * tor, enum ipc_msg msgid, int torid, int types,
     621addinfo( TrTorrent * gtor, enum ipc_msg msgid, int torid, int types,
    622622         tr_benc * val )
    623623{
     624    tr_torrent * tor = tr_torrent_handle( gtor );
     625
    624626    if( IPC_MSG_INFO == msgid )
    625     {
    626         const tr_info * inf = tr_torrent_info( tor );
    627         return ipc_addinfo( val, torid, inf, types );
    628     }
     627        return ipc_addinfo( val, torid, tor, types );
    629628    else
    630     {
    631         const tr_stat * st = tr_torrent_stat( tor );
    632         return ipc_addstat( val, torid, st, types );
    633     }
     629        return ipc_addstat( val, torid, tor, types );
    634630}
    635631
     
    794790    int                    ii, torid;
    795791    TrTorrent            * tor;
    796     const tr_info        * inf;
    797792    uint8_t              * buf;
    798793    size_t                 size;
     
    820815            continue;
    821816        }
    822         inf = tr_torrent_info( tor );
    823         if( 0 > ipc_addinfo( pkval, torid, inf, IPC_INF_HASH ) )
     817        if( 0 > ipc_addinfo( pkval, torid, tr_torrent_handle( tor ), IPC_INF_HASH ) )
    824818        {
    825819            tr_bencFree( &packet );
  • trunk/libtransmission/ipcparse.c

    r5547 r5579  
    553553ipc_addinfo( tr_benc         * list,
    554554             int               torrent_id,
    555              const tr_info   * inf,
     555             tr_torrent      * tor,
    556556             int               types )
    557557{
     
    559559    int          ii, jj, kk;
    560560    tr_file_index_t ff;
     561    const tr_info * inf = tr_torrentInfo( tor );
    561562
    562563    /* always send torrent id */
  • trunk/libtransmission/ipcparse.h

    r5547 r5579  
    171171                                    const int             * ids );
    172172
    173 int          ipc_addinfo   ( struct tr_benc *, int,
    174                              const struct tr_info *, int );
     173struct tr_torrent;
    175174
    176 struct tr_torrent;
     175int          ipc_addinfo   ( struct tr_benc     * appendme_list,
     176                             int                  torrent_id,
     177                             struct tr_torrent  * tor,
     178                             int                  info_types );
    177179
    178180int          ipc_addstat   ( struct tr_benc     * appendme_list,
Note: See TracChangeset for help on using the changeset viewer.