aboutsummaryrefslogtreecommitdiff
path: root/src/or/rendcache.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2015-10-06 11:32:06 -0400
committerNick Mathewson <nickm@torproject.org>2015-10-06 11:32:06 -0400
commitf179abdca935d6d119f66e469232b36955a292b4 (patch)
treef00e05fced86c7f6ad77d03fb0bdaa2961597ae8 /src/or/rendcache.c
parent2592d537f95173083e397d19e182346955741221 (diff)
parent70de8d4bf86c430969bb314ba8590c00ce4dd374 (diff)
downloadtor-f179abdca935d6d119f66e469232b36955a292b4.tar.gz
tor-f179abdca935d6d119f66e469232b36955a292b4.zip
Merge remote-tracking branch 'twstrike/rendcache_tests'
Conflicts: src/test/include.am src/test/rend_test_helpers.c src/test/rend_test_helpers.h
Diffstat (limited to 'src/or/rendcache.c')
-rw-r--r--src/or/rendcache.c34
1 files changed, 17 insertions, 17 deletions
diff --git a/src/or/rendcache.c b/src/or/rendcache.c
index 3d3beb0138..fddedf165a 100644
--- a/src/or/rendcache.c
+++ b/src/or/rendcache.c
@@ -6,6 +6,7 @@
* \brief Hidden service descriptor cache.
**/
+#define RENDCACHE_PRIVATE
#include "rendcache.h"
#include "config.h"
@@ -15,14 +16,14 @@
/** Map from service id (as generated by rend_get_service_id) to
* rend_cache_entry_t. */
-static strmap_t *rend_cache = NULL;
+STATIC strmap_t *rend_cache = NULL;
/** Map from service id to rend_cache_entry_t; only for hidden services. */
static strmap_t *rend_cache_local_service = NULL;
/** Map from descriptor id to rend_cache_entry_t; only for hidden service
* directories. */
-static digestmap_t *rend_cache_v2_dir = NULL;
+STATIC digestmap_t *rend_cache_v2_dir = NULL;
/** (Client side only) Map from service id to rend_cache_failure_t. This
* cache is used to track intro point(IP) failures so we know when to keep
@@ -49,10 +50,10 @@ static digestmap_t *rend_cache_v2_dir = NULL;
* This scheme allows us to not realy on the descriptor's timestamp (which
* is rounded down to the hour) to know if we have a newer descriptor. We
* only rely on the usability of intro points from an internal state. */
-static strmap_t *rend_cache_failure = NULL;
+STATIC strmap_t *rend_cache_failure = NULL;
/** DOCDOC */
-static size_t rend_cache_total_allocation = 0;
+STATIC size_t rend_cache_total_allocation = 0;
/** Initializes the service descriptor cache.
*/
@@ -66,7 +67,7 @@ rend_cache_init(void)
}
/** Return the approximate number of bytes needed to hold <b>e</b>. */
-static size_t
+STATIC size_t
rend_cache_entry_allocation(const rend_cache_entry_t *e)
{
if (!e)
@@ -84,7 +85,7 @@ rend_cache_get_total_allocation(void)
}
/** Decrement the total bytes attributed to the rendezvous cache by n. */
-static void
+STATIC void
rend_cache_decrement_allocation(size_t n)
{
static int have_underflowed = 0;
@@ -101,7 +102,7 @@ rend_cache_decrement_allocation(size_t n)
}
/** Increase the total bytes attributed to the rendezvous cache by n. */
-static void
+STATIC void
rend_cache_increment_allocation(size_t n)
{
static int have_overflowed = 0;
@@ -117,7 +118,7 @@ rend_cache_increment_allocation(size_t n)
}
/** Helper: free a rend cache failure intro object. */
-static void
+STATIC void
rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t *entry)
{
if (entry == NULL) {
@@ -128,7 +129,7 @@ rend_cache_failure_intro_entry_free(rend_cache_failure_intro_t *entry)
/** Allocate a rend cache failure intro object and return it. <b>failure</b>
* is set into the object. This function can not fail. */
-static rend_cache_failure_intro_t *
+STATIC rend_cache_failure_intro_t *
rend_cache_failure_intro_entry_new(rend_intro_point_failure_t failure)
{
rend_cache_failure_intro_t *entry = tor_malloc(sizeof(*entry));
@@ -138,7 +139,7 @@ rend_cache_failure_intro_entry_new(rend_intro_point_failure_t failure)
}
/** Helper: free a rend cache failure object. */
-static void
+STATIC void
rend_cache_failure_entry_free(rend_cache_failure_t *entry)
{
if (entry == NULL) {
@@ -164,7 +165,7 @@ rend_cache_failure_entry_free_(void *entry)
/** Allocate a rend cache failure object and return it. This function can
* not fail. */
-static rend_cache_failure_t *
+STATIC rend_cache_failure_t *
rend_cache_failure_entry_new(void)
{
rend_cache_failure_t *entry = tor_malloc(sizeof(*entry));
@@ -174,7 +175,7 @@ rend_cache_failure_entry_new(void)
/** Remove failure cache entry for the service ID in the given descriptor
* <b>desc</b>. */
-static void
+STATIC void
rend_cache_failure_remove(rend_service_descriptor_t *desc)
{
char service_id[REND_SERVICE_ID_LEN_BASE32 + 1];
@@ -194,7 +195,7 @@ rend_cache_failure_remove(rend_service_descriptor_t *desc)
}
/** Helper: free storage held by a single service descriptor cache entry. */
-static void
+STATIC void
rend_cache_entry_free(rend_cache_entry_t *e)
{
if (!e)
@@ -319,7 +320,7 @@ rend_cache_failure_purge(void)
* <b>identity</b> and service ID <b>service_id</b>. If found, the intro
* failure is set in <b>intro_entry</b> else it stays untouched. Return 1
* iff found else 0. */
-static int
+STATIC int
cache_failure_intro_lookup(const uint8_t *identity, const char *service_id,
rend_cache_failure_intro_t **intro_entry)
{
@@ -363,7 +364,7 @@ cache_failure_intro_dup(const rend_cache_failure_intro_t *entry)
/** Add an intro point failure to the failure cache using the relay
* <b>identity</b> and service ID <b>service_id</b>. Record the
* <b>failure</b> in that object. */
-static void
+STATIC void
cache_failure_intro_add(const uint8_t *identity, const char *service_id,
rend_intro_point_failure_t failure)
{
@@ -387,7 +388,7 @@ cache_failure_intro_add(const uint8_t *identity, const char *service_id,
* descriptor and kept into the failure cache. Then, each intro points that
* are NOT in the descriptor but in the failure cache for the given
* <b>service_id</b> are removed from the failure cache. */
-static void
+STATIC void
validate_intro_point_failure(const rend_service_descriptor_t *desc,
const char *service_id)
{
@@ -703,7 +704,6 @@ rend_cache_store_v2_desc_as_dir(const char *desc)
log_info(LD_REND, "Successfully stored service descriptor with desc ID "
"'%s' and len %d.",
safe_str(desc_id_base32), (int)encoded_size);
-
/* Statistics: Note down this potentially new HS. */
if (options->HiddenServiceStatistics) {
rep_hist_stored_maybe_new_hs(e->parsed->pk);