diff options
author | Roger Dingledine <arma@torproject.org> | 2003-07-05 07:10:34 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-07-05 07:10:34 +0000 |
commit | c6f70e36e0125af0a9205f50fd5df5bfd16be780 (patch) | |
tree | 3f3169efa6ca406c8b5caf716616e6bcdc20a2bd /src/or/buffers.c | |
parent | 9f58a2ece416c9d407b0895243fbbc1cfeef82ed (diff) | |
download | tor-c6f70e36e0125af0a9205f50fd5df5bfd16be780.tar.gz tor-c6f70e36e0125af0a9205f50fd5df5bfd16be780.zip |
implemented total read rate limiting
svn:r365
Diffstat (limited to 'src/or/buffers.c')
-rw-r--r-- | src/or/buffers.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 010547f355..4a89b260d4 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -28,7 +28,7 @@ void buf_free(char *buf) { free(buf); } -/* read from socket s, writing onto buf+buf_datalen. If at_most is >= 0 then +/* read from socket s, writing onto buf+buf_datalen. * read at most 'at_most' bytes, and in any case don't read more than will fit based on buflen. * If read() returns 0, set *reached_eof to 1 and return 0. If you want to tear * down the connection return -1, else return the number of bytes read. @@ -41,9 +41,8 @@ int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, i /* this is the point where you would grow the buffer, if you want to */ - if(at_most < 0 || *buflen - *buf_datalen < at_most) + if(at_most > *buflen - *buf_datalen) at_most = *buflen - *buf_datalen; /* take the min of the two */ - /* (note that this only modifies at_most inside this function) */ if(at_most == 0) return 0; /* we shouldn't read anything */ |