Dispose of IRCConnections properly to avoid leaking IRCService objects

Each IRCConnection starts an input thread and an output thread when
created; if not stopped, these threads continue to hold the IRCService,
resulting in a leak when the service is stopped.  Fix this by using
PircBot's dispose() to stop the threads when disposing of the
IRCConnection.
This commit is contained in:
Steven Luo 2011-05-29 17:47:24 -07:00 committed by Sebastian Kaspari
parent ffe73b7c9f
commit ae1b574997
1 changed files with 8 additions and 1 deletions

View File

@ -372,7 +372,14 @@ public class IRCService extends Service
for (int i = 0; i < mSize; i++) {
server = mServers.get(i);
if (server.isDisconnected()) {
connections.remove(server.getId());
int serverId = server.getId();
synchronized(this) {
IRCConnection connection = connections.get(serverId);
if (connection != null) {
connection.dispose();
}
connections.remove(serverId);
}
} else {
shutDown = false;
}