force bind to correct address

patch by jbellis; reviewed by Ray Slakinski for CASSANDRA-546

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@835711 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-11-13 02:34:31 +00:00
parent 183f51dc21
commit 01a2b07711
1 changed files with 3 additions and 0 deletions

View File

@ -31,6 +31,7 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import org.apache.cassandra.config.DatabaseDescriptor;
import org.apache.cassandra.net.io.FastSerializer;
@ -70,7 +71,9 @@ public class TcpConnection extends SelectionKeyHandler implements Comparable
private TcpConnection(InetAddress from, InetAddress to, TcpConnectionManager pool, boolean streaming) throws IOException
{
logger_.debug("creating connection from " + from + " to " + to);
socketChannel_ = SocketChannel.open();
socketChannel_.socket().bind(new InetSocketAddress(from, 0));
socketChannel_.configureBlocking(false);
localEp_ = from;