Commit 85f38115 authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

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
parent 6dc13cdb
......@@ -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);
......
......@@ -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 "
......
......@@ -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.) */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment