[or-cvs] make the buffer resize stuff work
Roger Dingledine
arma at seul.org
Tue Oct 14 03:06:51 UTC 2003
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or
Modified Files:
buffers.c connection.c
Log Message:
make the buffer resize stuff work
and make listener connections not have bufs
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- buffers.c 14 Oct 2003 01:34:31 -0000 1.46
+++ buffers.c 14 Oct 2003 03:06:48 -0000 1.47
@@ -45,8 +45,8 @@
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 @@
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.
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- connection.c 10 Oct 2003 01:48:32 -0000 1.119
+++ connection.c 14 Oct 2003 03:06:48 -0000 1.120
@@ -80,8 +80,10 @@
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 @@
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);
More information about the tor-commits
mailing list