1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 09:39:39 +02:00

SMACK-278: Call socket.close() in XMPPConnection.shutdown() before

closing the reader and writer streams. This basically prevents the
deadlock reported in SMACK-278.

Additionally, we need to tell the PacketReader and PacketWriter that
the socket got closed and that subsequent caused Exceptions can be
ignored. This is done via the socketClosed boolean in XMPP Connection,
that is queried by PacketReader and PacketWriter in case an Exception
is encountered.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13390 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Florian Schmaus 2013-01-06 14:02:44 +00:00 committed by flow
parent 3c2eaba840
commit e1bb5a6123
3 changed files with 57 additions and 10 deletions

View file

@ -149,6 +149,9 @@ class PacketWriter {
synchronized (queue) {
queue.notifyAll();
}
// Interrupt the keep alive thread if one was created
if (keepAliveThread != null)
keepAliveThread.interrupt();
}
/**
@ -232,10 +235,16 @@ class PacketWriter {
}
}
}
catch (IOException ioe){
if (!done) {
catch (IOException ioe) {
// The exception can be ignored if the the connection is 'done'
// or if the it was caused because the socket got closed
if (!(done || connection.isSocketClosed())) {
done = true;
connection.packetReader.notifyConnectionError(ioe);
// packetReader could be set to null by an concurrent disconnect() call.
// Therefore Prevent NPE exceptions by checking packetReader.
if (connection.packetReader != null) {
connection.packetReader.notifyConnectionError(ioe);
}
}
}
}
@ -307,4 +316,4 @@ class PacketWriter {
}
}
}
}
}