From 2341e096e681cef60c1d94a6eaea84d962d9f323 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 27 Apr 2010 20:42:39 -0700 Subject: [PATCH] Shutdown all connections when sync service is hung * When a sync thread receives an alarm due to a missed socket timeout on an HttpPost, we try to abort the HttpPost. * At times, however, the HttpPost cannot be aborted and the thread hangs indefinitely. * In this CL, we try to break this vicious cycle by shutting down our ClientConnectionManager when this case is detected. This should, in turn, close all of our socket connections, causing the sync threads to generate IOExceptions and terminate. * After appropriate IOException waits, new sync threads should then be able to run normally. Bug: 2615293 Change-Id: Idea6c3653cd60822d6260e0c5a7dad790ee25858 --- src/com/android/exchange/SyncManager.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/com/android/exchange/SyncManager.java b/src/com/android/exchange/SyncManager.java index 9f528dd8e..e63394fb7 100644 --- a/src/com/android/exchange/SyncManager.java +++ b/src/com/android/exchange/SyncManager.java @@ -1177,6 +1177,11 @@ public class SyncManager extends Service implements Runnable { return sClientConnectionManager; } + static private synchronized void shutdownConnectionManager() { + sClientConnectionManager.shutdown(); + sClientConnectionManager = null; + } + public static void stopAccountSyncs(long acctId) { SyncManager syncManager = INSTANCE; if (syncManager != null) { @@ -1448,6 +1453,9 @@ public class SyncManager extends Service implements Runnable { // thread to do the work log("Alarm failed; releasing mailbox"); syncManager.releaseMailbox(id); + // Shutdown the connection manager; this should close all of our + // sockets and generate IOExceptions all around. + syncManager.shutdownConnectionManager(); } } }}).start();