diff options
author | Benoit Foucher <benoit@zeroc.com> | 2008-04-16 15:13:08 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2008-04-16 15:13:08 +0200 |
commit | e2192db01a917ff5322a2e76b4c8b097482a18c2 (patch) | |
tree | dd918e2d20e4db9fcbba69318e10a23485d7ea80 /java/src/IceInternal/Network.java | |
parent | bug 3008 - IceSSL cleanup (diff) | |
download | ice-e2192db01a917ff5322a2e76b4c8b097482a18c2.tar.bz2 ice-e2192db01a917ff5322a2e76b4c8b097482a18c2.tar.xz ice-e2192db01a917ff5322a2e76b4c8b097482a18c2.zip |
Fixed for bug 3007
Diffstat (limited to 'java/src/IceInternal/Network.java')
-rw-r--r-- | java/src/IceInternal/Network.java | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/java/src/IceInternal/Network.java b/java/src/IceInternal/Network.java index e181b51a714..36cad790163 100644 --- a/java/src/IceInternal/Network.java +++ b/java/src/IceInternal/Network.java @@ -357,10 +357,18 @@ public final class Network throw se; } - if(addr.equals(fd.socket().getLocalSocketAddress())) + if(System.getProperty("os.name").equals("Linux")) { - closeSocketNoThrow(fd); - throw new Ice.ConnectionRefusedException(); + // + // Prevent self connect (self connect happens on Linux when a client tries to connect to + // a server which was just deactivated if the client socket re-uses the same ephemeral + // port as the server). + // + if(addr.equals(fd.socket().getLocalSocketAddress())) + { + closeSocketNoThrow(fd); + throw new Ice.ConnectionRefusedException(); + } } return true; } @@ -379,16 +387,19 @@ public final class Network { throw new Ice.ConnectFailedException(); } - - // - // Prevent self connect (self connect happens on Linux when a client tries to connect to - // a server which was just deactivated if the client socket re-uses the same ephemeral - // port as the server). - // - java.net.SocketAddress addr = fd.socket().getRemoteSocketAddress(); - if(addr != null && addr.equals(fd.socket().getLocalSocketAddress())) + + if(System.getProperty("os.name").equals("Linux")) { - throw new Ice.ConnectionRefusedException(); + // + // Prevent self connect (self connect happens on Linux when a client tries to connect to + // a server which was just deactivated if the client socket re-uses the same ephemeral + // port as the server). + // + java.net.SocketAddress addr = fd.socket().getRemoteSocketAddress(); + if(addr != null && addr.equals(fd.socket().getLocalSocketAddress())) + { + throw new Ice.ConnectionRefusedException(); + } } } catch(java.net.ConnectException ex) |