aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-07-28 15:11:20 +0000
committerNick Mathewson <nickm@torproject.org>2006-07-28 15:11:20 +0000
commit85f381153ba6a3c87e3e43e2640b313c27d9b2ff (patch)
tree46959266a23814748b6e4c7d18c811d10639ff26
parent6dc13cdbeb184fb906e50e79346e684d83a49eb5 (diff)
downloadtor-85f381153ba6a3c87e3e43e2640b313c27d9b2ff.tar
tor-85f381153ba6a3c87e3e43e2640b313c27d9b2ff.tar.gz
r6949@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 svn:r6934
-rw-r--r--src/or/connection.c6
-rw-r--r--src/or/main.c6
-rw-r--r--src/or/or.h22
3 files changed, 15 insertions, 19 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 8b241fcea..f5149a404 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1391,9 +1391,11 @@ connection_read_to_buf(connection_t *conn, int *max_to_read)
}
} 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);
diff --git a/src/or/main.c b/src/or/main.c
index 4ef3260e8..4370dcbc1 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -588,8 +588,8 @@ run_connection_housekeeping(int i, time_t now)
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 @@ run_connection_housekeeping(int i, time_t now)
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 "
diff --git a/src/or/or.h b/src/or/or.h
index 667ed1a2f..d05475617 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -606,7 +606,7 @@ typedef struct connection_t {
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 @@ typedef struct connection_t {
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 @@ typedef struct or_connection_t {
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.) */