Changeset 7533
- Timestamp:
- Dec 29, 2008, 9:17:48 PM (12 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/tracker.c
r7528 r7533 99 99 char escaped[SHA_DIGEST_LENGTH * 3 + 1]; 100 100 char * name; 101 int torrentId; 101 102 102 103 /* corresponds to the peer_id sent as a tracker request parameter. … … 175 176 176 177 static tr_tracker * 177 findTracker( tr_session * session, 178 const uint8_t * hash ) 179 { 180 tr_torrent * torrent = tr_torrentFindFromHash( session, hash ); 178 findTracker( tr_session * session, int torrentId ) 179 { 180 tr_torrent * torrent = tr_torrentFindFromId( session, torrentId ); 181 181 182 182 return torrent ? torrent->tracker : NULL; … … 187 187 ***/ 188 188 189 static const tr_tracker_event emptyEvent = { 0, NULL, NULL, NULL,0, 0 };189 static const tr_tracker_event emptyEvent = { 0, NULL, NULL, 0, 0 }; 190 190 191 191 static void … … 197 197 { 198 198 tr_tracker_event event = emptyEvent; 199 event.hash = t->hash;200 199 event.messageType = type; 201 200 event.text = msg; … … 233 232 tr_tracker_event event = emptyEvent; 234 233 235 event.hash = t->hash;236 234 event.messageType = TR_TRACKER_PEERS; 237 235 event.allAreSeeds = allAreSeeds; … … 383 381 384 382 static void 385 onStoppedResponse( tr_session *session,383 onStoppedResponse( tr_session * session, 386 384 long responseCode UNUSED, 387 385 const void * response UNUSED, 388 386 size_t responseLen UNUSED, 389 void * torrent_hash)390 { 391 tr_tracker * t = findTracker( session, t orrent_hash);387 void * torrentId ) 388 { 389 tr_tracker * t = findTracker( session, tr_ptr2int( torrentId ) ); 392 390 if( t ) 393 391 { … … 403 401 dbgmsg( NULL, "got a response to some `stop' message" ); 404 402 onReqDone( session ); 405 tr_free( torrent_hash );406 403 } 407 404 … … 411 408 const void * response, 412 409 size_t responseLen, 413 void * torrent_hash)410 void * torrentId ) 414 411 { 415 412 int retry; … … 419 416 420 417 onReqDone( session ); 421 t = findTracker( session, torrent_hash ); 422 tr_free( torrent_hash ); 418 t = findTracker( session, tr_ptr2int( torrentId ) ); 423 419 if( !t ) /* tracker's been closed */ 424 420 return; … … 610 606 const void * response, 611 607 size_t responseLen, 612 void * torrent _hash)608 void * torrentId ) 613 609 { 614 610 int success = FALSE; … … 617 613 618 614 onReqDone( session ); 619 t = findTracker( session, torrent_hash ); 620 tr_free( torrent_hash ); 615 t = findTracker( session, tr_ptr2int( torrentId ) ); 621 616 if( !t ) /* tracker's been closed... */ 622 617 return; … … 732 727 struct tr_tracker_request 733 728 { 734 uint8_t torrent_hash[SHA_DIGEST_LENGTH];735 729 int reqtype; /* TR_REQ_* */ 730 int torrentId; 736 731 char * url; 737 732 tr_web_done_func * done_func; … … 813 808 req->done_func = isStopping ? onStoppedResponse : onTrackerResponse; 814 809 req->url = tr_strdup( EVBUFFER_DATA( url ) ); 815 memcpy( req->torrent_hash, tracker->hash, SHA_DIGEST_LENGTH );810 req->torrentId = tracker->torrentId; 816 811 817 812 evbuffer_free( url ); … … 836 831 req->url = tr_strdup( EVBUFFER_DATA( url ) ); 837 832 req->done_func = onScrapeResponse; 838 memcpy( req->torrent_hash, tracker->hash, SHA_DIGEST_LENGTH );833 req->torrentId = tracker->torrentId; 839 834 840 835 evbuffer_free( url ); … … 883 878 { 884 879 struct tr_tracker_request * req = vreq; 885 tr_tracker * t = findTracker( req->session, 886 req->torrent_hash ); 880 tr_tracker * t = findTracker( req->session, req->torrentId ); 887 881 888 882 if( t ) … … 905 899 ++req->session->tracker->runningCount; 906 900 907 tr_webRun( req->session, req->url, NULL, req->done_func,908 tr_memdup( req->torrent_hash, SHA_DIGEST_LENGTH) );901 tr_webRun( req->session, req->url, NULL, 902 req->done_func, tr_int2ptr( req->torrentId ) ); 909 903 910 904 freeRequest( req ); … … 1063 1057 t->lastScrapeResponse = -1; 1064 1058 t->manualAnnounceAllowedAt = ~(time_t)0; 1065 t->name = tr_strdup( info->name ); 1066 t->randOffset = tr_cryptoRandInt( 30 ); 1059 t->name = tr_strdup( info->name ); 1060 t->torrentId = torrent->uniqueId; 1061 t->randOffset = tr_cryptoRandInt( 30 ); 1067 1062 memcpy( t->hash, info->hash, SHA_DIGEST_LENGTH ); 1068 1063 escape( t->escaped, info->hash, SHA_DIGEST_LENGTH ); -
trunk/libtransmission/tracker.h
r7404 r7533 52 52 TrackerEventType messageType; 53 53 54 /* the torrent's 20-character sha1 hash */55 const uint8_t * hash;56 57 54 /* for TR_TRACKER_WARNING and TR_TRACKER_ERROR */ 58 55 const char * text; -
trunk/libtransmission/utils.c
r7529 r7533 1285 1285 return dir==TR_UP || dir==TR_DOWN; 1286 1286 } 1287 1288 int 1289 tr_ptr2int( void* v ) 1290 { 1291 return (intptr_t)v; 1292 } 1293 1294 void* 1295 tr_int2ptr( int i ) 1296 { 1297 return (void*)(intptr_t)i; 1298 } -
trunk/libtransmission/utils.h
r7529 r7533 402 402 && tr_bitfieldHasFast( bitfield, nth ) ) 403 403 404 double tr_getRatio( double numerator, 405 double denominator ); 404 double tr_getRatio( double numerator, double denominator ); 405 406 407 int tr_ptr2int( void* ); 408 409 void* tr_int2ptr( int ); 406 410 407 411 #ifdef __cplusplus
Note: See TracChangeset
for help on using the changeset viewer.