Opened 6 years ago

Last modified 2 years ago

#8111 new enhancement

Refactor our checking of whether we should be reading/writing on a connection to use a set of reason-flags

Reported by: nickm Owned by:
Priority: High Milestone: Tor: unspecified
Component: Core Tor/Tor Version:
Severity: Normal Keywords: tor-relay mainloop refactor
Cc: Actual Points:
Parent ID: Points: 5
Reviewer: Sponsor:

Description

There are plenty of things that can block reading or writing on a connection: being out of bandwidth, not having anything more to say, having an internal buffer get too full, etc.

There are too many places where one of the things that would block read/write becomes false, and so we check all of the *other* potential reasons not to read/write before we re-enable reading/writing.

There's a much better pattern we could use: have a flags variable for "read_blocked" and a flags variable for "write_blocked", each bit of which represents a reason not to be reading or writing. Instead of calling connection_{stop,start}_{reading,writing} directly, we would call {un,}block_{reading,writing}(conn, reason), which would set or clear a bit corresponding to 'reason', and block/unblock reading/writing accordingly.

I haven't yet verified that this is a win; we should audit all the uses of connection_{stop,start}_{reading,writing} reading to see.

Child Tickets

Change History (7)

comment:1 Changed 6 years ago by nickm

Milestone: Tor: unspecifiedTor: 0.2.5.x-final

comment:2 Changed 6 years ago by arma

(Linking back to #8297 for complete cross-indexing.)

comment:3 Changed 5 years ago by nickm

Milestone: Tor: 0.2.5.x-finalTor: 0.2.???

comment:4 Changed 3 years ago by teor

Milestone: Tor: 0.2.???Tor: 0.3.???

Milestone renamed

comment:5 Changed 3 years ago by nickm

Keywords: tor-03-unspecified-201612 added
Milestone: Tor: 0.3.???Tor: unspecified

Finally admitting that 0.3.??? was a euphemism for Tor: unspecified all along.

comment:6 Changed 2 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:7 Changed 2 years ago by nickm

Keywords: mainloop refactor added
Points: 5
Priority: MediumHigh
Severity: Normal
Note: See TracTickets for help on using tickets.