Merge branch 'master' into refactor

This commit is contained in:
Boris Grozev 2016-10-12 18:20:06 +03:00
commit b5d3bb2ddc
2 changed files with 28 additions and 3 deletions

View File

@ -67,6 +67,14 @@ public abstract class AbstractUdpListener
*/
private static final int POOL_SIZE = 256;
/**
* The name of the property which controls the size of the receive buffer
* which {@link SinglePortUdpHarvester} will request for the sockets that
* it creates.
*/
private static final String SO_RCVBUF_PNAME
= AbstractUdpListener.class.getName() + ".SO_RCVBUF";
/**
* Returns the list of {@link TransportAddress}es, one for each allowed IP
* address found on each allowed network interface, with the given port.
@ -240,7 +248,22 @@ public abstract class AbstractUdpListener
throws IOException
{
this.localAddress = localAddress;
this.socket = new DatagramSocket(localAddress);
socket = new DatagramSocket(localAddress);
int receiveBufferSize = StackProperties.getInt(SO_RCVBUF_PNAME, -1);
if (receiveBufferSize > 0)
{
socket.setReceiveBufferSize(receiveBufferSize);
}
String logMessage
= "Initialized AbstractUdpListener with address " + localAddress;
logMessage += ". Receive buffer size " + socket.getReceiveBufferSize();
if (receiveBufferSize > 0)
{
logMessage += " (asked for " + receiveBufferSize + ")";
}
logger.info(logMessage);
thread = new Thread()
{

View File

@ -209,8 +209,10 @@ class Connector
if(!running)
return;
logger.finest(String.format("received datagram packet - addr: %s port: %d",
packet.getAddress(), packet.getPort()));
if (logger.isLoggable(Level.FINEST)){
logger.finest("received datagram packet - addr: "
+ packet.getAddress() + " port: " + packet.getPort());
}
if (packet.getPort() < 0)
{
logger.warning("Out of range packet port, resetting to 0");