From 350fb833ac8a5b9cb130b1fa7068d5fcc9ec2683 Mon Sep 17 00:00:00 2001 From: Matteo Campana Date: Tue, 27 Sep 2016 16:54:05 +0200 Subject: [PATCH 1/2] Do not use String.format and construct the string only if logger FINEST is enabled. --- src/main/java/org/ice4j/stack/Connector.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/ice4j/stack/Connector.java b/src/main/java/org/ice4j/stack/Connector.java index faef277..0e68eb3 100644 --- a/src/main/java/org/ice4j/stack/Connector.java +++ b/src/main/java/org/ice4j/stack/Connector.java @@ -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"); From 84ca00a325776193de254f7c73f4d8e374988735 Mon Sep 17 00:00:00 2001 From: Boris Grozev Date: Wed, 5 Oct 2016 11:28:21 +0300 Subject: [PATCH 2/2] feat: Makes the single-port harvester's sockets' receive buffer sizes configurable. --- .../ice/harvest/SinglePortUdpHarvester.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java index 04d5965..c9e7e8a 100644 --- a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java @@ -76,6 +76,14 @@ public class SinglePortUdpHarvester */ 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 + = SinglePortUdpHarvester.class.getName() + ".SO_RCVBUF"; + /** * Creates a new SinglePortUdpHarvester instance for each allowed * IP address found on each allowed network interface, with the given port. @@ -200,9 +208,23 @@ public class SinglePortUdpHarvester throws IOException { this.localAddress = localAddress; - this.socket = new DatagramSocket(localAddress); - logger.info("Initialized SinglePortUdpHarvester with address " - + localAddress); + socket = new DatagramSocket(localAddress); + + + int receiveBufferSize = StackProperties.getInt(SO_RCVBUF_PNAME, -1); + if (receiveBufferSize > 0) + { + socket.setReceiveBufferSize(receiveBufferSize); + } + + String logMessage + = "Initialized SinglePortUdpHarvester with address " + localAddress; + logMessage += ". Receive buffer size " + socket.getReceiveBufferSize(); + if (receiveBufferSize > 0) + { + logMessage += " (asked for " + receiveBufferSize + ")"; + } + logger.info(logMessage); thread = new Thread() {