mirror of
https://github.com/moparisthebest/Conversations
synced 2024-12-25 08:58:55 -05:00
synchronize on dedicated lock for catchup instead of account
This commit is contained in:
parent
9fd6539534
commit
7cd4ed78b2
@ -52,6 +52,8 @@ import eu.siacs.conversations.xmpp.XmppConnection;
|
||||
|
||||
public class NotificationService {
|
||||
|
||||
public static final Object CATCHUP_LOCK = new Object();
|
||||
|
||||
private static final String CONVERSATIONS_GROUP = "eu.siacs.conversations";
|
||||
private final XmppConnectionService mXmppConnectionService;
|
||||
|
||||
@ -173,7 +175,7 @@ public class NotificationService {
|
||||
}
|
||||
|
||||
public void push(final Message message) {
|
||||
synchronized (message.getConversation().getAccount()) {
|
||||
synchronized (CATCHUP_LOCK) {
|
||||
final XmppConnection connection = message.getConversation().getAccount().getXmppConnection();
|
||||
if (connection.isWaitingForSmCatchup()) {
|
||||
connection.incrementSmCatchupMessageCounter();
|
||||
|
@ -64,6 +64,7 @@ import eu.siacs.conversations.entities.Account;
|
||||
import eu.siacs.conversations.entities.Message;
|
||||
import eu.siacs.conversations.entities.ServiceDiscoveryResult;
|
||||
import eu.siacs.conversations.generator.IqGenerator;
|
||||
import eu.siacs.conversations.services.NotificationService;
|
||||
import eu.siacs.conversations.services.XmppConnectionService;
|
||||
import eu.siacs.conversations.utils.DNSHelper;
|
||||
import eu.siacs.conversations.utils.SSLSocketHelper;
|
||||
@ -617,15 +618,20 @@ public class XmppConnection implements Runnable {
|
||||
final AckPacket ack = new AckPacket(this.stanzasReceived, smVersion);
|
||||
tagWriter.writeStanzaAsync(ack);
|
||||
} else if (nextTag.isStart("a")) {
|
||||
synchronized (account) {
|
||||
boolean accountUiNeedsRefresh = false;
|
||||
synchronized (NotificationService.CATCHUP_LOCK) {
|
||||
if (mWaitingForSmCatchup.compareAndSet(true, false)) {
|
||||
int count = mSmCatchupMessageCounter.get();
|
||||
Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": SM catchup complete (" + count + ")");
|
||||
accountUiNeedsRefresh = true;
|
||||
if (count > 0) {
|
||||
mXmppConnectionService.getNotificationService().finishBacklog(true, account);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (accountUiNeedsRefresh) {
|
||||
mXmppConnectionService.updateAccountUi();
|
||||
}
|
||||
final Element ack = tagReader.readElement(nextTag);
|
||||
lastPacketReceived = SystemClock.elapsedRealtime();
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user