aboutsummaryrefslogtreecommitdiff
path: root/src/or/relay.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-11-07 12:15:30 -0500
committerNick Mathewson <nickm@torproject.org>2013-11-07 12:15:30 -0500
commit1b8ceb83c951f1cdea6b71a615a10d33b8adf2b3 (patch)
tree0046cb887736bb8007a31c6f390cdbebf5a70133 /src/or/relay.c
parent82d8944928daf868d12797e59a3a58ce4cb4f205 (diff)
downloadtor-1b8ceb83c951f1cdea6b71a615a10d33b8adf2b3.tar
tor-1b8ceb83c951f1cdea6b71a615a10d33b8adf2b3.tar.gz
Improved circuit queue out-of-memory handler
Previously, when we ran low on memory, we'd close whichever circuits had the most queued cells. Now, we close those that have the *oldest* queued cells, on the theory that those are most responsible for us running low on memory, and that those are the least likely to actually drain on their own if we wait a little longer. Based on analysis from a forthcoming paper by Jansen, Tschorsch, Johnson, and Scheuermann. Fixes bug 9093.
Diffstat (limited to 'src/or/relay.c')
-rw-r--r--src/or/relay.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/or/relay.c b/src/or/relay.c
index fda9e89ca..a193ad843 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1904,15 +1904,19 @@ cell_queue_append(cell_queue_t *queue, packed_cell_t *cell)
void
cell_queue_append_packed_copy(cell_queue_t *queue, const cell_t *cell)
{
+ struct timeval now;
packed_cell_t *copy = packed_cell_copy(cell);
+ tor_gettimeofday_cached(&now);
+ copy->inserted_time = (uint32_t)tv_to_msec(&now);
+
/* Remember the time when this cell was put in the queue. */
+ /*XXXX This may be obsoleted by inserted_time */
if (get_options()->CellStatistics) {
- struct timeval now;
uint32_t added;
insertion_time_queue_t *it_queue = queue->insertion_times;
if (!it_pool)
it_pool = mp_pool_new(sizeof(insertion_time_elem_t), 1024);
- tor_gettimeofday_cached(&now);
+
#define SECONDS_IN_A_DAY 86400L
added = (uint32_t)(((now.tv_sec % SECONDS_IN_A_DAY) * 100L)
+ ((uint32_t)now.tv_usec / (uint32_t)10000L));