Changeset 12238


Ignore:
Timestamp:
Mar 26, 2011, 12:06:04 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) remove the tr_session argument from the announce/scrape response callbacks

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer-common.h

    r12204 r12238  
    9797tr_scrape_response;
    9898
    99 typedef void tr_scrape_response_func( tr_session                * session,
    100                                       const tr_scrape_response  * response,
     99typedef void tr_scrape_response_func( const tr_scrape_response  * response,
    101100                                      void                      * user_data );
    102101
     
    225224tr_announce_response;
    226225
    227 typedef void tr_announce_response_func( tr_session                 * session,
    228                                         const tr_announce_response * response,
     226typedef void tr_announce_response_func( const tr_announce_response * response,
    229227                                        void                       * userdata );
    230228
  • trunk/libtransmission/announcer-http.c

    r12229 r12238  
    159159struct announce_data
    160160{
    161     tr_session * session;
    162161    tr_announce_response response;
    163162    tr_announce_response_func * response_func;
     
    172171
    173172    if( data->response_func != NULL )
    174         data->response_func( data->session,
    175                              &data->response,
    176                              data->response_func_user_data );
     173        data->response_func( &data->response, data->response_func_user_data );
    177174
    178175    tr_free( data->response.pex6 );
     
    286283
    287284    d = tr_new0( struct announce_data, 1 );
    288     d->session = session;
    289285    d->response_func = response_func;
    290286    d->response_func_user_data = response_func_user_data;
     
    305301struct scrape_data
    306302{
    307     tr_session * session;
    308303    tr_scrape_response response;
    309304    tr_scrape_response_func * response_func;
     
    318313
    319314    if( data->response_func != NULL )
    320         data->response_func( data->session,
    321                              &data->response,
    322                              data->response_func_user_data );
     315        data->response_func( &data->response, data->response_func_user_data );
    323316
    324317    tr_free( data->response.errmsg );
     
    437430
    438431    d = tr_new0( struct scrape_data, 1 );
    439     d->session = session;
    440432    d->response.url = tr_strdup( request->url );
    441433    d->response_func = response_func;
  • trunk/libtransmission/announcer-udp.c

    r12237 r12238  
    202202
    203203static void
    204 tau_scrape_request_finished( tr_session                       * session,
    205                              const struct tau_scrape_request  * request )
     204tau_scrape_request_finished( const struct tau_scrape_request  * request )
    206205{
    207206    if( request->callback != NULL )
    208         request->callback( session, &request->response, request->user_data );
    209 }
    210 
    211 static void
    212 tau_scrape_request_fail( tr_session                 * session,
    213                          struct tau_scrape_request  * request,
     207        request->callback( &request->response, request->user_data );
     208}
     209
     210static void
     211tau_scrape_request_fail( struct tau_scrape_request  * request,
    214212                         bool                         did_connect,
    215213                         bool                         did_timeout,
     
    219217    request->response.did_timeout = did_timeout;
    220218    request->response.errmsg = tr_strdup( errmsg );
    221     tau_scrape_request_finished( session, request );
    222 }
    223 
    224 static void
    225 on_scrape_response( tr_session                 * session,
    226                     struct tau_scrape_request  * request,
     219    tau_scrape_request_finished( request );
     220}
     221
     222static void
     223on_scrape_response( struct tau_scrape_request  * request,
    227224                    tau_action_t                 action,
    228225                    struct evbuffer            * buf )
     
    247244        }
    248245
    249         tau_scrape_request_finished( session, request );
     246        tau_scrape_request_finished( request );
    250247    }
    251248    else
     
    259256            errmsg = tr_strdup( _( "Unknown error" ) );
    260257
    261         tau_scrape_request_fail( session, request, true, false, errmsg );
     258        tau_scrape_request_fail( request, true, false, errmsg );
    262259        tr_free( errmsg );
    263260    }
     
    357354
    358355static void
    359 tau_announce_request_finished( tr_session                        * session,
    360                                const struct tau_announce_request * request )
     356tau_announce_request_finished( const struct tau_announce_request * request )
    361357{
    362358    if( request->callback != NULL )
    363         request->callback( session, &request->response, request->user_data );
    364 }
    365 
    366 static void
    367 tau_announce_request_fail( tr_session                   * session,
    368                            struct tau_announce_request  * request,
     359        request->callback( &request->response, request->user_data );
     360}
     361
     362static void
     363tau_announce_request_fail( struct tau_announce_request  * request,
    369364                           bool                           did_connect,
    370365                           bool                           did_timeout,
     
    374369    request->response.did_timeout = did_timeout;
    375370    request->response.errmsg = tr_strdup( errmsg );
    376     tau_announce_request_finished( session, request );
    377 }
    378 
    379 static void
    380 on_announce_response( tr_session                   * session,
    381                       struct tau_announce_request  * request,
     371    tau_announce_request_finished( request );
     372}
     373
     374static void
     375on_announce_response( struct tau_announce_request  * request,
    382376                      tau_action_t                   action,
    383377                      struct evbuffer              * buf )
     
    398392                                            NULL, 0,
    399393                                            &request->response.pex_count );
    400         tau_announce_request_finished( session, request );
     394        tau_announce_request_finished( request );
    401395    }
    402396    else
     
    409403            errmsg = tr_strdup( _( "Unknown error" ) );
    410404
    411         tau_announce_request_fail( session, request, true, false, errmsg );
     405        tau_announce_request_fail( request, true, false, errmsg );
    412406        tr_free( errmsg );
    413407    }
     
    470464    reqs = &tracker->scrapes;
    471465    for( i=0, n=tr_ptrArraySize(reqs); i<n; ++i )
    472         tau_scrape_request_fail( tracker->session, tr_ptrArrayNth( reqs, i ),
     466        tau_scrape_request_fail( tr_ptrArrayNth( reqs, i ),
    473467                                 did_connect, did_timeout, errmsg );
    474468    tr_ptrArrayDestruct( reqs, (PtrArrayForeachFunc)tau_scrape_request_free );
     
    478472    reqs = &tracker->announces;
    479473    for( i=0, n=tr_ptrArraySize(reqs); i<n; ++i )
    480         tau_announce_request_fail( tracker->session, tr_ptrArrayNth( reqs, i ),
     474        tau_announce_request_fail( tr_ptrArrayNth( reqs, i ),
    481475                                   did_connect, did_timeout, errmsg );
    482476    tr_ptrArrayDestruct( reqs, (PtrArrayForeachFunc)tau_announce_request_free );
     
    623617        if( cancel_all || ( req->created_at + TAU_REQUEST_TTL < now ) ) {
    624618            dbgmsg( tracker->key, "timeout announce req %p", req );
    625             tau_announce_request_fail( tracker->session, req, false, true, NULL );
     619            tau_announce_request_fail( req, false, true, NULL );
    626620            tau_announce_request_free( req );
    627621            tr_ptrArrayRemove( reqs, i );
     
    636630        if( cancel_all || ( req->created_at + TAU_REQUEST_TTL < now ) ) {
    637631            dbgmsg( tracker->key, "timeout scrape req %p", req );
    638             tau_scrape_request_fail( tracker->session, req, false, true, NULL );
     632            tau_scrape_request_fail( req, false, true, NULL );
    639633            tau_scrape_request_free( req );
    640634            tr_ptrArrayRemove( reqs, i );
     
    910904                dbgmsg( tracker->key, "%"PRIu32" is an announce request!", transaction_id );
    911905                tr_ptrArrayRemove( reqs, j );
    912                 on_announce_response( session, req, action_id, buf );
     906                on_announce_response( req, action_id, buf );
    913907                tau_announce_request_free( req );
    914908                evbuffer_free( buf );
     
    924918                dbgmsg( tracker->key, "%"PRIu32" is a scrape request!", transaction_id );
    925919                tr_ptrArrayRemove( reqs, j );
    926                 on_scrape_response( session, req, action_id, buf );
     920                on_scrape_response( req, action_id, buf );
    927921                tau_scrape_request_free( req );
    928922                evbuffer_free( buf );
  • trunk/libtransmission/announcer.c

    r12226 r12238  
    962962    time_t timeSent;
    963963    tr_announce_event event;
     964    tr_session * session;
    964965
    965966    /** If the request succeeds, the value for tier's "isRunning" flag */
     
    991992
    992993static void
    993 on_announce_done( tr_session                  * session,
    994                   const tr_announce_response  * response,
     994on_announce_done( const tr_announce_response  * response,
    995995                  void                        * vdata )
    996996{
    997     tr_announcer * announcer = session->announcer;
     997   
    998998    struct announce_data * data = vdata;
     999    tr_announcer * announcer = data->session->announcer;
    9991000    tr_tier * tier = getTier( announcer, response->info_hash, data->tierId );
    10001001    const time_t now = tr_time( );
     
    11671168
    11681169    data = tr_new0( struct announce_data, 1 );
     1170    data->session = announcer->session;
    11691171    data->tierId = tier->key;
    11701172    data->isRunningOnSuccess = tor->isRunning;
     
    12261228
    12271229static void
    1228 on_scrape_done( tr_session                * session,
    1229                 const tr_scrape_response  * response,
    1230                 void                      * user_data UNUSED )
     1230on_scrape_done( const tr_scrape_response  * response,
     1231                void                      * vsession )
    12311232{
    12321233    int i;
    12331234    const time_t now = tr_time( );
     1235    tr_session * session = vsession;
    12341236    tr_announcer * announcer = session->announcer;
    12351237
     
    13741376    /* send the requests we just built */
    13751377    for( i=0; i<request_count; ++i )
    1376         scrape_request_delegate( announcer, &requests[i], on_scrape_done, NULL );
     1378        scrape_request_delegate( announcer, &requests[i], on_scrape_done, announcer->session );
    13771379
    13781380    /* cleanup */
Note: See TracChangeset for help on using the changeset viewer.