Opened 6 years ago

Closed 6 years ago

#12202 closed enhancement (fixed)

Refactor: Improve interface of `entry_is_live`

Reported by: asn Owned by:
Priority: Low Milestone: Tor: 0.2.6.x-final
Component: Core Tor/Tor Version:
Severity: Keywords: tor-guard
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:


entry_is_live() checks whether a given entry guard can be used. It accepts as arguments a couple of flags that we might want the entry guard to have.

Its signature is:

static INLINE const node_t *
entry_is_live(const entry_guard_t *e, int need_uptime, int need_capacity,
              int assume_reachable, int need_descriptor, const char **msg)

Which results in calls like this:

      if (entry_is_live(entry, 0, 1, 0, !for_directory, &msg))
     if (entry_is_live(e, 0, 1, 0, 0, &msg))
      const node_t *r = entry_is_live(entry, 0, 1, 0, 0, &live_msg);

It would probably be better if we turn those boolean flags into a bitstring (maybe similar to router_crn_flags_t), so that the calls are more readable.

This is just code refactoring and should result in no behavior changes.

Child Tickets

Change History (2)

comment:1 Changed 6 years ago by asn

Milestone: Tor: 0.2.6.x-final
Status: newneeds_review

Pushed a branch in bug12202 in my
It even includes unittests!

It is supposed to be applied on top of the #12207 since those change the interface of choose_random_entry_impl() and it also adds the unittest file for entrynodes.c.

comment:2 Changed 6 years ago by nickm

Resolution: fixed
Status: needs_reviewclosed

Looks okay to me. Merged!

Note: See TracTickets for help on using tickets.