Use watchdog alarms with mailbox syncs
* There are cases in which an HTTP POST can hang indefinitely; this will eventually be caught, but it could be a long time until this happens (I've seen hours) * Set a watchdog alarm for all HTTP POSTs (rather than just PING) Bug: 2492860 Change-Id: Ifccbb54c191c4164bb3188e0291490276bce25fb
This commit is contained in:
parent
136d3b96bb
commit
850e9fdda9
@ -965,7 +965,7 @@ public class EasSyncService extends AbstractSyncService {
|
||||
protected HttpResponse sendHttpClientPost(String cmd, HttpEntity entity, int timeout)
|
||||
throws IOException {
|
||||
HttpClient client = getHttpClient(timeout);
|
||||
boolean sleepAllowed = cmd.equals(PING_COMMAND);
|
||||
boolean isPingCommand = cmd.equals(PING_COMMAND);
|
||||
|
||||
// Split the mail sending commands
|
||||
String extra = null;
|
||||
@ -992,16 +992,21 @@ public class EasSyncService extends AbstractSyncService {
|
||||
method.setEntity(entity);
|
||||
synchronized(getSynchronizer()) {
|
||||
mPendingPost = method;
|
||||
if (sleepAllowed) {
|
||||
SyncManager.runAsleep(mMailboxId, timeout+(10*SECONDS));
|
||||
long alarmTime = timeout+(10*SECONDS);
|
||||
if (isPingCommand) {
|
||||
SyncManager.runAsleep(mMailboxId, alarmTime);
|
||||
} else {
|
||||
SyncManager.setWatchdogAlarm(mMailboxId, alarmTime);
|
||||
}
|
||||
}
|
||||
try {
|
||||
return client.execute(method);
|
||||
} finally {
|
||||
synchronized(getSynchronizer()) {
|
||||
if (sleepAllowed) {
|
||||
if (isPingCommand) {
|
||||
SyncManager.runAwake(mMailboxId);
|
||||
} else {
|
||||
SyncManager.clearWatchdogAlarm(mMailboxId);
|
||||
}
|
||||
mPendingPost = null;
|
||||
}
|
||||
|
@ -1286,6 +1286,20 @@ public class SyncManager extends Service implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
static public void clearWatchdogAlarm(long id) {
|
||||
SyncManager syncManager = INSTANCE;
|
||||
if (syncManager != null) {
|
||||
syncManager.clearAlarm(id);
|
||||
}
|
||||
}
|
||||
|
||||
static public void setWatchdogAlarm(long id, long millis) {
|
||||
SyncManager syncManager = INSTANCE;
|
||||
if (syncManager != null) {
|
||||
syncManager.setAlarm(id, millis);
|
||||
}
|
||||
}
|
||||
|
||||
static public void alert(Context context, long id) {
|
||||
SyncManager syncManager = INSTANCE;
|
||||
checkSyncManagerServiceRunning();
|
||||
|
Loading…
Reference in New Issue
Block a user