diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-12-15 12:57:57 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-12-15 12:57:57 -0500 |
commit | a7d44731d9ac831cd68f34ac640b50cdde3a60af (patch) | |
tree | 88a149ac07f30c0af5be47cc7d8f9ed9d57db244 /src/or/connection.h | |
parent | 54433993c7c84dc9af878ebaf8dd1deae8c595e3 (diff) | |
parent | d72af1085a1d9ed6f2c9bdb5e9c85eba991db842 (diff) | |
download | tor-a7d44731d9ac831cd68f34ac640b50cdde3a60af.tar.gz tor-a7d44731d9ac831cd68f34ac640b50cdde3a60af.zip |
Merge remote-tracking branch 'teor/feature4483-v10-squashed'
Diffstat (limited to 'src/or/connection.h')
-rw-r--r-- | src/or/connection.h | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/src/or/connection.h b/src/or/connection.h index d416962c0a..7479faa509 100644 --- a/src/or/connection.h +++ b/src/or/connection.h @@ -193,7 +193,57 @@ connection_t *connection_get_by_type_state(int type, int state); connection_t *connection_get_by_type_state_rendquery(int type, int state, const char *rendquery); dir_connection_t *connection_dir_get_by_purpose_and_resource( - int state, const char *resource); + int purpose, + const char *resource); +dir_connection_t *connection_dir_get_by_purpose_resource_and_state( + int purpose, + const char *resource, + int state); +smartlist_t *connection_dir_list_by_purpose_and_resource( + int purpose, + const char *resource); +smartlist_t *connection_dir_list_by_purpose_resource_and_state( + int purpose, + const char *resource, + int state); + +#define CONN_LEN_AND_FREE_TEMPLATE(sl) \ + STMT_BEGIN \ + int len = smartlist_len(sl); \ + smartlist_free(sl); \ + return len; \ + STMT_END + +/** Return a count of directory connections that are fetching the item + * described by <b>purpose</b>/<b>resource</b>. */ +static INLINE int +connection_dir_count_by_purpose_and_resource( + int purpose, + const char *resource) +{ + smartlist_t *conns = connection_dir_list_by_purpose_and_resource( + purpose, + resource); + CONN_LEN_AND_FREE_TEMPLATE(conns); +} + +/** Return a count of directory connections that are fetching the item + * described by <b>purpose</b>/<b>resource</b>/<b>state</b>. */ +static INLINE int +connection_dir_count_by_purpose_resource_and_state( + int purpose, + const char *resource, + int state) +{ + smartlist_t *conns = + connection_dir_list_by_purpose_resource_and_state( + purpose, + resource, + state); + CONN_LEN_AND_FREE_TEMPLATE(conns); +} + +#undef CONN_LEN_AND_FREE_TEMPLATE int any_other_active_or_conns(const or_connection_t *this_conn); @@ -239,6 +289,13 @@ void connection_buckets_note_empty_ts(uint32_t *timestamp_var, int tokens_before, size_t tokens_removed, const struct timeval *tvnow); +MOCK_DECL(STATIC int,connection_connect_sockaddr, + (connection_t *conn, + const struct sockaddr *sa, + socklen_t sa_len, + const struct sockaddr *bindaddr, + socklen_t bindaddr_len, + int *socket_error)); #endif #endif |