mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Merge remote-tracking branch 'public/bug10169_024' into bug10169_025_v2
Conflicts: src/common/compat_libevent.h src/or/relay.c
This commit is contained in:
commit
bb37544214
@ -673,3 +673,33 @@ tor_gettimeofday_cache_set(const struct timeval *tv)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* As tor_gettimeofday_cached, but can never move backwards in time.
|
||||||
|
*
|
||||||
|
* The returned value may diverge from wall-clock time, since wall-clock time
|
||||||
|
* can trivially be adjusted backwards, and this can't. Don't mix wall-clock
|
||||||
|
* time with these values in the same calculation.
|
||||||
|
*
|
||||||
|
* Depending on implementation, this function may or may not "smooth out" huge
|
||||||
|
* jumps forward in wall-clock time. It may or may not keep its results
|
||||||
|
* advancing forward (as opposed to stalling) if the wall-clock time goes
|
||||||
|
* backwards. The current implementation does neither of of these.
|
||||||
|
*
|
||||||
|
* This function is not thread-safe; do not call it outside the main thread.
|
||||||
|
*
|
||||||
|
* In future versions of Tor, this may return a time does not have its
|
||||||
|
* origin at the Unix epoch.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
tor_gettimeofday_cached_monotonic(struct timeval *tv)
|
||||||
|
{
|
||||||
|
struct timeval last_tv = { 0, 0 };
|
||||||
|
|
||||||
|
tor_gettimeofday_cached(tv);
|
||||||
|
if (timercmp(tv, &last_tv, <)) {
|
||||||
|
memcpy(tv, &last_tv, sizeof(struct timeval));
|
||||||
|
} else {
|
||||||
|
memcpy(&last_tv, tv, sizeof(struct timeval));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -94,6 +94,7 @@ void tor_gettimeofday_cache_clear(void);
|
|||||||
#ifdef TOR_UNIT_TESTS
|
#ifdef TOR_UNIT_TESTS
|
||||||
void tor_gettimeofday_cache_set(const struct timeval *tv);
|
void tor_gettimeofday_cache_set(const struct timeval *tv);
|
||||||
#endif
|
#endif
|
||||||
|
void tor_gettimeofday_cached_monotonic(struct timeval *tv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -680,7 +680,7 @@ buf_add_chunk_with_capacity(buf_t *buf, size_t capacity, int capped)
|
|||||||
chunk = chunk_new_with_alloc_size(preferred_chunk_size(capacity));
|
chunk = chunk_new_with_alloc_size(preferred_chunk_size(capacity));
|
||||||
}
|
}
|
||||||
|
|
||||||
tor_gettimeofday_cached(&now);
|
tor_gettimeofday_cached_monotonic(&now);
|
||||||
chunk->inserted_time = (uint32_t)tv_to_msec(&now);
|
chunk->inserted_time = (uint32_t)tv_to_msec(&now);
|
||||||
|
|
||||||
if (buf->tail) {
|
if (buf->tail) {
|
||||||
|
@ -1794,7 +1794,7 @@ circuits_handle_oom(size_t current_allocation)
|
|||||||
mem_to_recover = current_allocation - mem_target;
|
mem_to_recover = current_allocation - mem_target;
|
||||||
}
|
}
|
||||||
|
|
||||||
tor_gettimeofday_cached(&now);
|
tor_gettimeofday_cached_monotonic(&now);
|
||||||
now_ms = (uint32_t)tv_to_msec(&now);
|
now_ms = (uint32_t)tv_to_msec(&now);
|
||||||
|
|
||||||
/* This algorithm itself assumes that you've got enough memory slack
|
/* This algorithm itself assumes that you've got enough memory slack
|
||||||
@ -1832,9 +1832,11 @@ circuits_handle_oom(size_t current_allocation)
|
|||||||
buf_shrink_freelists(1); /* This is necessary to actually release buffer
|
buf_shrink_freelists(1); /* This is necessary to actually release buffer
|
||||||
chunks. */
|
chunks. */
|
||||||
|
|
||||||
log_notice(LD_GENERAL, "Removed "U64_FORMAT" bytes by killing %d circuits.",
|
log_notice(LD_GENERAL, "Removed "U64_FORMAT" bytes by killing %d circuits; "
|
||||||
|
"%d circuits remain alive.",
|
||||||
U64_PRINTF_ARG(mem_recovered),
|
U64_PRINTF_ARG(mem_recovered),
|
||||||
n_circuits_killed);
|
n_circuits_killed,
|
||||||
|
smartlist_len(circlist) - n_circuits_killed);
|
||||||
|
|
||||||
smartlist_free(circlist);
|
smartlist_free(circlist);
|
||||||
}
|
}
|
||||||
|
@ -2151,7 +2151,8 @@ cell_queue_append_packed_copy(circuit_t *circ, cell_queue_t *queue,
|
|||||||
(void)circ;
|
(void)circ;
|
||||||
(void)exitward;
|
(void)exitward;
|
||||||
(void)use_stats;
|
(void)use_stats;
|
||||||
tor_gettimeofday_cached(&now);
|
tor_gettimeofday_cached_monotonic(&now);
|
||||||
|
|
||||||
copy->inserted_time = (uint32_t)tv_to_msec(&now);
|
copy->inserted_time = (uint32_t)tv_to_msec(&now);
|
||||||
|
|
||||||
cell_queue_append(queue, copy);
|
cell_queue_append(queue, copy);
|
||||||
|
Loading…
Reference in New Issue
Block a user