summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-10-14 03:06:48 +0000
committerRoger Dingledine <arma@torproject.org>2003-10-14 03:06:48 +0000
commit58ec05877a4f07dfc1680a26eeda91e6f81bf717 (patch)
tree0344d91fc4242ba02193a078016c6f9f354b2e1b
parentee9e54b43464d3792d000294dab264420e9784c5 (diff)
downloadtor-58ec05877a4f07dfc1680a26eeda91e6f81bf717.tar.gz
tor-58ec05877a4f07dfc1680a26eeda91e6f81bf717.zip
make the buffer resize stuff work
and make listener connections not have bufs svn:r584
-rw-r--r--src/or/buffers.c10
-rw-r--r--src/or/connection.c12
2 files changed, 13 insertions, 9 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 34ea1fa996..bb49e45f5f 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -45,8 +45,8 @@ static INLINE int buf_ensure_capacity(buf_t *buf, size_t capacity)
new_len = buf->len*2;
while (new_len < capacity)
new_len *= 2;
- log_fn(LOG_DEBUG,"Growing buffer from %ld to %ld bytes.",
- buf->len, new_len);
+ log_fn(LOG_DEBUG,"Growing buffer from %d to %d bytes.",
+ (int)buf->len, (int)new_len);
buf_resize(buf,new_len);
return 0;
}
@@ -63,9 +63,9 @@ static INLINE void buf_shrink_if_underfull(buf_t *buf) {
new_len = buf->len / 2;
while (buf->datalen < new_len/4 && new_len/2 > MIN_BUF_SHRINK_SIZE)
new_len /= 2;
- log_fn(LOG_DEBUG,"Shrinking buffer from %ld to %ld bytes.",
- buf->len, new_len);
- buf_resize(buf->buf, new_len);
+ log_fn(LOG_DEBUG,"Shrinking buffer from %d to %d bytes.",
+ (int)buf->len, (int)new_len);
+ buf_resize(buf, new_len);
}
/* Remove the first 'n' bytes from buf.
diff --git a/src/or/connection.c b/src/or/connection.c
index dcdb474a16..7a0d0b8b63 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -80,8 +80,10 @@ connection_t *connection_new(int type) {
memset(conn,0,sizeof(connection_t)); /* zero it out to start */
conn->type = type;
- conn->inbuf = buf_new();
- conn->outbuf = buf_new();
+ if(!connection_is_listener(conn)) { /* listeners never use their buf */
+ conn->inbuf = buf_new();
+ conn->outbuf = buf_new();
+ }
conn->timestamp_created = now;
conn->timestamp_lastread = now;
@@ -93,8 +95,10 @@ connection_t *connection_new(int type) {
void connection_free(connection_t *conn) {
assert(conn);
- buf_free(conn->inbuf);
- buf_free(conn->outbuf);
+ if(!connection_is_listener(conn)) {
+ buf_free(conn->inbuf);
+ buf_free(conn->outbuf);
+ }
if(conn->address)
free(conn->address);