]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Check the token supply when we received a padding event, too.
authorMike Perry <mikeperry-git@torproject.org>
Wed, 15 May 2019 03:43:57 +0000 (03:43 +0000)
committerGeorge Kadianakis <desnacked@riseup.net>
Wed, 15 May 2019 12:10:48 +0000 (15:10 +0300)
We need to check here because otherwise we can try to schedule padding with no
tokens left upon the receipt of a padding event when our bins just became
empty.

src/core/or/circuitpadding.c

index 3124e740332340006d26a14a171db0bff2575ea5..cd58a191d64462ca7a1e21e80b50da40974a87c9 100644 (file)
@@ -1699,8 +1699,16 @@ void
 circpad_cell_event_padding_sent(circuit_t *on_circ)
 {
   FOR_EACH_ACTIVE_CIRCUIT_MACHINE_BEGIN(i, on_circ) {
-    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 */
+
+      circpad_machine_spec_transition(on_circ->padding_info[i],
                              CIRCPAD_EVENT_PADDING_SENT);
+    }
   } FOR_EACH_ACTIVE_CIRCUIT_MACHINE_END;
 }