mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-15 16:52:07 +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.
|
* Shuts the packet reader down.
|
||||||
*/
|
*/
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
done = true;
|
// Notify connection listeners of the connection closing if done hasn't already been set.
|
||||||
// Notify connection listeners of the connection closing.
|
if (!done) {
|
||||||
synchronized (connectionListeners) {
|
synchronized (connectionListeners) {
|
||||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||||
ConnectionListener listener = (ConnectionListener)i.next();
|
ConnectionListener listener = (ConnectionListener)i.next();
|
||||||
listener.connectionClosed();
|
listener.connectionClosed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
done = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -287,15 +289,18 @@ class PacketReader {
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
if (!done) {
|
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
|
// An exception occurred while parsing. Notify connection listeners of
|
||||||
// the error and close the connection.
|
// the error and close the connection.
|
||||||
connection.close();
|
|
||||||
synchronized (connectionListeners) {
|
synchronized (connectionListeners) {
|
||||||
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
for (Iterator i=connectionListeners.iterator(); i.hasNext(); ) {
|
||||||
ConnectionListener listener = (ConnectionListener)i.next();
|
ConnectionListener listener = (ConnectionListener)i.next();
|
||||||
listener.connectionClosedOnError(e);
|
listener.connectionClosedOnError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue