[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Add connection_is_moribund() inline
commit 1a7709d40949b559a6f86e2bbcd1648eeeeed1af
Author: Andrea Shepard <andrea@xxxxxxxxxxxxxx>
Date: Sat Aug 20 03:34:16 2016 +0000
Add connection_is_moribund() inline
---
src/or/connection.c | 3 +--
src/or/connection.h | 14 ++++++++++++++
src/or/main.c | 5 +----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/src/or/connection.c b/src/or/connection.c
index f38dc59..713a70c 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -4588,8 +4588,7 @@ pick_oos_victims, (int n))
++(conn_counts_by_type[c->type]);
/* Skip anything we would count as moribund */
- if (c->conn_array_index < 0 ||
- c->marked_for_close) {
+ if (connection_is_moribund(c)) {
continue;
}
diff --git a/src/or/connection.h b/src/or/connection.h
index 9bf063f..d25e002 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -247,6 +247,20 @@ void clock_skew_warning(const connection_t *conn, long apparent_skew,
int trusted, log_domain_mask_t domain,
const char *received, const char *source);
+/** Check if a connection is on the way out so the OOS handler doesn't try
+ * to kill more than it needs. */
+static inline int
+connection_is_moribund(connection_t *conn)
+{
+ if (conn != NULL &&
+ (conn->conn_array_index < 0 ||
+ conn->marked_for_close)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
void connection_check_oos(int n_socks, int failed);
#ifdef CONNECTION_PRIVATE
diff --git a/src/or/main.c b/src/or/main.c
index 9741f15..6ab94f5 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -662,10 +662,7 @@ connection_count_moribund, (void))
* runs next.
*/
SMARTLIST_FOREACH_BEGIN(closeable_connection_lst, connection_t *, conn) {
- if (conn->conn_array_index < 0 ||
- conn->marked_for_close) {
- ++moribund;
- }
+ if (connection_is_moribund(conn)) ++moribund;
} SMARTLIST_FOREACH_END(conn);
return moribund;
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits