Changeset 2876
- Timestamp:
- Aug 20, 2007, 2:29:36 AM (16 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/inout.c
r2846 r2876 309 309 if( success ) 310 310 { 311 tr_ inf( "Piece %d hash OK", pieceIndex );311 tr_dbg( "Piece %d hash OK", pieceIndex ); 312 312 tr_cpPieceAdd( tor->completion, pieceIndex ); 313 313 } -
trunk/libtransmission/tracker.c
r2868 r2876 51 51 #define REQ_TIMEOUT_INTERVAL_SEC 60 52 52 53 /* the number of peers that is our goal*/53 /* the value of the 'numwant' argument passed in tracker requests */ 54 54 #define NUMWANT 75 55 55 … … 184 184 static tr_ptrArray_t * connections = NULL; 185 185 if( !connections ) 186 connections = tr_ptrArrayNew( );186 connections = tr_ptrArrayNew( ); 187 187 188 188 tmp.address = (char*) address; … … 236 236 event.peerCount = count; 237 237 event.peerCompact = peers; 238 tr_inf( " torrent %sgot %d new peers", tor->torrent->info.name, count );238 tr_inf( "Torrent \"%s\" got %d new peers", tor->torrent->info.name, count ); 239 239 tr_publisherPublish( tor->publisher, tor, &event ); 240 240 } … … 282 282 283 283 if( !t->scrapeTag ) 284 t->scrapeTag = tr_timerNew( t->handle, onTrackerScrapeNow, t, NULL, 1000 ); 284 t->scrapeTag = tr_timerNew( t->handle, 285 onTrackerScrapeNow, t, 286 NULL, 1000 ); 285 287 } 286 288 … … 358 360 359 361 static void 360 escape( char * out, const uint8_t * in, int in_len ) 362 escape( char * out, const uint8_t * in, int in_len ) /* rfc2396 */ 361 363 { 362 364 const uint8_t *end = in + in_len; … … 570 572 Tracker * t = (Tracker*) vt; 571 573 572 tr_inf( " scrape response from '%s': %s",574 tr_inf( "Got scrape response from '%s': %s", 573 575 t->primaryAddress, 574 576 (req ? req->response_code_line : "(null)") ); … … 578 580 int numResponses = 0; 579 581 benc_val_t benc, *files; 580 int n_scraping = tr_ptrArraySize( t->scraping );582 const int n_scraping = tr_ptrArraySize( t->scraping ); 581 583 const int bencLoaded = !parseBencResponse( req, &benc ); 582 584 … … 621 623 tor, NULL, 622 624 t->scrapeIntervalMsec ); 623 tr_dbg( "torrent '%s' scraped. re-scraping in %d seconds", 625 tr_dbg( "Torrent '%s' scrape successful." 626 " Rescraping in %d seconds", 624 627 tor->torrent->info.name, t->scrapeIntervalMsec/1000 ); 625 628 } … … 638 641 tr_trackerStop( torrents[i] ); 639 642 tr_ptrArrayClear( t->scraping ); 640 n_scraping = 0;641 643 642 644 t->multiscrapeMax = INT_MAX; … … 652 654 if( ( 0 < numResponses ) && ( numResponses < n_scraping ) ) 653 655 t->multiscrapeMax = numResponses; 654 }655 else if( !req )656 {657 int i, n;658 Torrent ** torrents = (Torrent**)659 tr_ptrArrayPeek( t->scraping, &n );660 for( i=0; i<n; ++i )661 torrents[i]->scrapeTag = tr_timerNew( t->handle,662 onTorrentScrapeNow,663 torrents[i], NULL,664 t->scrapeIntervalMsec );665 tr_ptrArrayClear( t->scraping );666 667 t->multiscrapeMax = INT_MAX;668 656 } 669 657 … … 732 720 tr_ptrArrayErase( t->scrapeQueue, 0, ask_n ); 733 721 734 /* don't scrape again until we have some response from the tracker */735 tr_timerFree( &t->scrapeTag );736 737 722 /* ping the tracker */ 738 tr_inf( "scrape to %s:%d: %s", address->address, address->port, uri ); 723 tr_inf( "Sending scrape to tracker %s:%d: %s", 724 address->address, address->port, uri ); 739 725 evcon = getConnection( address->address, address->port ); 740 assert( evcon != NULL );741 726 evhttp_connection_set_timeout( evcon, SCRAPE_TIMEOUT_INTERVAL_SEC ); 742 727 req = evhttp_request_new( onScrapeResponse, t ); … … 746 731 } 747 732 733 t->scrapeTag = NULL; 748 734 return FALSE; 749 735 } … … 756 742 757 743 static int 758 torrentIsRunning( Torrent * tor ) 759 { 760 return tor->lastRequest && strcmp( tor->lastRequest, "stopped" ); 744 torrentIsRunning( const Torrent * tor ) 745 { 746 return ( tor != NULL ) 747 && ( tor->lastRequest != NULL ) 748 && ( strcmp( tor->lastRequest, "stopped" ) ); 761 749 } 762 750 … … 835 823 } 836 824 837 static int838 onReannounceNow( void * vtor );839 840 825 /* handle braindead trackers whose minimums is higher 841 826 than the interval. */ … … 856 841 t->announceIntervalMsec = t->minAnnounceIntervalMsec; 857 842 } 843 844 static int onReannounceNow( void * vtor ); 858 845 859 846 static void … … 865 852 int reannounceInterval; 866 853 867 tr_inf( " torrent \"%s\" tracker response: %s",854 tr_inf( "Torrent \"%s\" tracker response: %s", 868 855 tor->torrent->info.name, 869 856 ( req ? req->response_code_line : "(null)") ); … … 971 958 struct evhttp_connection * evcon = NULL; 972 959 973 tr_inf( "tracker request to %s:%d: %s", address->address, 974 address->port, uri ); 960 tr_inf( "Torrent \"%s\" sending '%s' to tracker %s:%d: %s", 961 tor->torrent->info.name, 962 (eventName ? eventName : "periodic announce"), 963 address->address, address->port, 964 uri ); 975 965 976 966 /* kill any pending requests */ … … 987 977 tor->httpReq = evhttp_request_new( onTrackerResponse, tor ); 988 978 addCommonHeaders( tor->tracker, tor->httpReq ); 989 tr_evhttp_make_request( tor->tracker->handle, evcon, tor->httpReq, EVHTTP_REQ_GET, uri ); 979 tr_evhttp_make_request( tor->tracker->handle, evcon, 980 tor->httpReq, EVHTTP_REQ_GET, uri ); 990 981 } 991 982 … … 996 987 onReannounceNow( void * vtor ) 997 988 { 998 sendTrackerRequest( (Torrent*)vtor, "" ); 989 Torrent * tor = (Torrent *) vtor; 990 sendTrackerRequest( tor, "" ); 991 tor->reannounceTag = NULL; 999 992 return FALSE; 1000 993 } … … 1030 1023 /* return true if this torrent's currently running 1031 1024 and it's been long enough since the last announce */ 1032 return ( tor != NULL ) 1033 && ( tor->reannounceTag != NULL ) 1025 return ( torrentIsRunning( tor ) ) 1034 1026 && ( tr_date() >= tor->manualAnnounceAllowedAt ); 1035 1027 } … … 1041 1033 int * setme_seederCount ) 1042 1034 { 1043 if( setme_completedCount )1035 if( setme_completedCount ) 1044 1036 *setme_completedCount = tor->timesDownloaded; 1045 1037 1046 if( setme_leecherCount )1038 if( setme_leecherCount ) 1047 1039 *setme_leecherCount = tor->leechers; 1048 1040 1049 if( setme_seederCount )1041 if( setme_seederCount ) 1050 1042 *setme_seederCount = tor->seeders; 1051 1043 } -
trunk/libtransmission/trevent.c
r2874 r2876 34 34 #include "utils.h" 35 35 36 / /#define DEBUG36 /* #define DEBUG */ 37 37 #ifdef DEBUG 38 38 #undef tr_dbg -
trunk/libtransmission/trevent.h
r2874 r2876 16 16 **/ 17 17 18 externvoid tr_eventInit( struct tr_handle_s * tr_handle );18 void tr_eventInit( struct tr_handle_s * tr_handle ); 19 19 20 externvoid tr_eventClose( struct tr_handle_s * tr_handle );20 void tr_eventClose( struct tr_handle_s * tr_handle ); 21 21 22 22 /**
Note: See TracChangeset
for help on using the changeset viewer.