1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-23 08:13:27 +00:00

Don't switch trackers while announcing

Fixes: #297
This commit is contained in:
Mike Gelfand 2017-07-04 21:22:26 +03:00
parent d46fdda9ea
commit a86266d3c2
2 changed files with 14 additions and 4 deletions

View file

@ -675,7 +675,7 @@ static bool tau_tracker_is_idle(struct tau_tracker const* tracker)
return tr_ptrArrayEmpty(&tracker->announces) && tr_ptrArrayEmpty(&tracker->scrapes) && tracker->dns_request == NULL;
}
static void tau_tracker_upkeep(struct tau_tracker* tracker)
static void tau_tracker_upkeep_ex(struct tau_tracker* tracker, bool timeout_reqs)
{
time_t const now = tr_time();
bool const closing = tracker->close_at != 0;
@ -727,7 +727,10 @@ static void tau_tracker_upkeep(struct tau_tracker* tracker)
return;
}
tau_tracker_timeout_reqs(tracker);
if (timeout_reqs)
{
tau_tracker_timeout_reqs(tracker);
}
if (tracker->addr != NULL && tracker->connection_expiration_time > now)
{
@ -735,6 +738,11 @@ static void tau_tracker_upkeep(struct tau_tracker* tracker)
}
}
static void tau_tracker_upkeep(struct tau_tracker* tracker)
{
tau_tracker_upkeep_ex(tracker, true);
}
/****
*****
***** SESSION
@ -982,7 +990,7 @@ void tr_tracker_udp_announce(tr_session* session, tr_announce_request const* req
struct tau_tracker* tracker = tau_session_get_tracker(tau, request->url);
struct tau_announce_request* r = tau_announce_request_new(request, response_func, user_data);
tr_ptrArrayAppend(&tracker->announces, r);
tau_tracker_upkeep(tracker);
tau_tracker_upkeep_ex(tracker, false);
}
void tr_tracker_udp_scrape(tr_session* session, tr_scrape_request const* request, tr_scrape_response_func response_func,
@ -992,5 +1000,5 @@ void tr_tracker_udp_scrape(tr_session* session, tr_scrape_request const* request
struct tau_tracker* tracker = tau_session_get_tracker(tau, request->url);
struct tau_scrape_request* r = tau_scrape_request_new(request, response_func, user_data);
tr_ptrArrayAppend(&tracker->scrapes, r);
tau_tracker_upkeep(tracker);
tau_tracker_upkeep_ex(tracker, false);
}

View file

@ -1475,6 +1475,8 @@ static void multiscrape(tr_announcer* announcer, tr_ptrArray* tiers)
uint8_t const* hash = tier->tor->info.hash;
bool found = false;
TR_ASSERT(url != NULL);
/* if there's a request with this scrape URL and a free slot, use it */
for (int j = 0; !found && j < request_count; ++j)
{