Commit 80923c8a authored by Gaston Dombiak's avatar Gaston Dombiak Committed by gaston

Fixed sending of error packets to sender when sender belongs to a remote server.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1459 b35dd754-fafc-0310-a699-88a17e54d16e
parent 8dd8a477
...@@ -190,12 +190,23 @@ public class IQRouter extends BasicModule { ...@@ -190,12 +190,23 @@ public class IQRouter extends BasicModule {
reply.setChildElement(packet.getChildElement().createCopy()); reply.setChildElement(packet.getChildElement().createCopy());
reply.setError(PacketError.Condition.service_unavailable); reply.setError(PacketError.Condition.service_unavailable);
} }
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) { try {
session.process(reply); // Locate a route to the sender of the IQ and ask it to process
// the packet. Use the routingTable so that routes to remote servers
// may be found
routingTable.getRoute(packet.getFrom()).process(packet);
} }
else { catch (NoSuchRouteException e) {
Log.warn("Packet could not be delivered " + packet); // No root was found so try looking for local sessions that have never
// sent an available presence or haven't authenticated yet
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
session.process(reply);
}
else {
Log.warn("Packet could not be delivered " + packet);
}
} }
} }
else { else {
...@@ -233,12 +244,25 @@ public class IQRouter extends BasicModule { ...@@ -233,12 +244,25 @@ public class IQRouter extends BasicModule {
// If a route to the target address was not found then try to answer a // If a route to the target address was not found then try to answer a
// service_unavailable error code to the sender of the IQ packet // service_unavailable error code to the sender of the IQ packet
if (!handlerFound) { if (!handlerFound) {
Session session = sessionManager.getSession(packet.getFrom()); IQ reply = IQ.createResultIQ(packet);
if (session != null) { reply.setChildElement(packet.getChildElement().createCopy());
IQ reply = IQ.createResultIQ(packet); reply.setError(PacketError.Condition.service_unavailable);
reply.setChildElement(packet.getChildElement().createCopy()); try {
reply.setError(PacketError.Condition.service_unavailable); // Locate a route to the sender of the IQ and ask it to process
session.process(reply); // the packet. Use the routingTable so that routes to remote servers
// may be found
routingTable.getRoute(packet.getFrom()).process(reply);
}
catch (NoSuchRouteException e) {
// No root was found so try looking for local sessions that have never
// sent an available presence or haven't authenticated yet
Session session = sessionManager.getSession(packet.getFrom());
if (session != null) {
session.process(reply);
}
else {
Log.warn("Packet could not be delivered " + reply);
}
} }
} }
} }
......
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