Add connection_is_moribund() inline

This commit is contained in:
Andrea Shepard 2016-08-20 03:34:16 +00:00
parent a403230fe3
commit 1a7709d409
3 changed files with 16 additions and 6 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;