[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor] 24/77: sort pqueue ties by time-added
This is an automated email from the git hooks/post-receive script.
dgoulet pushed a commit to branch main
in repository tor.
commit a575e35c17d49bd830a9a1814ad9a3b122df9f08
Author: Roger Dingledine <arma@xxxxxxxxxxxxxx>
AuthorDate: Fri Jul 1 16:29:46 2022 -0400
sort pqueue ties by time-added
our pqueue implementation does bizarre unspecified things with
ordering of elements that are equal. it certainly doesn't do any
sort of "first in first out" property that i was expecting.
now make it explicit by saying that "equal-effort, added-earlier" is
higher priority.
---
src/feature/hs/hs_circuit.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/feature/hs/hs_circuit.c b/src/feature/hs/hs_circuit.c
index c5eb22d5cd..6b8d87351c 100644
--- a/src/feature/hs/hs_circuit.c
+++ b/src/feature/hs/hs_circuit.c
@@ -624,6 +624,11 @@ compare_rend_request_by_effort_(const void *_a, const void *_b)
if (a->rdv_data.pow_effort > b->rdv_data.pow_effort) {
return -1;
} else if (a->rdv_data.pow_effort == b->rdv_data.pow_effort) {
+ /* tie-breaker! use the time it was added to the queue. older better. */
+ if (a->enqueued_ts < b->enqueued_ts)
+ return -1;
+ if (a->enqueued_ts > b->enqueued_ts)
+ return 1;
return 0;
} else {
return 1;
@@ -780,8 +785,10 @@ handle_rend_pqueue_cb(mainloop_event_t *ev, void *arg)
offsetof(pending_rend_t, idx));
log_notice(LD_REND, "Dequeued pending rendezvous request with effort: %u. "
+ "Waited %d. "
"Remaining requests: %u",
req->rdv_data.pow_effort,
+ (int)(now - req->enqueued_ts),
smartlist_len(pow_state->rend_request_pqueue));
if (queued_rend_request_is_too_old(req, now)) {
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits