X-Git-Url: http://git.onelab.eu/?p=distributedratelimiting.git;a=blobdiff_plain;f=drl%2Fdrl_state.c;h=a30337b432be72d5a1d207ca8a3dfe15216f338d;hp=8583d0d4edf3f23339f83cebc599cf7ce9b95896;hb=19bf89f36a91be2fdd4a0b6c7099f7515507e1e1;hpb=a3995c9ac407020dcdc5c471191b767bb1667d2e diff --git a/drl/drl_state.c b/drl/drl_state.c index 8583d0d..a30337b 100644 --- a/drl/drl_state.c +++ b/drl/drl_state.c @@ -118,7 +118,7 @@ void free_comm(comm_t *comm) { } } -int read_comm(comm_t *comm, double *aggregate) { +int read_comm(comm_t *comm, double *aggregate, double decayto) { remote_limiter_t *remote; pthread_mutex_lock(&comm->lock); @@ -131,9 +131,10 @@ int read_comm(comm_t *comm, double *aggregate) { *aggregate += remote->rate; /* If we continue to read it without having heard an update, - * we start to decay its value. */ + * we start to make the peer's value approach decayto, getting + * half of the way there each time. */ if (remote->awol >= REMOTE_AWOL_THRESHOLD) { - remote->rate = remote->rate / 2; + remote->rate += ((decayto - remote->rate) / 2); } else { remote->awol++; }