r16111@catbus: nickm | 2007-10-24 15:03:57 -0400
Allow multiple download schedules to exist. At the moment, we use one for consensus, and the other one for everything else. svn:r12158
This commit is contained in:
parent
02e7a83f91
commit
9767415dca
|
@ -90,6 +90,8 @@ Changes in version 0.2.0.9-alpha - 2007-10-24
|
|||
after one fails: don't wait 60 seconds to notice.
|
||||
- When fetching a consensus as a cache, wait until a newer consensus
|
||||
should exist before trying to replace the current one.
|
||||
- Use a more forgiving schedule for retrying failed consensus downloads
|
||||
than for other types.
|
||||
|
||||
o Minor bugfixes (other directory issues):
|
||||
- Correct the implementation of "download votes by digest." Bugfix on
|
||||
|
|
|
@ -2725,6 +2725,19 @@ dir_networkstatus_download_failed(smartlist_t *failed, int status_code)
|
|||
});
|
||||
}
|
||||
|
||||
static const int server_dl_schedule[] = {
|
||||
0, 0, 0, 60, 60, 60*2, 60*5, 60*15, INT_MAX
|
||||
};
|
||||
static const int client_dl_schedule[] = {
|
||||
0, 0, 60, 60*5, 60*10, INT_MAX
|
||||
};
|
||||
static const int server_consensus_dl_schedule[] = {
|
||||
0, 0, 60, 60*5, 60*10, 60*30, 60*30, 60*30, 60*30, 60*30, 60*60, 60*60*2
|
||||
};
|
||||
static const int client_consensus_dl_schedule[] = {
|
||||
0, 0, 60, 60*5, 60*10, 60*30, 60*60, 60*60, 60*60, 60*60*3, 60*60*6, 60*60*12
|
||||
};
|
||||
|
||||
/** Called when an attempt to download <b>dls</b> has failed with HTTP status
|
||||
* <b>status_code</b>. Increment the failure count (if the code indicates a
|
||||
* real failure) and set <b>dls<b>->next_attempt_at to an appropriate time in
|
||||
|
@ -2733,31 +2746,46 @@ time_t
|
|||
download_status_increment_failure(download_status_t *dls, int status_code,
|
||||
const char *item, int server, time_t now)
|
||||
{
|
||||
const int *schedule;
|
||||
int schedule_len;
|
||||
int increment;
|
||||
tor_assert(dls);
|
||||
if (status_code != 503 || server)
|
||||
++dls->n_download_failures;
|
||||
if (server) {
|
||||
switch (dls->n_download_failures) {
|
||||
case 0: dls->next_attempt_at = 0; break;
|
||||
case 1: dls->next_attempt_at = 0; break;
|
||||
case 2: dls->next_attempt_at = 0; break;
|
||||
case 3: dls->next_attempt_at = now+60; break;
|
||||
case 4: dls->next_attempt_at = now+60; break;
|
||||
case 5: dls->next_attempt_at = now+60*2; break;
|
||||
case 6: dls->next_attempt_at = now+60*5; break;
|
||||
case 7: dls->next_attempt_at = now+60*15; break;
|
||||
default: dls->next_attempt_at = TIME_MAX; break;
|
||||
}
|
||||
} else {
|
||||
switch (dls->n_download_failures) {
|
||||
case 0: dls->next_attempt_at = 0; break;
|
||||
case 1: dls->next_attempt_at = 0; break;
|
||||
case 2: dls->next_attempt_at = now+60; break;
|
||||
case 3: dls->next_attempt_at = now+60*5; break;
|
||||
case 4: dls->next_attempt_at = now+60*10; break;
|
||||
default: dls->next_attempt_at = TIME_MAX; break;
|
||||
}
|
||||
|
||||
switch (dls->schedule) {
|
||||
case DL_SCHED_GENERIC:
|
||||
if (server) {
|
||||
schedule = server_dl_schedule;
|
||||
schedule_len = sizeof(server_dl_schedule)/sizeof(int);
|
||||
} else {
|
||||
schedule = client_dl_schedule;
|
||||
schedule_len = sizeof(client_dl_schedule)/sizeof(int);
|
||||
}
|
||||
break;
|
||||
case DL_SCHED_CONSENSUS:
|
||||
if (server) {
|
||||
schedule = server_consensus_dl_schedule;
|
||||
schedule_len = sizeof(server_consensus_dl_schedule)/sizeof(int);
|
||||
} else {
|
||||
schedule = client_consensus_dl_schedule;
|
||||
schedule_len = sizeof(client_consensus_dl_schedule)/sizeof(int);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
tor_assert(0);
|
||||
}
|
||||
|
||||
if (dls->n_download_failures < schedule_len)
|
||||
increment = schedule[dls->n_download_failures];
|
||||
else
|
||||
increment = schedule[schedule_len-1];
|
||||
|
||||
if (increment < INT_MAX)
|
||||
dls->next_attempt_at = now+increment;
|
||||
else
|
||||
dls->next_attempt_at = TIME_MAX;
|
||||
|
||||
if (item) {
|
||||
if (dls->next_attempt_at == 0)
|
||||
log_debug(LD_DIR, "%s failed %d time(s); I'll try again immediately.",
|
||||
|
|
|
@ -49,7 +49,7 @@ static time_t last_networkstatus_download_attempted = 0;
|
|||
* before the current consensus becomes invalid. */
|
||||
static time_t time_to_download_next_consensus = 0;
|
||||
/** Download status for the current consensus networkstatus. */
|
||||
static download_status_t consensus_dl_status = { 0, 0};
|
||||
static download_status_t consensus_dl_status = { 0, 0, DL_SCHED_CONSENSUS };
|
||||
|
||||
/** True iff we have logged a warning about this OR not being valid or
|
||||
* not being named. */
|
||||
|
|
|
@ -1067,6 +1067,12 @@ typedef enum {
|
|||
SAVED_IN_JOURNAL
|
||||
} saved_location_t;
|
||||
|
||||
/** DOCDOC */
|
||||
typedef enum {
|
||||
DL_SCHED_GENERIC = 0,
|
||||
DL_SCHED_CONSENSUS = 1,
|
||||
} download_schedule_t;
|
||||
|
||||
/** Information about our plans for retrying downloads for a downloadable
|
||||
* object. */
|
||||
typedef struct download_status_t {
|
||||
|
@ -1074,6 +1080,7 @@ typedef struct download_status_t {
|
|||
* again? */
|
||||
uint8_t n_download_failures; /**< Number of failures trying to download the
|
||||
* most recent descriptor. */
|
||||
download_schedule_t schedule : 1;
|
||||
} download_status_t;
|
||||
|
||||
/** Information need to cache an onion router's descriptor. */
|
||||
|
|
Loading…
Reference in New Issue