From: George Kadianakis Date: Wed, 15 May 2019 13:46:51 +0000 (+0300) Subject: Merge branch 'bug28780-squashed3-rebased' into bug28780_rebase X-Git-Tag: tor-0.4.1.1-alpha~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d71fa707dd01bdaa2ed301e82ace6fd23f63e638;p=thirdparty%2Ftor.git Merge branch 'bug28780-squashed3-rebased' into bug28780_rebase --- d71fa707dd01bdaa2ed301e82ace6fd23f63e638 diff --cc src/core/or/circuitpadding.c index cd58a191d6,68140356c9..ddf28ea624 --- a/src/core/or/circuitpadding.c +++ b/src/core/or/circuitpadding.c @@@ -1649,16 -1649,13 +1760,17 @@@ circpad_cell_event_nonpadding_sent(circ /* If there are no machines then this loop should not iterate */ FOR_EACH_ACTIVE_CIRCUIT_MACHINE_BEGIN(i, on_circ) { - /* First, update any RTT estimate */ + /* First, update any timestamps */ + on_circ->padding_info[i]->last_cell_time_sec = approx_time(); circpad_estimate_circ_rtt_on_send(on_circ, on_circ->padding_info[i]); - /* Remove a token: this is the idea of adaptive padding, since we have an - * ideal distribution that we want our distribution to look like. */ - if (!circpad_machine_remove_token(on_circ->padding_info[i])) { + /* Then, do accounting */ + circpad_machine_count_nonpadding_sent(on_circ->padding_info[i]); + + /* Check to see if we've run out of tokens for this state already, + * and if not, check for other state transitions */ + if (check_machine_token_supply(on_circ->padding_info[i]) + == CIRCPAD_STATE_UNCHANGED) { /* If removing a token did not cause a transition, check if * non-padding sent event should */ circpad_machine_spec_transition(on_circ->padding_info[i], @@@ -1699,16 -1697,9 +1812,17 @@@ voi circpad_cell_event_padding_sent(circuit_t *on_circ) { FOR_EACH_ACTIVE_CIRCUIT_MACHINE_BEGIN(i, on_circ) { - on_circ->padding_info[i]->last_cell_time_sec = approx_time(); - circpad_machine_spec_transition(on_circ->padding_info[i], + /* Check to see if we've run out of tokens for this state already, + * and if not, check for other state transitions */ + if (check_machine_token_supply(on_circ->padding_info[i]) + == CIRCPAD_STATE_UNCHANGED) { + /* If removing a token did not cause a transition, check if + * non-padding sent event should */ + ++ on_circ->padding_info[i]->last_cell_time_sec = approx_time(); + circpad_machine_spec_transition(on_circ->padding_info[i], CIRCPAD_EVENT_PADDING_SENT); + } } FOR_EACH_ACTIVE_CIRCUIT_MACHINE_END; }