summaryrefslogtreecommitdiff
path: root/src/or/main.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2008-12-18 17:19:04 +0000
committerNick Mathewson <nickm@torproject.org>2008-12-18 17:19:04 +0000
commitbf80e2df3fe48f81c69bb68887376b02ab247e5f (patch)
treed95e835992abf9a2bad5954042ea38e5a6a9df3c /src/or/main.c
parentb91335117f9faf84001acc65859886e4ddc267a5 (diff)
downloadtor-bf80e2df3fe48f81c69bb68887376b02ab247e5f.tar.gz
tor-bf80e2df3fe48f81c69bb68887376b02ab247e5f.zip
Replace calls to time(NULL) that occur on the order of once per read, one per write, or once per cell with calls to a function that looks at a cached value of time. This is tricksy to benchmark, since it will only help on systems where time() is a syscall and syscalls are relatively slow.
svn:r17690
Diffstat (limited to 'src/or/main.c')
-rw-r--r--src/or/main.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 762e14f801..17cd6d2676 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1192,6 +1192,7 @@ second_elapsed_callback(int fd, short event, void *args)
/* log_fn(LOG_NOTICE, "Tick."); */
tor_gettimeofday(&now);
+ update_approx_time(now.tv_sec);
/* the second has rolled over. check more stuff. */
bytes_written = stats_prev_global_write_bucket - global_write_bucket;
@@ -1461,6 +1462,8 @@ do_main_loop(void)
event_active(conn->read_event, EV_READ, 1));
called_loop_once = smartlist_len(active_linked_connection_lst) ? 1 : 0;
+ update_approx_time(time(NULL));
+
/* poll until we have an event, or the second ends, or until we have
* some active linked connections to trigger events for. */
loop_result = event_loop(called_loop_once ? EVLOOP_ONCE : 0);
@@ -2059,6 +2062,7 @@ int
tor_main(int argc, char *argv[])
{
int result = 0;
+ update_approx_time(time(NULL));
tor_threads_init();
init_logging();
#ifdef USE_DMALLOC