mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-21 21:44:58 +02:00
more cleanups on the hsusage patch
svn:r10077
This commit is contained in:
parent
590c6ff33d
commit
e9c4dd1304
@ -141,7 +141,7 @@ static char* nt_strerror(uint32_t errnum);
|
|||||||
/** How long do we let OR connections handshake before we decide that
|
/** How long do we let OR connections handshake before we decide that
|
||||||
* they are obsolete? */
|
* they are obsolete? */
|
||||||
#define TLS_HANDSHAKE_TIMEOUT (60)
|
#define TLS_HANDSHAKE_TIMEOUT (60)
|
||||||
/** How often do we write hidden service usage statistics to disk* */
|
/** How often do we write hidden service usage statistics to disk? */
|
||||||
#define WRITE_HSUSAGE_INTERVAL (900)
|
#define WRITE_HSUSAGE_INTERVAL (900)
|
||||||
|
|
||||||
/********* END VARIABLES ************/
|
/********* END VARIABLES ************/
|
||||||
|
@ -2800,7 +2800,7 @@ void dump_pk_ops(int severity);
|
|||||||
|
|
||||||
void rep_hist_free_all(void);
|
void rep_hist_free_all(void);
|
||||||
|
|
||||||
/* for hidden service usage statistic */
|
/* for hidden service usage statistics */
|
||||||
void hs_usage_note_publish_total(const char *service_id, time_t now);
|
void hs_usage_note_publish_total(const char *service_id, time_t now);
|
||||||
void hs_usage_note_publish_novel(const char *service_id, time_t now);
|
void hs_usage_note_publish_novel(const char *service_id, time_t now);
|
||||||
void hs_usage_note_fetch_total(const char *service_id, time_t now);
|
void hs_usage_note_fetch_total(const char *service_id, time_t now);
|
||||||
|
@ -399,7 +399,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published)
|
|||||||
}
|
}
|
||||||
/* report novel publication to statistics */
|
/* report novel publication to statistics */
|
||||||
if (published && options->HSAuthorityRecordStats) {
|
if (published && options->HSAuthorityRecordStats) {
|
||||||
hs_usage_note_publish_total(query, time(NULL));
|
hs_usage_note_publish_total(query, now);
|
||||||
}
|
}
|
||||||
e = (rend_cache_entry_t*) strmap_get_lc(rend_cache, key);
|
e = (rend_cache_entry_t*) strmap_get_lc(rend_cache, key);
|
||||||
if (e && e->parsed->timestamp > parsed->timestamp) {
|
if (e && e->parsed->timestamp > parsed->timestamp) {
|
||||||
@ -420,7 +420,7 @@ rend_cache_store(const char *desc, size_t desc_len, int published)
|
|||||||
strmap_set_lc(rend_cache, key, e);
|
strmap_set_lc(rend_cache, key, e);
|
||||||
/* report novel publication to statistics */
|
/* report novel publication to statistics */
|
||||||
if (published && options->HSAuthorityRecordStats) {
|
if (published && options->HSAuthorityRecordStats) {
|
||||||
hs_usage_note_publish_novel(query, time(NULL));
|
hs_usage_note_publish_novel(query, now);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
rend_service_descriptor_free(e->parsed);
|
rend_service_descriptor_free(e->parsed);
|
||||||
|
@ -1271,7 +1271,7 @@ hs_usage_free_all(void)
|
|||||||
current_period = NULL;
|
current_period = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Inserts a new occurence for the given service id to the given ordered
|
/** Inserts a new occurrence for the given service id to the given ordered
|
||||||
* list. */
|
* list. */
|
||||||
static void
|
static void
|
||||||
hs_usage_insert_value(hs_usage_list_t *lst, const char *service_id)
|
hs_usage_insert_value(hs_usage_list_t *lst, const char *service_id)
|
||||||
@ -1279,7 +1279,7 @@ hs_usage_insert_value(hs_usage_list_t *lst, const char *service_id)
|
|||||||
/* search if there is already an elem with same service_id in list */
|
/* search if there is already an elem with same service_id in list */
|
||||||
hs_usage_list_elem_t *current = lst->start;
|
hs_usage_list_elem_t *current = lst->start;
|
||||||
hs_usage_list_elem_t *previous = NULL;
|
hs_usage_list_elem_t *previous = NULL;
|
||||||
while (current != NULL && strcmp(current->service_id,service_id)) {
|
while (current != NULL && strcasecmp(current->service_id,service_id)) {
|
||||||
previous = current;
|
previous = current;
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
@ -1289,7 +1289,7 @@ hs_usage_insert_value(hs_usage_list_t *lst, const char *service_id)
|
|||||||
* list), don't need to sort (1 is smallest value). */
|
* list), don't need to sort (1 is smallest value). */
|
||||||
/* create elem */
|
/* create elem */
|
||||||
hs_usage_list_elem_t *e = hs_usage_list_elem_new();
|
hs_usage_list_elem_t *e = hs_usage_list_elem_new();
|
||||||
/* update list attributes (one new elem, one new occurence) */
|
/* update list attributes (one new elem, one new occurrence) */
|
||||||
lst->total_count++;
|
lst->total_count++;
|
||||||
lst->total_service_ids++;
|
lst->total_service_ids++;
|
||||||
/* copy service id to elem */
|
/* copy service id to elem */
|
||||||
@ -1303,10 +1303,10 @@ hs_usage_insert_value(hs_usage_list_t *lst, const char *service_id)
|
|||||||
previous->next = e;
|
previous->next = e;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* found! add occurence to elem and consider resorting */
|
/* found! add occurrence to elem and consider resorting */
|
||||||
/* update list attributes (no new elem, but one new occurence) */
|
/* update list attributes (no new elem, but one new occurrence) */
|
||||||
lst->total_count++;
|
lst->total_count++;
|
||||||
/* add occurence to elem */
|
/* add occurrence to elem */
|
||||||
current->count++;
|
current->count++;
|
||||||
/* is it another than the first list elem? and has previous elem fewer
|
/* is it another than the first list elem? and has previous elem fewer
|
||||||
* count than current? then we need to resort */
|
* count than current? then we need to resort */
|
||||||
|
Loading…
Reference in New Issue
Block a user