repo: ngircd
action: commit
revision: 
path_from: 
revision_from: f732c7117e5a4b74b47c4594470506dcb2773760:
path_to: 
revision_to: 
git.thebackupbox.net
ngircd
git clone git://git.thebackupbox.net/ngircd
commit f732c7117e5a4b74b47c4594470506dcb2773760
Author: Alexander Barton 
Date:   Sat Feb 12 23:24:56 2011 +0100

    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).

diff --git a/src/ngircd/conn.c b/src/ngircd/conn.c
index e92240b6ff1548732f53e7d09e236b2a42ed23a9..
index ..e58e6335a2a2cb298bbcf83703f7b7ccb666ddd2 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 3f1122ca2fcaba6c93f502667a8ea0f5ffc73699..
index ..ec7bee9320a566321a9990d9c97cff94db98fc6d 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,

-----END OF PAGE-----