]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Make write buffers bigger, but flush early
authorAlexander Barton <alex@barton.de>
Sat, 12 Feb 2011 22:24:56 +0000 (23:24 +0100)
committerAlexander Barton <alex@barton.de>
Sat, 12 Feb 2011 22:24:56 +0000 (23:24 +0100)
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
src/ngircd/defines.h

index e92240b6ff1548732f53e7d09e236b2a42ed23a9..e58e6335a2a2cb298bbcf83703f7b7ccb666ddd2 100644 (file)
@@ -858,7 +858,7 @@ static bool
 Conn_Write( CONN_ID Idx, char *Data, size_t Len )
 {
        CLIENT *c;
 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 );
        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 >=
                /* 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))
                        /* Buffer is full, flush it. Handle_Write deals with
                         * low-level errors, if any. */
                        if (!Handle_Write(Idx))
index 3f1122ca2fcaba6c93f502667a8ea0f5ffc73699..ec7bee9320a566321a9990d9c97cff94db98fc6d 100644 (file)
 
 #define READBUFFER_LEN 2048            /* Size of the read buffer of a
                                           connection in bytes. */
 
 #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. */
                                           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,
                                           server link connection in bytes. */
 
 #define PROTOVER "0210"                        /* Implemented IRC protocol version,