Don't switch trackers while announcing

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

View File

@ -659,7 +659,8 @@ tau_tracker_is_idle (const struct tau_tracker * tracker)
}
static void
tau_tracker_upkeep (struct tau_tracker * tracker)
tau_tracker_upkeep_ex (struct tau_tracker * tracker,
bool timeout_reqs)
{
const time_t now = tr_time ();
const bool closing = tracker->close_at != 0;
@ -717,12 +718,19 @@ 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))
tau_tracker_send_reqs (tracker);
}
static void
tau_tracker_upkeep (struct tau_tracker * tracker)
{
tau_tracker_upkeep_ex (tracker, true);
}
/****
*****
***** SESSION
@ -957,7 +965,7 @@ tr_tracker_udp_announce (tr_session * session,
response_func,
user_data);
tr_ptrArrayAppend (&tracker->announces, r);
tau_tracker_upkeep (tracker);
tau_tracker_upkeep_ex (tracker, false);
}
void
@ -972,5 +980,5 @@ tr_tracker_udp_scrape (tr_session * session,
response_func,
user_data);
tr_ptrArrayAppend (&tracker->scrapes, r);
tau_tracker_upkeep (tracker);
tau_tracker_upkeep_ex (tracker, false);
}

View File

@ -1425,6 +1425,8 @@ multiscrape (tr_announcer * announcer, tr_ptrArray * tiers)
char * url = tier->currentTracker->scrape;
const uint8_t * hash = tier->tor->info.hash;
assert (url != NULL);
/* if there's a request with this scrape URL and a free slot, use it */
for (j=0; j<request_count; ++j)
{