]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
1899. [func] Raise the UDP recieve buffer size to 32k if it is
authorMark Andrews <marka@isc.org>
Tue, 12 Jul 2005 00:41:55 +0000 (00:41 +0000)
committerMark Andrews <marka@isc.org>
Tue, 12 Jul 2005 00:41:55 +0000 (00:41 +0000)
                        less than 32k. [RT #14953]

CHANGES
lib/isc/unix/socket.c
lib/isc/win32/socket.c

diff --git a/CHANGES b/CHANGES
index 3d1983b762bd5a270a202b3e21107ec63d1c1a4a..7b005257edccdd8338e63672570070063b827e55 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+1899.  [func]          Raise the UDP recieve buffer size to 32k if it is
+                       less than 32k. [RT #14953]
+
 1898.  [port]          sunos: non blocking i/o support. [RT #14951]
 
 1897.  [func]          Support for IPSECKEY rdata type. [RT #14967]
index 26e34b9cd5b8165431d27d6924aeef467fc25409..fbed68406c6b8f0e16181066069d0ef8c088a93c 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.251 2005/07/08 04:30:22 marka Exp $ */
+/* $Id: socket.c,v 1.252 2005/07/12 00:41:54 marka Exp $ */
 
 /*! \file */
 
@@ -132,6 +132,11 @@ typedef isc_event_t intev_t;
 #endif
 #endif
 
+/*%
+ * The size to raise the recieve buffer to (from BIND 8).
+ */
+#define RCVBUFSIZE (32*1024)
+
 /*%
  * The number of times a send operation is repeated if the result is EINTR.
  */
@@ -1365,6 +1370,10 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
        isc_result_t ret;
 #if defined(USE_CMSG) || defined(SO_BSDCOMPAT)
        int on = 1;
+#endif
+#if defined(SO_RCVBUF)
+       ISC_SOCKADDR_LEN_T optlen;
+       int size;
 #endif
        char strbuf[ISC_STRERRORSIZE];
        const char *err = "socket";
@@ -1468,9 +1477,10 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
        }
 #endif
 
-#if defined(USE_CMSG)
+#if defined(USE_CMSG) || defined(SO_RCVBUF)
        if (type == isc_sockettype_udp) {
 
+#if defined(USE_CMSG)
 #if defined(SO_TIMESTAMP)
                if (setsockopt(sock->fd, SOL_SOCKET, SO_TIMESTAMP,
                               (void *)&on, sizeof(on)) < 0
@@ -1540,9 +1550,30 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                }
 #endif
 #endif /* ISC_PLATFORM_HAVEIPV6 */
-
+#endif /* defined(USE_CMSG) */
+
+#if defined(SO_RCVBUF)
+               optlen = sizeof(size);
+               if (getsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF,
+                              (void *)&size, &optlen) >= 0 &&
+                    size < RCVBUFSIZE) {
+                       size = RCVBUFSIZE;
+                       if (setsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF,
+                                      (void *)&size, sizeof(size)) == -1) {
+                               isc__strerror(errno, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                       "setsockopt(%d, SO_RCVBUF, %d) %s: %s",
+                                       sock->fd, size,
+                                       isc_msgcat_get(isc_msgcat,
+                                                      ISC_MSGSET_GENERAL,
+                                                      ISC_MSG_FAILED,
+                                                      "failed"),
+                                       strbuf);
+                       }
+               }
+#endif
        }
-#endif /* USE_CMSG */
+#endif /* defined(USE_CMSG) || defined(SO_RCVBUF) */
 
        sock->references = 1;
        *socketp = sock;
index 65766cca6fe90fb6cebe993a51e43ad2d88fe6c6..96f65e0e167cf4d3ca135367466dabd43444e378 100644 (file)
@@ -15,7 +15,7 @@
  * PERFORMANCE OF THIS SOFTWARE.
  */
 
-/* $Id: socket.c,v 1.38 2005/06/08 01:04:30 marka Exp $ */
+/* $Id: socket.c,v 1.39 2005/07/12 00:41:55 marka Exp $ */
 
 /* This code has been rewritten to take advantage of Windows Sockets
  * I/O Completion Ports and Events. I/O Completion Ports is ONLY
@@ -191,6 +191,11 @@ struct msghdr {
         int     msg_flags;              /* flags on received message */
 } msghdr;
        
+/*%
+ * The size to raise the recieve buffer to.
+ */
+#define RCVBUFSIZE (32*1024)
+
 /*
  * The number of times a send operation is repeated if the result is EINTR.
  */
@@ -1833,6 +1838,10 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
        isc_result_t result;
 #if defined(USE_CMSG) || defined(SO_BSDCOMPAT)
        int on = 1;
+#endif
+#if defined(SO_RCVBUF)
+       ISC_SOCKADDR_LEN_T optlen;
+       int size;
 #endif
        int socket_errno;
        char strbuf[ISC_STRERRORSIZE];
@@ -1896,9 +1905,10 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
        }
 
 
-#if defined(USE_CMSG)
+#if defined(USE_CMSG) || defined(SO_RCVBUF)
        if (type == isc_sockettype_udp) {
 
+#if defined(USE_CMSG)
 #if defined(ISC_PLATFORM_HAVEIPV6)
 #ifdef IPV6_RECVPKTINFO
                /* 2292bis */
@@ -1940,9 +1950,21 @@ isc_socket_create(isc_socketmgr_t *manager, int pf, isc_sockettype_t type,
                }
 #endif
 #endif /* ISC_PLATFORM_HAVEIPV6 */
+#endif /* definef(USE_CMSG) */
+
+#if defined(SO_RCVBUF)
+              optlen = sizeof(size);
+              if (getsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF,
+                             (void *)&size, &optlen) >= 0 &&
+                   size < RCVBUFSIZE) {
+                      size = RCVBUFSIZE;
+                      (void)setsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF,
+                                       (void *)&size, sizeof(size));
+              }
+#endif
 
        }
-#endif /* USE_CMSG */
+#endif /* defined(USE_CMSG) || defined(SO_RCVBUF) */
 
        sock->references = 1;
        *socketp = sock;