summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/or/main.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 163dd5d0fb..a5ad1d9648 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -848,6 +848,20 @@ conn_close_if_marked(int i)
"Holding conn (fd %d) open for more flushing.",
(int)conn->s));
conn->timestamp_lastwritten = now; /* reset so we can flush more */
+ } else if (sz == 0) { /* retval is also 0 */
+ /* Connection must flush before closing, but it's being rate-limited.
+ Let's remove from Libevent, and mark it as blocked on bandwidth so it
+ will be re-added on next token bucket refill. Prevents busy Libevent
+ loops where we keep ending up here and returning 0 until we are no
+ longer blocked on bandwidth. */
+ if (connection_is_reading(conn)) {
+ conn->read_blocked_on_bw = 1;
+ connection_stop_reading(conn);
+ }
+ if (connection_is_writing(conn)) {
+ conn->write_blocked_on_bw = 1;
+ connection_stop_writing(conn);
+ }
}
return 0;
}