2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

1899. [func] Raise the UDP recieve buffer size to 32k if it is

less than 32k. [RT #14953]
This commit is contained in:
Mark Andrews
2005-07-12 00:41:55 +00:00
parent ea8cec4518
commit 0563d476de
3 changed files with 62 additions and 6 deletions

View 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;