diff options
-rw-r--r-- | Changelog-Trunk.txt | 2 | ||||
-rw-r--r-- | src/common/socket.c | 12 |
2 files changed, 13 insertions, 1 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index d971ad4f6..b29d1fc9d 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -4,6 +4,8 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. 2009/01/21 + * Added a limit of 1MB of pending data in the write fifo for non-server sockets. + Connections that go over the limit are closed. * Replaced the fake timer heap (sorted array) with a real heap. (improves performance) [FlavioJS] 2009/01/20 * Added a generic binary heap implementation based on defines. [FlavioJS] diff --git a/src/common/socket.c b/src/common/socket.c index 022a4ae72..11493fef4 100644 --- a/src/common/socket.c +++ b/src/common/socket.c @@ -205,6 +205,10 @@ int naddr_ = 0; // # of ip addresses // initial send buffer size (will be resized as needed) #define WFIFO_SIZE (16*1024) +// Maximum size of pending data in the write fifo. (for non-server connections) +// The connection is closed if it goes over the limit. +#define WFIFO_MAX (1*1024*1024) + struct socket_data* session[FD_SETSIZE]; #ifdef SEND_SHORTLIST @@ -625,12 +629,18 @@ int WFIFOSET(int fd, size_t len) if(s->wdata_size+len > s->max_wdata) { // actually there was a buffer overflow already uint32 ip = s->client_addr; - ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %d bytes on a %d/%d bytes buffer.\n", fd, CONVIP(ip), len, s->wdata_size, s->max_wdata); + ShowFatalError("WFIFOSET: Write Buffer Overflow. Connection %d (%d.%d.%d.%d) has written %u bytes on a %u/%u bytes buffer.\n", fd, CONVIP(ip), (unsigned int)len, (unsigned int)s->wdata_size, (unsigned int)s->max_wdata); ShowDebug("Likely command that caused it: 0x%x\n", (*(unsigned short*)(s->wdata + s->wdata_size))); // no other chance, make a better fifo model exit(EXIT_FAILURE); } + if( !s->flag.server && s->wdata_size+len > WFIFO_MAX ) + {// reached maximum write fifo size + set_eof(fd); + return 0; + } + s->wdata_size += len; //If the interserver has 200% of its normal size full, flush the data. if( s->flag.server && s->wdata_size >= 2*FIFOSIZE_SERVERLINK ) |