diff options
author | Nick Mathewson <nickm@torproject.org> | 2003-04-16 17:04:58 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2003-04-16 17:04:58 +0000 |
commit | 33176c70a5b9bb345d96af22178c003e177b2bb9 (patch) | |
tree | 10336e1543ad7f638f0f147e65864ef7a3eb6e66 /src/or/circuit.c | |
parent | 0c61bc3756e833abe97999fa2a22b944a9ce3931 (diff) | |
download | tor-33176c70a5b9bb345d96af22178c003e177b2bb9.tar tor-33176c70a5b9bb345d96af22178c003e177b2bb9.tar.gz |
Factor out timeval-related functions.
svn:r237
Diffstat (limited to 'src/or/circuit.c')
-rw-r--r-- | src/or/circuit.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/or/circuit.c b/src/or/circuit.c index 17dcc0662..cc9f51b9b 100644 --- a/src/or/circuit.c +++ b/src/or/circuit.c @@ -53,8 +53,7 @@ circuit_t *circuit_new(aci_t p_aci, connection_t *p_conn) { circuit_t *circ; struct timeval now; - if(gettimeofday(&now,NULL) < 0) - return NULL; + my_gettimeofday(&now); circ = (circuit_t *)malloc(sizeof(circuit_t)); if(!circ) @@ -157,7 +156,7 @@ int circuit_init(circuit_t *circ, int aci_type, onion_layer_t *layer) { log(LOG_DEBUG,"circuit_init(): aci_type = %u.",aci_type); - gettimeofday(&start,NULL); + my_gettimeofday(&start); circ->n_aci = get_unique_aci_by_addr_port(circ->n_addr, circ->n_port, aci_type); if(!circ->n_aci) { @@ -165,19 +164,12 @@ int circuit_init(circuit_t *circ, int aci_type, onion_layer_t *layer) { return -1; } - gettimeofday(&end,NULL); + my_gettimeofday(&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 > 1000) { /* more than 1ms */ + if (tv_udiff(&start, &end) > 1000) {/* more than 1ms */ log(LOG_NOTICE,"circuit_init(): get_unique_aci just took %d us!",time_passed); } - - log(LOG_DEBUG,"circuit_init(): Chosen ACI %u.",circ->n_aci); /* keys */ |