Make write buffers bigger, but flush early

This patch
 - makes the server write buffer bigger: 64k,
 - makes the regular write buffer bigger: 32k,
 - tries to flush the write buffer starting at 4K.

Before this patch, a client got disconnected if the buffer flushing at 4k
failed, now regular clients can store up to 32k and servers up 64k even
if flushing is not possible at the moment (e.g. on slow links).
This commit is contained in:
Alexander Barton 2011-02-12 23:24:56 +01:00
parent 477224be5c
commit f732c7117e
2 changed files with 7 additions and 4 deletions

View File

@ -858,7 +858,7 @@ static bool
Conn_Write( CONN_ID Idx, char *Data, size_t Len )
{
CLIENT *c;
size_t writebuf_limit = WRITEBUFFER_LEN;
size_t writebuf_limit = WRITEBUFFER_MAX_LEN;
assert( Idx > NONE );
assert( Data != NULL );
assert( Len > 0 );
@ -894,7 +894,7 @@ Conn_Write( CONN_ID Idx, char *Data, size_t Len )
/* Uncompressed link:
* Check if outbound buffer has enough space for the data. */
if (array_bytes(&My_Connections[Idx].wbuf) + Len >=
writebuf_limit) {
WRITEBUFFER_FLUSH_LEN) {
/* Buffer is full, flush it. Handle_Write deals with
* low-level errors, if any. */
if (!Handle_Write(Idx))

View File

@ -59,9 +59,12 @@
#define READBUFFER_LEN 2048 /* Size of the read buffer of a
connection in bytes. */
#define WRITEBUFFER_LEN 4096 /* Size of the write buffer of a
#define WRITEBUFFER_FLUSH_LEN 4096 /* Size of a write buffer that triggers
buffer flushing if more space is
needed for storing data. */
#define WRITEBUFFER_MAX_LEN 32768 /* Maximum size of the write buffer of a
connection in bytes. */
#define WRITEBUFFER_SLINK_LEN 51200 /* Size of the write buffer of a
#define WRITEBUFFER_SLINK_LEN 65536 /* Maximum size of the write buffer of a
server link connection in bytes. */
#define PROTOVER "0210" /* Implemented IRC protocol version,