mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-29 15:32:06 +01:00
Fix connection closing notifications on error.
git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2050 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
3c3b3d5cdf
commit
334cfd8c3a
1 changed files with 12 additions and 7 deletions
|
@ -200,14 +200,16 @@ class PacketReader {
|
|||
* Shuts the packet reader down.
|
||||
*/
|
||||
public void shutdown() {
|
||||
done = true;
|
||||
// Notify connection listeners of the connection closing.
|
||||
synchronized (connectionListeners) {
|
||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||
ConnectionListener listener = (ConnectionListener)i.next();
|
||||
listener.connectionClosed();
|
||||
// Notify connection listeners of the connection closing if done hasn't already been set.
|
||||
if (!done) {
|
||||
synchronized (connectionListeners) {
|
||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||
ConnectionListener listener = (ConnectionListener)i.next();
|
||||
listener.connectionClosed();
|
||||
}
|
||||
}
|
||||
}
|
||||
done = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -287,15 +289,18 @@ class PacketReader {
|
|||
}
|
||||
catch (Exception e) {
|
||||
if (!done) {
|
||||
// Set done to true since we want to do our own notification of connection closing.
|
||||
done = true;
|
||||
connection.close();
|
||||
// An exception occurred while parsing. Notify connection listeners of
|
||||
// the error and close the connection.
|
||||
connection.close();
|
||||
synchronized (connectionListeners) {
|
||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||
ConnectionListener listener = (ConnectionListener)i.next();
|
||||
listener.connectionClosedOnError(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue