Increased UDP receive buffer to 1MB per socket.
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 29 Dec 2010 12:07:50 +0000 (12:07 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Wed, 29 Dec 2010 12:07:50 +0000 (12:07 +0000)
bin/inputs/udp.py

index aa59b60ff3033059f25438da6a0c0f2367a48b6e..5ca1a12884f593e0962c13f239c34db796c3b478 100644 (file)
@@ -15,6 +15,7 @@ from ais.inputs.virtual import Channel, Service
 from ais.inputs.config import source_get_infoin
 
 UDP_HEADER_SIZE = 28
+UDP_RCVBUF = 1024*1024
 
 
 class UdpChannel(Channel):
@@ -45,7 +46,10 @@ class UdpService(Service):
         self.serverport = serverport
         self.sock = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM)
         #http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560238 :
-        self.sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0);
+        self.sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0)
+        self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, UDP_RCVBUF)
+        socksize = self.sock.getsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF)
+        logging.info('Socket buffer size is %s bytes', socksize)
         self.sock.bind(('', serverport))
         self.channels = {} # channelid is (addr,port) or (addr,None)
         logging.info('Listening on UDP port %s.', serverport)