aboutsummaryrefslogtreecommitdiff
path: root/src/feature/hs/hs_circuit.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2022-06-30 22:01:15 -0400
committerMicah Elizabeth Scott <beth@torproject.org>2023-05-10 07:37:11 -0700
commitb95bd5017f09dd9385e54e9b3b6a49474b4dc9a8 (patch)
tree8222763d8aa99f5307f9115816cdba9123762fd1 /src/feature/hs/hs_circuit.c
parent5e768d5cb98ef8bae1b76c30610dfe21f17a3fda (diff)
downloadtor-b95bd5017f09dd9385e54e9b3b6a49474b4dc9a8.tar.gz
tor-b95bd5017f09dd9385e54e9b3b6a49474b4dc9a8.zip
track how many in-flight hs-side rend circs
not used in decision-making yet, but it's all ready to use in a "don't dequeue any more if we have too many in-flight" kind of way
Diffstat (limited to 'src/feature/hs/hs_circuit.c')
-rw-r--r--src/feature/hs/hs_circuit.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/feature/hs/hs_circuit.c b/src/feature/hs/hs_circuit.c
index 0c71443879..26dd600f1d 100644
--- a/src/feature/hs/hs_circuit.c
+++ b/src/feature/hs/hs_circuit.c
@@ -689,6 +689,27 @@ trim_rend_pqueue(hs_pow_service_state_t *pow_state, time_t now)
smartlist_free(old_pqueue);
}
+/** Count up how many pending outgoing (CIRCUIT_PURPOSE_S_CONNECT_REND)
+ * circuits there are for this service. Used in the PoW rate limiting
+ * world to decide whether it's time to launch any new ones.
+ */
+static int
+count_service_rp_circuits_pending(hs_service_t *service)
+{
+ origin_circuit_t *ocirc = NULL;
+ int count = 0;
+ while ((ocirc = circuit_get_next_by_purpose(ocirc,
+ CIRCUIT_PURPOSE_S_CONNECT_REND))) {
+ /* Count up circuits that are v3 and for this service. */
+ if (ocirc->hs_ident != NULL &&
+ ed25519_pubkey_eq(&ocirc->hs_ident->identity_pk,
+ &service->keys.identity_pk)) {
+ count++;
+ }
+ }
+ return count;
+}
+
/** How many rendezvous request we handle per mainloop event. Per prop327,
* handling an INTRODUCE2 cell takes on average 5.56msec on an average CPU and
* so it means that launching this max amount of circuits is well below 0.08
@@ -705,6 +726,11 @@ handle_rend_pqueue_cb(mainloop_event_t *ev, void *arg)
(void) ev; /* Not using the returned event, make compiler happy. */
+ log_notice(LD_REND, "Considering launching more rendezvous responses. "
+ "%d in-flight, %d pending.",
+ count_service_rp_circuits_pending(service),
+ smartlist_len(pow_state->rend_request_pqueue));
+
/* Process rendezvous request until the maximum per mainloop run. */
while (smartlist_len(pow_state->rend_request_pqueue) > 0) {
/* Pop next request by effort. */