From 20d84c0e94cbed9eeea71f855860c7846072f360 Mon Sep 17 00:00:00 2001 From: Kenny Root Date: Tue, 16 Jun 2009 01:45:34 +0000 Subject: Avoid concurrent modification of bridges list when TerminalManager service is destroyed while still connected to hosts git-svn-id: https://connectbot.googlecode.com/svn/trunk/connectbot@305 df292f66-193f-0410-a5fc-6d59da041ff2 --- src/org/connectbot/service/TerminalManager.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/org/connectbot/service/TerminalManager.java b/src/org/connectbot/service/TerminalManager.java index f7483dd..9b5f6a4 100644 --- a/src/org/connectbot/service/TerminalManager.java +++ b/src/org/connectbot/service/TerminalManager.java @@ -162,9 +162,13 @@ public class TerminalManager extends Service implements BridgeDisconnectedListen public void onDestroy() { Log.i(TAG, "Destroying background service"); - // disconnect and dispose of any existing bridges - for(TerminalBridge bridge : bridges) - bridge.dispatchDisconnect(true); + if (bridges.size() > 0) { + TerminalBridge[] tmpBridges = bridges.toArray(new TerminalBridge[bridges.size()]); + + // disconnect and dispose of any existing bridges + for (int i = 0; i < tmpBridges.length; i++) + tmpBridges[i].dispatchDisconnect(true); + } if(hostdb != null) { hostdb.close(); -- cgit v1.2.3