removed some unecessary locking

This commit is contained in:
Daniel Gultsch 2016-11-19 13:34:27 +01:00
parent 8132480b82
commit 40c747660d

View File

@ -67,7 +67,6 @@ import eu.siacs.conversations.crypto.PgpEngine;
import eu.siacs.conversations.crypto.axolotl.AxolotlService; import eu.siacs.conversations.crypto.axolotl.AxolotlService;
import eu.siacs.conversations.crypto.axolotl.FingerprintStatus; import eu.siacs.conversations.crypto.axolotl.FingerprintStatus;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage; import eu.siacs.conversations.crypto.axolotl.XmppAxolotlMessage;
import eu.siacs.conversations.crypto.axolotl.XmppAxolotlSession;
import eu.siacs.conversations.entities.Account; import eu.siacs.conversations.entities.Account;
import eu.siacs.conversations.entities.Blockable; import eu.siacs.conversations.entities.Blockable;
import eu.siacs.conversations.entities.Bookmark; import eu.siacs.conversations.entities.Bookmark;
@ -298,7 +297,7 @@ public class XmppConnectionService extends Service {
mOnAccountUpdate.onAccountUpdate(); mOnAccountUpdate.onAccountUpdate();
} }
if (account.getStatus() == Account.State.ONLINE) { if (account.getStatus() == Account.State.ONLINE) {
synchronized (XmppConnectionService.this) { synchronized (mLowPingTimeoutMode) {
if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) { if (mLowPingTimeoutMode.remove(account.getJid().toBareJid())) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode"); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": leaving low ping timeout mode");
} }
@ -336,10 +335,10 @@ public class XmppConnectionService extends Service {
account.pendingConferenceJoins.clear(); account.pendingConferenceJoins.clear();
scheduleWakeUpCall(Config.PING_MAX_INTERVAL, account.getUuid().hashCode()); scheduleWakeUpCall(Config.PING_MAX_INTERVAL, account.getUuid().hashCode());
} else { } else {
synchronized (XmppConnectionService.this) { if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) {
if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) { resetSendingToWaiting(account);
resetSendingToWaiting(account); if (!account.isOptionSet(Account.OPTION_DISABLED)) {
if (!account.isOptionSet(Account.OPTION_DISABLED)) { synchronized (mLowPingTimeoutMode) {
if (mLowPingTimeoutMode.contains(account.getJid().toBareJid())) { if (mLowPingTimeoutMode.contains(account.getJid().toBareJid())) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": went into offline state during low ping mode. reconnecting now"); Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": went into offline state during low ping mode. reconnecting now");
reconnectAccount(account, true, false); reconnectAccount(account, true, false);
@ -348,20 +347,20 @@ public class XmppConnectionService extends Service {
scheduleWakeUpCall(timeToReconnect, account.getUuid().hashCode()); scheduleWakeUpCall(timeToReconnect, account.getUuid().hashCode());
} }
} }
} else if (account.getStatus() == Account.State.REGISTRATION_SUCCESSFUL) { }
databaseBackend.updateAccount(account); } else if (account.getStatus() == Account.State.REGISTRATION_SUCCESSFUL) {
reconnectAccount(account, true, false); databaseBackend.updateAccount(account);
} else if ((account.getStatus() != Account.State.CONNECTING) reconnectAccount(account, true, false);
&& (account.getStatus() != Account.State.NO_INTERNET)) { } else if ((account.getStatus() != Account.State.CONNECTING)
resetSendingToWaiting(account); && (account.getStatus() != Account.State.NO_INTERNET)) {
if (connection != null) { resetSendingToWaiting(account);
int next = connection.getTimeToNextAttempt(); if (connection != null) {
Log.d(Config.LOGTAG, account.getJid().toBareJid() int next = connection.getTimeToNextAttempt();
+ ": error connecting account. try again in " Log.d(Config.LOGTAG, account.getJid().toBareJid()
+ next + "s for the " + ": error connecting account. try again in "
+ (connection.getAttempt() + 1) + " time"); + next + "s for the "
scheduleWakeUpCall(next, account.getUuid().hashCode()); + (connection.getAttempt() + 1) + " time");
} scheduleWakeUpCall(next, account.getUuid().hashCode());
} }
} }
} }