Fix problem with timeouts and sending attachments (#2178288)
* Standard Exchange command timeouts are 20 seconds * For sending, however, these need to be significantly longer to handle the case of sending large attachments, as sending (of any length) happens in a single HTTP Post command * Having an infinite timeout leads to the (small) possibility of the Outbox hanging for a long time, holding up the sending of other mail, so we set a long, but not infinite timeout for this case * Timeout now set for 15 minutes * Prevent sync of Outbox and Drafts (the UI triggers these by changing the contents of these boxes, but we need to ignore the pings that are generated this way) Change-Id: I5b830d6b4e94525d95138b2112be12898a37882e
This commit is contained in:
parent
b634dbf618
commit
4b59cfc8ed
@ -52,6 +52,12 @@ public class EasOutboxService extends EasSyncService {
|
||||
new String[] {BodyColumns.SOURCE_MESSAGE_KEY};
|
||||
public static final String WHERE_MESSAGE_KEY = Body.MESSAGE_KEY + "=?";
|
||||
|
||||
// This needs to be long enough to send the longest reasonable message, without being so long
|
||||
// as to effectively "hang" sending of mail. The standard 30 second timeout isn't long enough
|
||||
// for pictures and the like. For now, we'll use 15 minutes, in the knowledge that any socket
|
||||
// failure would probably generate an Exception before timing out anyway
|
||||
public static final int SEND_MAIL_TIMEOUT = 15*MINUTES;
|
||||
|
||||
public EasOutboxService(Context _context, Mailbox _mailbox) {
|
||||
super(_context, _mailbox);
|
||||
}
|
||||
@ -129,7 +135,7 @@ public class EasOutboxService extends EasSyncService {
|
||||
cmd += "&ItemId=" + itemId + "&CollectionId=" + collectionId + "&SaveInSent=T";
|
||||
}
|
||||
userLog("Send cmd: " + cmd);
|
||||
HttpResponse resp = sendHttpClientPost(cmd, inputEntity);
|
||||
HttpResponse resp = sendHttpClientPost(cmd, inputEntity, SEND_MAIL_TIMEOUT);
|
||||
|
||||
inputStream.close();
|
||||
int code = resp.getStatusLine().getStatusCode();
|
||||
@ -167,7 +173,6 @@ public class EasOutboxService extends EasSyncService {
|
||||
@Override
|
||||
public void run() {
|
||||
setupService();
|
||||
|
||||
File cacheDir = mContext.getCacheDir();
|
||||
try {
|
||||
mDeviceId = SyncManager.getDeviceId();
|
||||
|
@ -111,7 +111,6 @@ public class EasSyncService extends AbstractSyncService {
|
||||
static private final int PING_HEARTBEAT_INCREMENT = 3*PING_MINUTES;
|
||||
static private final int PING_FORCE_HEARTBEAT = 2*PING_MINUTES;
|
||||
|
||||
static private final int PROTOCOL_PING_STATUS_UNAVAILABLE = -1;
|
||||
static private final int PROTOCOL_PING_STATUS_COMPLETED = 1;
|
||||
|
||||
// Fallbacks (in minutes) for ping loop failures
|
||||
|
@ -292,6 +292,11 @@ public class SyncManager extends Service implements Runnable {
|
||||
cv, WHERE_MAILBOX_KEY, new String[] {Long.toString(mailboxId)});
|
||||
|
||||
kick("start outbox");
|
||||
// Outbox can't be synced in EAS
|
||||
return;
|
||||
} else if (m.mType == Mailbox.TYPE_DRAFTS) {
|
||||
// Drafts can't be synced in EAS
|
||||
return;
|
||||
}
|
||||
startManualSync(mailboxId, SyncManager.SYNC_SERVICE_START_SYNC, null);
|
||||
}
|
||||
@ -1139,6 +1144,11 @@ public class SyncManager extends Service implements Runnable {
|
||||
if (service != null) {
|
||||
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, id);
|
||||
if (m != null) {
|
||||
// We ignore drafts completely (doesn't sync). Changes in Outbox are handled
|
||||
// in the checkMailboxes loop, so we can ignore these pings.
|
||||
if (m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) {
|
||||
return;
|
||||
}
|
||||
service.mAccount = Account.restoreAccountWithId(INSTANCE, m.mAccountKey);
|
||||
service.mMailbox = m;
|
||||
service.ping();
|
||||
@ -1623,6 +1633,12 @@ public class SyncManager extends Service implements Runnable {
|
||||
|
||||
static public void serviceRequest(long mailboxId, long ms, int reason) {
|
||||
if (INSTANCE == null) return;
|
||||
Mailbox m = Mailbox.restoreMailboxWithId(INSTANCE, mailboxId);
|
||||
// Never allow manual start of Drafts or Outbox via serviceRequest
|
||||
if (m == null || m.mType == Mailbox.TYPE_DRAFTS || m.mType == Mailbox.TYPE_OUTBOX) {
|
||||
INSTANCE.log("Ignoring serviceRequest for drafts/outbox");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
AbstractSyncService service = INSTANCE.mServiceMap.get(mailboxId);
|
||||
if (service != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user