Esempio n. 1
0
static void
test_rend_cache_failure_entry_free(void *data)
{
  (void)data;

  // Test that it can deal with a NULL argument
  rend_cache_failure_entry_free(NULL);

 /* done: */
 /*  (void)0; */
}
Esempio n. 2
0
static void
test_rend_cache_failure_entry_new(void *data)
{
  rend_cache_failure_t *failure;

  (void)data;

  failure = rend_cache_failure_entry_new();
  tt_assert(failure);
  tt_int_op(digestmap_size(failure->intro_failures), OP_EQ, 0);

 done:
  rend_cache_failure_entry_free(failure);
}
Esempio n. 3
0
/** Remove failure cache entry for the service ID in the given descriptor
 * <b>desc</b>. */
STATIC void
rend_cache_failure_remove(rend_service_descriptor_t *desc)
{
  char service_id[REND_SERVICE_ID_LEN_BASE32 + 1];
  rend_cache_failure_t *entry;

  if (desc == NULL) {
    return;
  }
  if (rend_get_service_id(desc->pk, service_id) < 0) {
    return;
  }
  entry = strmap_get_lc(rend_cache_failure, service_id);
  if (entry != NULL) {
    strmap_remove_lc(rend_cache_failure, service_id);
    rend_cache_failure_entry_free(entry);
  }
}
Esempio n. 4
0
/** Remove all entries that re REND_CACHE_FAILURE_MAX_AGE old. This is
 * called every second.
 *
 * We have to clean these regurlarly else if for whatever reasons an hidden
 * service goes offline and a client tries to connect to it during that
 * time, a failure entry is created and the client will be unable to connect
 * for a while even though the service has return online.  */
void
rend_cache_failure_clean(time_t now)
{
  time_t cutoff = now - REND_CACHE_FAILURE_MAX_AGE;
  STRMAP_FOREACH_MODIFY(rend_cache_failure, key,
                        rend_cache_failure_t *, ent) {
    /* Free and remove every intro failure object that match the cutoff. */
    DIGESTMAP_FOREACH_MODIFY(ent->intro_failures, ip_key,
                             rend_cache_failure_intro_t *, ip_ent) {
      if (ip_ent->created_ts < cutoff) {
        rend_cache_failure_intro_entry_free(ip_ent);
        MAP_DEL_CURRENT(ip_key);
      }
    } DIGESTMAP_FOREACH_END;
    /* If the entry is now empty of intro point failures, remove it. */
    if (digestmap_isempty(ent->intro_failures)) {
      rend_cache_failure_entry_free(ent);
      MAP_DEL_CURRENT(key);
    }
  } STRMAP_FOREACH_END;
Esempio n. 5
0
/** Helper: deallocate a rend_cache_failure_t. (Used with strmap_free(),
 * which requires a function pointer whose argument is void*). */
STATIC void
rend_cache_failure_entry_free_(void *entry)
{
  rend_cache_failure_entry_free(entry);
}
Esempio n. 6
0
/** Helper: deallocate a rend_cache_failure_t. (Used with strmap_free(),
 * which requires a function pointer whose argument is void*). */
static void
rend_cache_failure_entry_free_(void *entry)
{
  rend_cache_failure_entry_free(entry);
}