X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Fdgram.c;h=99ccdc52c4c5aa82c982ea703891cfbdfb15ceec;hb=d74dc4d908fcbc1a4ef474edaf51e61ec90eab6b;hp=f0e80ec837f0573e55ebe02a59bab189458575dc;hpb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;p=debian%2Famanda diff --git a/common-src/dgram.c b/common-src/dgram.c index f0e80ec..99ccdc5 100644 --- a/common-src/dgram.c +++ b/common-src/dgram.c @@ -61,6 +61,7 @@ dgram_bind( sockaddr_union name; int save_errno; int *portrange; + int sndbufsize = MAX_DGRAM; portrange = getconf_intrange(CNF_RESERVED_UDP_PORT); *portp = (in_port_t)0; @@ -80,6 +81,13 @@ dgram_bind( return -1; } + /* try setting the buffer size (= maximum allowable UDP packet size) */ + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, + (void *) &sndbufsize, sizeof(sndbufsize)) < 0) { + dbprintf("dgram_bind: could not set udp send buffer to %d: %s (ignored)\n", + sndbufsize, strerror(errno)); + } + SU_INIT(&name, family); SU_SET_INADDR_ANY(&name); @@ -159,6 +167,8 @@ dgram_send_addr( s = dgram->socket; socket_opened = 0; } else { + int sndbufsize = MAX_DGRAM; + g_debug("dgram_send_addr: setting up a socket with family %d", SU_GET_FAMILY(addr)); if((s = socket(SU_GET_FAMILY(addr), SOCK_DGRAM, 0)) == -1) { save_errno = errno; @@ -176,6 +186,13 @@ dgram_send_addr( strerror(errno)); } #endif + + /* try setting the buffer size (= maximum allowable UDP packet size) */ + if (setsockopt(s, SOL_SOCKET, SO_SNDBUF, + (void *) &sndbufsize, sizeof(sndbufsize)) < 0) { + dbprintf("dgram_send_addr: could not set udp send buffer to %d: %s (ignored)\n", + sndbufsize, strerror(errno)); + } } if(s < 0 || s >= (int)FD_SETSIZE) {