Commit 83bf58e2 authored by guus's avatar guus

OF-584: Openfire should not re-use a socket when that has already been closed...

OF-584: Openfire should not re-use a socket when that has already been closed by a previous connection attempt.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@13341 b35dd754-fafc-0310-a699-88a17e54d16e
parent e22dbfce
......@@ -261,14 +261,14 @@ public class LocalOutgoingServerSession extends LocalSession implements Outgoing
}
// Connect to remote server using XMPP 1.0 (TLS + SASL EXTERNAL or TLS + server dialback or server dialback)
SocketConnection connection = null;
String realHostname = null;
int realPort = port;
Socket socket = new Socket();
Socket socket = null;
// Get a list of real hostnames to connect to using DNS lookup of the specified hostname
List<DNSUtil.HostAddress> hosts = DNSUtil.resolveXMPPDomain(hostname, port);
for (Iterator<DNSUtil.HostAddress> it = hosts.iterator(); it.hasNext();) {
try {
socket = new Socket();
DNSUtil.HostAddress address = it.next();
realHostname = address.getHost();
realPort = address.getPort();
......@@ -283,12 +283,21 @@ public class LocalOutgoingServerSession extends LocalSession implements Outgoing
catch (Exception e) {
Log.warn("Error trying to connect to remote server: " + hostname +
"(DNS lookup: " + realHostname + ":" + realPort + ")", e);
try {
if (socket != null) {
socket.close();
}
}
catch (IOException ex) {
Log.debug("Additional exception while trying to close socket when connection to remote server failed.", ex);
}
}
}
if (!socket.isConnected()) {
return null;
}
SocketConnection connection = null;
try {
connection =
new SocketConnection(XMPPServer.getInstance().getPacketDeliverer(), socket,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment