summaryrefslogtreecommitdiff
path: root/src/or/command.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-04-16 17:04:58 +0000
committerNick Mathewson <nickm@torproject.org>2003-04-16 17:04:58 +0000
commit33176c70a5b9bb345d96af22178c003e177b2bb9 (patch)
tree10336e1543ad7f638f0f147e65864ef7a3eb6e66 /src/or/command.c
parent0c61bc3756e833abe97999fa2a22b944a9ce3931 (diff)
downloadtor-33176c70a5b9bb345d96af22178c003e177b2bb9.tar.gz
tor-33176c70a5b9bb345d96af22178c003e177b2bb9.zip
Factor out timeval-related functions.
svn:r237
Diffstat (limited to 'src/or/command.c')
-rw-r--r--src/or/command.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/or/command.c b/src/or/command.c
index 878d26e0a0..2ec250000b 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -14,24 +14,14 @@ void command_time_process_cell(cell_t *cell, connection_t *conn,
*num += 1;
- if(gettimeofday(&start,NULL) < 0) {
- log(LOG_ERR,"command_time_process_cell(): gettimeofday failed.");
- return;
- }
+ my_gettimeofday(&start);
(*func)(cell, conn);
- if(gettimeofday(&end,NULL) < 0) {
- log(LOG_ERR,"command_time_process_cell(): gettimeofday failed.");
- return;
- }
+ my_gettimeofday(&end);
+ time_passed = tv_udiff(&start, &end) ;
- if(end.tv_usec < start.tv_usec) {
- end.tv_sec--;
- end.tv_usec += 1000000;
- }
- time_passed = ((end.tv_sec - start.tv_sec)*1000000) + (end.tv_usec - start.tv_usec);
- if(time_passed > 5000) { /* more than 5ms */
+ if (time_passed > 5000) { /* more than 5ms */
log(LOG_INFO,"command_time_process_cell(): That call just took %d ms.",time_passed/1000);
}
*time += time_passed;
@@ -43,10 +33,7 @@ void command_process_cell(cell_t *cell, connection_t *conn) {
static long current_second = 0; /* from previous calls to gettimeofday */
struct timeval now;
- if(gettimeofday(&now,NULL) < 0) {
- log(LOG_ERR,"command_process_cell(): gettimeofday failed.");
- return;
- }
+ my_gettimeofday(&now);
if(now.tv_sec > current_second) { /* the second has rolled over */
/* print stats */