Add more ping logging to detect odd looping behavior in Moto log

Change-Id: I66f9789cf9ded590ec96b502c2f74f5d0ae5d17d
This commit is contained in:
Marc Blank 2009-09-23 17:49:47 -07:00
parent 5fed934083
commit cf19af4c74

View File

@ -59,6 +59,7 @@ import android.content.ContentValues;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.os.RemoteException; import android.os.RemoteException;
import android.os.SystemClock;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -684,7 +685,7 @@ public class EasSyncService extends AbstractSyncService {
void runPingLoop() throws IOException, StaleFolderListException { void runPingLoop() throws IOException, StaleFolderListException {
int pingHeartbeat = mPingHeartbeat; int pingHeartbeat = mPingHeartbeat;
userLog("runPingLoop");
// Do push for all sync services here // Do push for all sync services here
long endTime = System.currentTimeMillis() + (30*MINUTES); long endTime = System.currentTimeMillis() + (30*MINUTES);
HashMap<String, Integer> pingErrorMap = new HashMap<String, Integer>(); HashMap<String, Integer> pingErrorMap = new HashMap<String, Integer>();
@ -692,6 +693,7 @@ public class EasSyncService extends AbstractSyncService {
int pingWaitCount = 0; int pingWaitCount = 0;
while ((System.currentTimeMillis() < endTime) && !mStop) { while ((System.currentTimeMillis() < endTime) && !mStop) {
userLog("runPingLoop, top of loop, pingWaitCount = " + pingWaitCount);
// Count of pushable mailboxes // Count of pushable mailboxes
int pushCount = 0; int pushCount = 0;
// Count of mailboxes that can be pushed right now // Count of mailboxes that can be pushed right now
@ -756,6 +758,7 @@ public class EasSyncService extends AbstractSyncService {
boolean forcePing = (pingWaitCount > 9); boolean forcePing = (pingWaitCount > 9);
if ((canPushCount > 0) && ((canPushCount == pushCount) || forcePing)) { if ((canPushCount > 0) && ((canPushCount == pushCount) || forcePing)) {
userLog("runPingLoop, about to send ping, setting pingWaitCount = 0");
// If all pingable boxes are ready for push, send Ping to the server // If all pingable boxes are ready for push, send Ping to the server
s.end().end().done(); s.end().end().done();
pingWaitCount = 0; pingWaitCount = 0;
@ -763,6 +766,7 @@ public class EasSyncService extends AbstractSyncService {
// If we've been stopped, this is a good time to return // If we've been stopped, this is a good time to return
if (mStop) return; if (mStop) return;
long pingTime = SystemClock.elapsedRealtime();
try { try {
// Send the ping, wrapped by appropriate timeout/alarm // Send the ping, wrapped by appropriate timeout/alarm
if (forcePing) { if (forcePing) {
@ -826,6 +830,11 @@ public class EasSyncService extends AbstractSyncService {
pingHeartbeat = PING_MIN_HEARTBEAT; pingHeartbeat = PING_MIN_HEARTBEAT;
} }
userLog("Decreased ping heartbeat to ", pingHeartbeat, "s"); userLog("Decreased ping heartbeat to ", pingHeartbeat, "s");
} else if ((SystemClock.elapsedRealtime() - pingTime) < 2000) {
userLog("NAT type IOException < 2 seconds; throwing IOException");
throw e;
} else {
userLog("NAT type IOException > 2 seconds?");
} }
} else { } else {
userLog("IOException detected in runPingLoop: " + userLog("IOException detected in runPingLoop: " +
@ -836,9 +845,10 @@ public class EasSyncService extends AbstractSyncService {
} else if (pushCount > 0) { } else if (pushCount > 0) {
// If we want to Ping, but can't just yet, wait a little bit // If we want to Ping, but can't just yet, wait a little bit
// TODO Change sleep to wait and use notify from SyncManager when a sync ends // TODO Change sleep to wait and use notify from SyncManager when a sync ends
userLog("pingLoop waiting for: ", (pushCount - canPushCount), " box(es)");
sleep(1*SECONDS); sleep(1*SECONDS);
pingWaitCount++; pingWaitCount++;
userLog("pingLoop waited for: ", (pushCount - canPushCount), " box(es), count = "
+ pingWaitCount);
} else if (uninitCount > 0) { } else if (uninitCount > 0) {
// In this case, we're doing an initial sync of at least one mailbox. Since this // In this case, we're doing an initial sync of at least one mailbox. Since this
// is typically a one-time case, I'm ok with trying again every 10 seconds until // is typically a one-time case, I'm ok with trying again every 10 seconds until