make rhizome over mdp idle timeout configurable at runtime.

This commit is contained in:
gardners 2013-02-17 17:37:34 +10:30 committed by Jeremy Lakeman
parent 065a1c6f09
commit 5a3dec28d9
2 changed files with 14 additions and 13 deletions

View File

@ -313,6 +313,7 @@ STRING(256, datastore_path, "", cf_opt_absolute_path,, "Path of
ATOM(uint64_t, database_size, 1000000, cf_opt_uint64_scaled,, "Size of database in bytes")
ATOM(uint64_t, max_internal_blob_size, 10000000000, cf_opt_uint64_scaled,, "Size of largest bundle to store internally in database.")
ATOM(uint64_t, rhizome_mdp_block_size, 512, cf_opt_uint64_scaled,, "Rhizome MDP block size.")
ATOM(uint64_t, idle_timeout, RHIZOME_IDLE_TIMEOUT, cf_opt_uint64_scaled,, "Rhizome transfer timeout if no data received.")
ATOM(uint32_t, fetch_delay_ms, 50, cf_opt_uint32_nonzero,, "Delay from receiving first bundle advert to initiating fetch")
SUB_STRUCT(rhizome_direct, direct,)
SUB_STRUCT(rhizome_api, api,)

View File

@ -599,8 +599,8 @@ static int schedule_fetch(struct rhizome_fetch_slot *slot)
watch(&slot->alarm);
/* And schedule a timeout alarm */
unschedule(&slot->alarm);
slot->alarm.alarm = gettime_ms() + RHIZOME_IDLE_TIMEOUT;
slot->alarm.deadline = slot->alarm.alarm + RHIZOME_IDLE_TIMEOUT;
slot->alarm.alarm = gettime_ms() + config.rhizome.idle_timeout;
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
schedule(&slot->alarm);
RETURN(0);
}
@ -1040,7 +1040,7 @@ int rhizome_suggest_queue_manifest_import(rhizome_manifest *m, const struct sock
sched_activate.function = rhizome_start_next_queued_fetches;
sched_activate.stats = &rsnqf_stats;
sched_activate.alarm = gettime_ms() + rhizome_fetch_delay_ms();
sched_activate.deadline = sched_activate.alarm + RHIZOME_IDLE_TIMEOUT;
sched_activate.deadline = sched_activate.alarm + config.rhizome.idle_timeout;
schedule(&sched_activate);
}
@ -1269,7 +1269,7 @@ static int rhizome_fetch_switch_to_mdp(struct rhizome_fetch_slot *slot)
*/
slot->file_len=slot->manifest->fileLength;
slot->mdpIdleTimeout=RHIZOME_IDLE_TIMEOUT; // give up if nothing received for 5 seconds
slot->mdpIdleTimeout=config.rhizome.idle_timeout; // give up if nothing received for 5 seconds
slot->mdpRXBitmap=0x00000000; // no blocks received yet
slot->mdpRXBlockLength=config.rhizome.rhizome_mdp_block_size; // Rhizome over MDP block size
rhizome_fetch_mdp_requestblocks(slot);
@ -1277,7 +1277,7 @@ static int rhizome_fetch_switch_to_mdp(struct rhizome_fetch_slot *slot)
/* We are requesting a manifest, which is stateless, except that we eventually
give up. All we need to do now is send the request, and set our alarm to
try again in case we haven't heard anything back. */
slot->mdpIdleTimeout=RHIZOME_IDLE_TIMEOUT;
slot->mdpIdleTimeout=config.rhizome.idle_timeout;
rhizome_fetch_mdp_requestmanifest(slot);
}
@ -1299,8 +1299,8 @@ void rhizome_fetch_write(struct rhizome_fetch_slot *slot)
} else {
// reset timeout
unschedule(&slot->alarm);
slot->alarm.alarm=gettime_ms() + RHIZOME_IDLE_TIMEOUT;
slot->alarm.deadline = slot->alarm.alarm + RHIZOME_IDLE_TIMEOUT;
slot->alarm.alarm=gettime_ms() + config.rhizome.idle_timeout;
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
schedule(&slot->alarm);
slot->request_ofs+=bytes;
if (slot->request_ofs>=slot->request_len) {
@ -1570,8 +1570,8 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
rhizome_write_content(slot, buffer, bytes);
// reset inactivity timeout
unschedule(&slot->alarm);
slot->alarm.alarm=gettime_ms() + RHIZOME_IDLE_TIMEOUT;
slot->alarm.deadline = slot->alarm.alarm + RHIZOME_IDLE_TIMEOUT;
slot->alarm.alarm=gettime_ms() + config.rhizome.idle_timeout;
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
slot->alarm.function = rhizome_fetch_poll;
schedule(&slot->alarm);
return;
@ -1598,8 +1598,8 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
if (bytes > 0) {
// reset timeout
unschedule(&slot->alarm);
slot->alarm.alarm = gettime_ms() + RHIZOME_IDLE_TIMEOUT;
slot->alarm.deadline = slot->alarm.alarm + RHIZOME_IDLE_TIMEOUT;
slot->alarm.alarm = gettime_ms() + config.rhizome.idle_timeout;
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
schedule(&slot->alarm);
slot->request_len += bytes;
if (http_header_complete(slot->request, slot->request_len, bytes)) {
@ -1636,8 +1636,8 @@ void rhizome_fetch_poll(struct sched_ent *alarm)
rhizome_write_content(slot, parts.content_start, content_bytes);
// reset inactivity timeout
unschedule(&slot->alarm);
slot->alarm.alarm=gettime_ms() + RHIZOME_IDLE_TIMEOUT;
slot->alarm.deadline = slot->alarm.alarm + RHIZOME_IDLE_TIMEOUT;
slot->alarm.alarm=gettime_ms() + config.rhizome.idle_timeout;
slot->alarm.deadline = slot->alarm.alarm + config.rhizome.idle_timeout;
slot->alarm.function = rhizome_fetch_poll;
schedule(&slot->alarm);