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
This commit is contained in:
Marc Blank 2010-04-27 20:42:39 -07:00
parent 4713110b02
commit 2341e096e6
1 changed files with 8 additions and 0 deletions

View File

@ -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();