[or-cvs] r6934: Shave another 8 bytes from connection_t: turn inbuf_reached_ (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri Jul 28 15:11:21 UTC 2006


Author: nickm
Date: 2006-07-28 11:11:20 -0400 (Fri, 28 Jul 2006)
New Revision: 6934

Modified:
   tor/trunk/
   tor/trunk/src/or/connection.c
   tor/trunk/src/or/main.c
   tor/trunk/src/or/or.h
Log:
 r6949 at Kushana:  nickm | 2006-07-28 10:17:38 -0400
 Shave another 8 bytes from connection_t: turn inbuf_reached_eof into a bit, and lower timestamp_lastempty to or_connection_t



Property changes on: tor/trunk
___________________________________________________________________
Name: svk:merge
   - c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6948
   + c95137ef-5f19-0410-b913-86e773d04f59:/tor/branches/oo-connections:6949

Modified: tor/trunk/src/or/connection.c
===================================================================
--- tor/trunk/src/or/connection.c	2006-07-28 15:11:11 UTC (rev 6933)
+++ tor/trunk/src/or/connection.c	2006-07-28 15:11:20 UTC (rev 6934)
@@ -1391,9 +1391,11 @@
     }
 
   } else {
+    int reached_eof = 0;
     CONN_LOG_PROTECT(conn,
-        result = read_to_buf(conn->s, at_most, conn->inbuf,
-                             &conn->inbuf_reached_eof));
+        result = read_to_buf(conn->s, at_most, conn->inbuf, &reached_eof));
+    if (reached_eof)
+      conn->inbuf_reached_eof = 1;
 
 //  log_fn(LOG_DEBUG,"read_to_buf returned %d.",read_result);
 

Modified: tor/trunk/src/or/main.c
===================================================================
--- tor/trunk/src/or/main.c	2006-07-28 15:11:11 UTC (rev 6933)
+++ tor/trunk/src/or/main.c	2006-07-28 15:11:20 UTC (rev 6934)
@@ -588,8 +588,8 @@
   or_options_t *options = get_options();
   or_connection_t *or_conn;
 
-  if (conn->outbuf && !buf_datalen(conn->outbuf))
-    conn->timestamp_lastempty = now;
+  if (conn->outbuf && !buf_datalen(conn->outbuf) && conn->type == CONN_TYPE_OR)
+    TO_OR_CONN(conn)->timestamp_lastempty = now;
 
   if (conn->marked_for_close) {
     /* nothing to do here */
@@ -684,7 +684,7 @@
       connection_mark_for_close(conn);
       conn->hold_open_until_flushed = 1;
     } else if (
-         now >= conn->timestamp_lastempty + options->KeepalivePeriod*10 &&
+         now >= or_conn->timestamp_lastempty + options->KeepalivePeriod*10 &&
          now >= conn->timestamp_lastwritten + options->KeepalivePeriod*10) {
       log_fn(LOG_PROTOCOL_WARN,LD_PROTOCOL,
              "Expiring stuck OR connection to fd %d (%s:%d). (%d bytes to "

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2006-07-28 15:11:11 UTC (rev 6933)
+++ tor/trunk/src/or/or.h	2006-07-28 15:11:20 UTC (rev 6934)
@@ -606,7 +606,7 @@
 
   uint8_t type; /**< What kind of connection is this? */
   uint8_t state; /**< Current state of this connection. */
-  uint8_t purpose; /**< Only used for DIR and EXIT types currently. !!! */
+  uint8_t purpose; /**< Only used for DIR and EXIT types currently. */
   unsigned wants_to_read:1; /**< Boolean: should we start reading again once
                             * the bandwidth throttler allows it? */
   unsigned wants_to_write:1; /**< Boolean: should we start writing again once
@@ -614,40 +614,32 @@
   unsigned hold_open_until_flushed:1; /**< Despite this connection's being
                                       * marked for close, do we flush it
                                       * before closing it? */
-
   unsigned edge_has_sent_end:1; /**< For debugging; only used on edge
                          * connections.  Set once we've set the stream end,
                          * and check in circuit_about_to_close_connection(). */
   /** For control connections only. If set, we send extended info with control
-   * events as appropriate. !!!! */
+   * events as appropriate. */
   unsigned int control_events_are_extended:1;
   /** Used for OR conns that shouldn't get any new circs attached to them. !!*/
   unsigned int or_is_obsolete:1;
   /** For AP connections only. If 1, and we fail to reach the chosen exit,
-   * stop requiring it. !!! */
+   * stop requiring it. */
   unsigned int chosen_exit_optional:1;
+  int inbuf_reached_eof:1; /**< Boolean: did read() return 0 on this conn? */
 
   int s; /**< Our socket; -1 if this connection is closed. */
   int conn_array_index; /**< Index into the global connection array. */
   struct event *read_event; /**< Libevent event structure. */
   struct event *write_event; /**< Libevent event structure. */
   buf_t *inbuf; /**< Buffer holding data read over this connection. */
-  int inbuf_reached_eof; /**< Boolean: did read() return 0 on this conn?
-                          * (!!!bitfield?)
-                          */
-  time_t timestamp_lastread; /**< When was the last time libevent said we could
-                              * read? */
-
   buf_t *outbuf; /**< Buffer holding data to write over this connection. */
   size_t outbuf_flushlen; /**< How much data should we try to flush from the
                            * outbuf? */
+  time_t timestamp_lastread; /**< When was the last time libevent said we could
+                              * read? */
   time_t timestamp_lastwritten; /**< When was the last time libevent said we
                                  * could write? */
-
   time_t timestamp_created; /**< When was this connection_t created? */
-  time_t timestamp_lastempty; /**< When was the outbuf last completely empty?
-                               * !!!!
-                               */
 
   uint32_t addr; /**< IP of the other side of the connection; used to identify
                   * routers, along with port. */
@@ -675,6 +667,8 @@
 
   tor_tls_t *tls; /**< TLS connection state */
 
+  time_t timestamp_lastempty; /**< When was the outbuf last completely empty?*/
+
   /* bandwidth* and receiver_bucket only used by ORs in OPEN state: */
   int bandwidthrate; /**< Bytes/s added to the bucket. (OPEN ORs only.) */
   int bandwidthburst; /**< Max bucket size for this conn. (OPEN ORs only.) */



More information about the tor-commits mailing list