diff --git a/src/org/jgroups/blocks/cs/NioServer.java b/src/org/jgroups/blocks/cs/NioServer.java index ef35e31faaa..e81128a1f6d 100644 --- a/src/org/jgroups/blocks/cs/NioServer.java +++ b/src/org/jgroups/blocks/cs/NioServer.java @@ -116,6 +116,8 @@ public synchronized void stop() { // Util.close(selector); // closing the selector also stops the acceptor thread // socket_factory.close(channel); selector.wakeup(); + // Wait for server channel to close (via acceptorDone()) + Util.interruptAndWaitToDie(acceptor); } } diff --git a/src/org/jgroups/protocols/FD_SOCK2.java b/src/org/jgroups/protocols/FD_SOCK2.java index e6bc1a02f87..06ea05f1755 100644 --- a/src/org/jgroups/protocols/FD_SOCK2.java +++ b/src/org/jgroups/protocols/FD_SOCK2.java @@ -450,8 +450,8 @@ public static ByteArray messageToBuffer(Message msg) throws Exception { } protected int[] computeBindPorts(int actual_port) { - int[] bind_ports=new int[port_range]; - for(int i=0; i < port_range; i++) { + int[] bind_ports=new int[port_range+1]; + for(int i=0; i <= port_range; i++) { int port=(actual_port+offset+i) % max_port; if(port < min_port) port=port+min_port;