Opened 7 years ago

Last modified 2 months ago

#8111 assigned 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: MrSquanchee
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:


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 (10)

comment:1 Changed 7 years ago by nickm

Milestone: Tor: unspecifiedTor: 0.2.5.x-final

comment:2 Changed 7 years ago by arma

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

comment:3 Changed 6 years ago by nickm

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

comment:4 Changed 4 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 3 years ago by nickm

Keywords: tor-03-unspecified-201612 removed

Remove an old triaging keyword.

comment:7 Changed 3 years ago by nickm

Keywords: mainloop refactor added
Points: 5
Priority: MediumHigh
Severity: Normal

comment:8 Changed 3 months ago by MrSquanchee

Hii nickm,
Is this ticket still relevant and needs work ??
If yes,
I would like to work in this ticket :)

comment:9 Changed 3 months ago by nickm

Yes, but it'll be tricky!

I'd suggest doing this with one flag at a time, if you go for it.

comment:10 Changed 2 months ago by MrSquanchee

Owner: set to MrSquanchee
Status: newassigned

I would be careful :)

Note: See TracTickets for help on using tickets.