aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2003-03-17 21:21:35 +0000
committerNick Mathewson <nickm@torproject.org>2003-03-17 21:21:35 +0000
commit4ad74c2141db709ff3c59e0547999f25a68efeae (patch)
tree1154636aa444cc227f13669206cbb4e3ce6f0bcf /src/or
parent6deed60bb5b5f495b4812f15c0e7a3b21fc440e4 (diff)
downloadtor-4ad74c2141db709ff3c59e0547999f25a68efeae.tar
tor-4ad74c2141db709ff3c59e0547999f25a68efeae.tar.gz
Do not uncompress from z_outbuf to outbuf unless outbuf is less than maximally full
svn:r188
Diffstat (limited to 'src/or')
-rw-r--r--src/or/connection.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/or/connection.c b/src/or/connection.c
index 23743cecd..cb02161fd 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -147,8 +147,8 @@ connection_t *connection_new(int type) {
} else {
conn->compression = conn->decompression = NULL;
}
- conn->done_sending = conn->done_receiving = 0
#endif
+ conn->done_sending = conn->done_receiving = 0;
return conn;
}
@@ -383,15 +383,22 @@ int connection_compress_from_buf(char *string, int len, connection_t *conn,
int connection_decompress_to_buf(char *string, int len, connection_t *conn,
int flush) {
- /* This is not sane with respect to flow control; we want to spool out to
- * z_outbuf, but only decompress and write as needed.
- */
int n;
struct timeval now;
- if (write_to_buf(string, len,
- &conn->z_outbuf, &conn->z_outbuflen, &conn->z_outbuf_datalen) < 0)
- return -1;
+ if (len) {
+ if (write_to_buf(string, len,
+ &conn->z_outbuf, &conn->z_outbuflen, &conn->z_outbuf_datalen) < 0)
+ return -1;
+ }
+
+ /* If we have more that 10 payloads worth of data waiting in outbuf,
+ * don't uncompress any more; queue this data in z_outbuf.
+ *
+ * This check should may be different.
+ */
+ if (connection_outbuf_too_full(conn->outbuf))
+ return 0;
n = decompress_buf_to_buf(
&conn->z_outbuf, &conn->z_outbuflen, &conn->z_outbuf_datalen,
@@ -411,6 +418,7 @@ int connection_decompress_to_buf(char *string, int len, connection_t *conn,
return 0;
conn->timestamp_lastwritten = now.tv_sec;
+ conn->outbuf_flushlen += n;
return n;
}