From f732c7117e5a4b74b47c4594470506dcb2773760 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Sat, 12 Feb 2011 23:24:56 +0100 Subject: [PATCH] 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). --- src/ngircd/conn.c | 4 ++-- src/ngircd/defines.h | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c index e92240b6..e58e6335 100644 --- a/src/ngircd/conn.c +++ b/src/ngircd/conn.c @@ -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)) diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h index 3f1122ca..ec7bee93 100644 --- a/src/ngircd/defines.h +++ b/src/ngircd/defines.h @@ -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, -- 2.40.0