aboutsummaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-10-04 03:29:09 +0000
committerRoger Dingledine <arma@torproject.org>2003-10-04 03:29:09 +0000
commitbe874358a4385d8d6bd7f82d3f372bb79055033c (patch)
tree72b615a6357820b49e9a66ab32c3554463a7834c /src/or/command.c
parentf563bbd2f988cd1f6ca292f89a47a86f98fe0e8d (diff)
downloadtor-be874358a4385d8d6bd7f82d3f372bb79055033c.tar
tor-be874358a4385d8d6bd7f82d3f372bb79055033c.tar.gz
wrap strdup; prefer time() to gettimeofday()
svn:r538
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 6195e5c13..8caabf41d 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -25,11 +25,11 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn,
*num += 1;
- my_gettimeofday(&start);
+ tor_gettimeofday(&start);
(*func)(cell, conn);
- my_gettimeofday(&end);
+ tor_gettimeofday(&end);
time_passed = tv_udiff(&start, &end) ;
if (time_passed > 5000) { /* more than 5ms */
@@ -38,17 +38,13 @@ static void command_time_process_cell(cell_t *cell, connection_t *conn,
*time += time_passed;
}
-
-
void command_process_cell(cell_t *cell, connection_t *conn) {
static int num_create=0, num_created=0, num_relay=0, num_destroy=0;
static int create_time=0, created_time=0, relay_time=0, destroy_time=0;
- static long current_second = 0; /* from previous calls to gettimeofday */
- struct timeval now;
-
- my_gettimeofday(&now);
+ static time_t current_second = 0; /* from previous calls to time */
+ time_t now = time(NULL);
- if(now.tv_sec > current_second) { /* the second has rolled over */
+ if(now > current_second) { /* the second has rolled over */
/* print stats */
log(LOG_INFO,"At end of second:");
log(LOG_INFO,"Create: %d (%d ms)", num_create, create_time/1000);
@@ -61,7 +57,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) {
create_time = created_time = relay_time = destroy_time = 0;
/* remember which second it is, for next time */
- current_second = now.tv_sec;
+ current_second = now;
}
switch(cell->command) {