[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Clean up some logging and interfaces



Update of /home/or/cvsroot/tor/src/common
In directory moria.mit.edu:/tmp/cvs-serv1670/src/common

Modified Files:
	tortls.c util.c 
Log Message:
Clean up some logging and interfaces

Index: tortls.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/tortls.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- tortls.c	15 Nov 2004 23:29:24 -0000	1.76
+++ tortls.c	23 Nov 2004 00:08:26 -0000	1.77
@@ -441,12 +441,13 @@
   if (r > 0)
     return r;
   err = tor_tls_get_error(tls, r, CATCH_ZERO, "reading", LOG_INFO);
-  log_fn(LOG_DEBUG,"returned r=%d, err=%d",r,err);
   if (err == _TOR_TLS_ZERORETURN) {
+    log_fn(LOG_DEBUG,"read returned r=%d; TLS is closed",r);
     tls->state = TOR_TLS_ST_CLOSED;
     return TOR_TLS_CLOSE;
   } else {
     tor_assert(err != TOR_TLS_DONE);
+    log_fn(LOG_DEBUG,"read returned r=%d, err=%d",r,err);
     return err;
   }
 }
@@ -479,7 +480,6 @@
     return r;
   }
   if (err == TOR_TLS_WANTWRITE || err == TOR_TLS_WANTREAD) {
-//    log_fn(LOG_INFO,"wantwrite or wantread. remembering the number %d.",n);
     tls->wantwrite_n = n;
   }
   return err;
@@ -685,7 +685,6 @@
   if (!(chain = SSL_get_peer_cert_chain(tls->ssl)))
     goto done;
   num_in_chain = sk_X509_num(chain);
-  log_fn(LOG_DEBUG,"Number of certs in chain: %d", num_in_chain);
   /* 1 means we're receiving (server-side), and it's just the id_cert.
    * 2 means we're connecting (client-side), and it's both the link
    * cert and the id_cert.

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/common/util.c,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -d -r1.183 -r1.184
--- util.c	22 Nov 2004 23:28:26 -0000	1.183
+++ util.c	23 Nov 2004 00:08:26 -0000	1.184
@@ -475,7 +475,6 @@
  * ===== */
 
 /** Return the number of microseconds elapsed between *start and *end.
- * If start is after end, return 0.
  */
 long
 tv_udiff(struct timeval *start, struct timeval *end)
@@ -483,17 +482,12 @@
   long udiff;
   long secdiff = end->tv_sec - start->tv_sec;
 
-  if (secdiff+1 > LONG_MAX/1000000) {
+  if (labs(secdiff+1) > LONG_MAX/1000000) {
     log_fn(LOG_WARN, "comparing times too far apart.");
     return LONG_MAX;
   }
 
   udiff = secdiff*1000000L + (end->tv_usec - start->tv_usec);
-  if(udiff < 0) {
-    log_fn(LOG_INFO, "start (%ld.%ld) is after end (%ld.%ld). Returning 0.",
-           (long)start->tv_sec, (long)start->tv_usec, (long)end->tv_sec, (long)end->tv_usec);
-    return 0;
-  }
   return udiff;
 }