From f57626a6b1e4704a2ea717d8ac45cf0208e42c6c Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 26 Dec 2006 04:17:37 +0000 Subject: [PATCH] support manual announcing to tracker (as in user forces an announce) in libT...when implemented in a front end it should limit the use of this --- libtransmission/tracker.c | 12 +++++++++--- libtransmission/tracker.h | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libtransmission/tracker.c b/libtransmission/tracker.c index 4156c18b5..0e283f851 100644 --- a/libtransmission/tracker.c +++ b/libtransmission/tracker.c @@ -92,6 +92,7 @@ struct tr_tracker_s static int announceToScrape ( char * announce, char * scrape ); static void setAnnounce ( tr_tracker_t * tc, tr_announce_list_ptr_t * announceItem ); static void failureAnnouncing( tr_tracker_t * tc ); +void trackerPulse ( tr_tracker_t *, int ); static tr_http_t * getQuery ( tr_tracker_t * tc ); static tr_http_t * getScrapeQuery ( tr_tracker_t * tc ); static void readAnswer ( tr_tracker_t * tc, const char *, int ); @@ -322,7 +323,7 @@ void tr_trackerChangePort( tr_tracker_t * tc, int port ) tc->newPort = port; } -void tr_trackerPulse( tr_tracker_t * tc ) +void trackerPulse( tr_tracker_t * tc, int manual ) { tr_torrent_t * tor = tc->tor; tr_info_t * inf = &tor->info; @@ -330,10 +331,15 @@ void tr_trackerPulse( tr_tracker_t * tc ) char * address, * announce; int len, i, port; tr_announce_list_ptr_t * announcePtr, * prevAnnouncePtr; - - if( ( NULL == tc->http ) && shouldConnect( tc ) ) + + if( ( NULL == tc->http ) && ( manual || shouldConnect( tc ) ) ) { + if( manual ) + { + tc->allUnreachIfError = 0; + } tc->completelyUnconnectable = 0; + tc->randOffset = tr_rand( 60000 ); if( tr_fdSocketWillCreate( tor->fdlimit, 1 ) ) diff --git a/libtransmission/tracker.h b/libtransmission/tracker.h index 2f9154b14..c2f9169ed 100644 --- a/libtransmission/tracker.h +++ b/libtransmission/tracker.h @@ -29,7 +29,10 @@ typedef struct tr_tracker_s tr_tracker_t; tr_tracker_t * tr_trackerInit ( tr_torrent_t * ); void tr_trackerChangePort( tr_tracker_t *, int ); -void tr_trackerPulse ( tr_tracker_t * ); + +#define tr_trackerPulse( tc ) trackerPulse( (tc), 0 ) +#define tr_trackerPulseManual( tc ) trackerPulse( (tc), 1 ) + void tr_trackerCompleted ( tr_tracker_t * ); void tr_trackerStopped ( tr_tracker_t * ); void tr_trackerClose ( tr_tracker_t * );