mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-22 22:32:06 +01:00
Cleaned up connection close operation.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@1829 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
668ab89ece
commit
5a1f449f03
3 changed files with 13 additions and 5 deletions
|
@ -263,10 +263,10 @@ class PacketReader {
|
||||||
} while (eventType != parser.END_DOCUMENT && !done);
|
} while (eventType != parser.END_DOCUMENT && !done);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
if (!done) {
|
||||||
// An exception occurred while parsing. Print the error an close the
|
// An exception occurred while parsing. Print the error an close the
|
||||||
// connection.
|
// connection.
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (!done) {
|
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,6 +148,7 @@ class PacketWriter {
|
||||||
// stream.append("xmlns:sasl=\"http://www.iana.org/assignments/sasl-mechanisms\" ");
|
// stream.append("xmlns:sasl=\"http://www.iana.org/assignments/sasl-mechanisms\" ");
|
||||||
writer.write(stream.toString());
|
writer.write(stream.toString());
|
||||||
writer.flush();
|
writer.flush();
|
||||||
|
stream = null;
|
||||||
// Write out packets from the queue.
|
// Write out packets from the queue.
|
||||||
while (!done) {
|
while (!done) {
|
||||||
Packet packet = nextPacket();
|
Packet packet = nextPacket();
|
||||||
|
@ -168,10 +169,12 @@ class PacketWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (IOException ioe){
|
catch (IOException ioe){
|
||||||
|
if (!done) {
|
||||||
ioe.printStackTrace();
|
ioe.printStackTrace();
|
||||||
connection.close();
|
connection.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -323,6 +323,11 @@ public class XMPPConnection {
|
||||||
packetWriter.sendPacket(new Presence(Presence.Type.UNAVAILABLE));
|
packetWriter.sendPacket(new Presence(Presence.Type.UNAVAILABLE));
|
||||||
packetWriter.shutdown();
|
packetWriter.shutdown();
|
||||||
packetReader.shutdown();
|
packetReader.shutdown();
|
||||||
|
// Wait 100 ms for processes to clean-up, then shutdown.
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
catch (Exception e) { }
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue