]> arthur.barton.de Git - ngircd-alex.git/commitdiff
Revert "Increase read buffer size for server connections"
authorAlexander Barton <alex@barton.de>
Fri, 1 May 2020 20:38:41 +0000 (22:38 +0200)
committerAlexander Barton <alex@barton.de>
Sun, 3 May 2020 22:46:56 +0000 (00:46 +0200)
This reverts commit c6e3c13f27744971fcb1d2de4e561d3bcdaa5aed.

This sounded like the right approach at first, but I'm not that sure
that it really makes sense to have different sizes of read buffers: the
per-connection read buffer only needs to keep data that is needed to
parse one full command, be it plain text, encrypted and/or compressed.
Then ngIRCd should handle this one command, move leftover data to the
beginning of the buffer and read the next chunk from the network that is
missing to get the next complete command (512 bytes at max).

So I revert this for now and try to fix the logic in Read_Request(),
which is broken nevertheless, as it results in servers becoming
disconnected during "server burst" when "big" lists are transferred.

src/ngircd/conn.c
src/ngircd/defines.h

index ef0f95fa73e8912d8e349d7c0ba71c5bd81c836d..92d9939ab291445e53806b75609dfaa8209915ad 100644 (file)
@@ -1546,46 +1546,34 @@ static void
 Read_Request( CONN_ID Idx )
 {
        ssize_t len;
 Read_Request( CONN_ID Idx )
 {
        ssize_t len;
-       size_t readbuf_limit = READBUFFER_LEN;
        static const unsigned int maxbps = COMMAND_LEN / 2;
        static const unsigned int maxbps = COMMAND_LEN / 2;
-       char readbuf[READBUFFER_MAX_LEN];
+       char readbuf[READBUFFER_LEN];
        time_t t;
        CLIENT *c;
        assert( Idx > NONE );
        assert( My_Connections[Idx].sock > NONE );
 
        time_t t;
        CLIENT *c;
        assert( Idx > NONE );
        assert( My_Connections[Idx].sock > NONE );
 
-       /* Make sure that there still exists a CLIENT structure associated
-        * with this connection and check if this is a server or not: */
-       c = Conn_GetClient(Idx);
-       if (c) {
-               /* Servers do get special read buffer limits, so they can
-                * process all the messages that are required while peering. */
-               if (Client_Type(c) == CLIENT_SERVER)
-                       readbuf_limit = READBUFFER_SLINK_LEN;
-       } else
-               LogDebug("Read request without client (connection %d)!?", Idx);
-
 #ifdef ZLIB
 #ifdef ZLIB
-       if ((array_bytes(&My_Connections[Idx].rbuf) >= readbuf_limit) ||
-               (array_bytes(&My_Connections[Idx].zip.rbuf) >= readbuf_limit))
+       if ((array_bytes(&My_Connections[Idx].rbuf) >= READBUFFER_LEN) ||
+               (array_bytes(&My_Connections[Idx].zip.rbuf) >= READBUFFER_LEN))
 #else
 #else
-       if (array_bytes(&My_Connections[Idx].rbuf) >= readbuf_limit)
+       if (array_bytes(&My_Connections[Idx].rbuf) >= READBUFFER_LEN)
 #endif
        {
                /* Read buffer is full */
                Log(LOG_ERR,
                    "Receive buffer space exhausted (connection %d): %d/%d bytes",
 #endif
        {
                /* Read buffer is full */
                Log(LOG_ERR,
                    "Receive buffer space exhausted (connection %d): %d/%d bytes",
-                   Idx, array_bytes(&My_Connections[Idx].rbuf), readbuf_limit);
+                   Idx, array_bytes(&My_Connections[Idx].rbuf), READBUFFER_LEN);
                Conn_Close(Idx, "Receive buffer space exhausted", NULL, false);
                return;
        }
 
 #ifdef SSL_SUPPORT
        if (Conn_OPTION_ISSET(&My_Connections[Idx], CONN_SSL))
                Conn_Close(Idx, "Receive buffer space exhausted", NULL, false);
                return;
        }
 
 #ifdef SSL_SUPPORT
        if (Conn_OPTION_ISSET(&My_Connections[Idx], CONN_SSL))
-               len = ConnSSL_Read( &My_Connections[Idx], readbuf, readbuf_limit);
+               len = ConnSSL_Read( &My_Connections[Idx], readbuf, sizeof(readbuf));
        else
 #endif
        else
 #endif
-       len = read(My_Connections[Idx].sock, readbuf, readbuf_limit);
+       len = read(My_Connections[Idx].sock, readbuf, sizeof(readbuf));
        if (len == 0) {
                LogDebug("Client \"%s:%u\" is closing connection %d ...",
                         My_Connections[Idx].host,
        if (len == 0) {
                LogDebug("Client \"%s:%u\" is closing connection %d ...",
                         My_Connections[Idx].host,
index 7ce30e572862f8cd04fb05ced54ec4d072e53e47..ff8cd226d641b0dced4b398438b74c14f2df983a 100644 (file)
 /** 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 READBUFFER_LEN 2048
 
-/** Maximum size of the read buffer of a connection in bytes. */
-#define READBUFFER_MAX_LEN 65535
-
-/** Maximum size of the read buffer of a server link connection in bytes. */
-#define READBUFFER_SLINK_LEN 65536
-
 /** Size that triggers write buffer flushing if more space is needed. */
 #define WRITEBUFFER_FLUSH_LEN 4096
 
 /** Size that triggers write buffer flushing if more space is needed. */
 #define WRITEBUFFER_FLUSH_LEN 4096
 
 #define WRITEBUFFER_MAX_LEN 32768
 
 /** Maximum size of the write buffer of a server link connection in bytes. */
 #define WRITEBUFFER_MAX_LEN 32768
 
 /** Maximum size of the write buffer of a server link connection in bytes. */
-#define WRITEBUFFER_SLINK_LEN READBUFFER_SLINK_LEN
+#define WRITEBUFFER_SLINK_LEN 65536
 
 
 /* IRC/IRC+ protocol */
 
 
 /* IRC/IRC+ protocol */