aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-07-01 08:52:56 +0200
committerChristian Schneppe <christian@pix-art.de>2019-07-01 08:52:56 +0200
commitf2c4eebaf88cc4d6c16609e2a9cbd13a5b5ccf0a (patch)
tree85046b681b8763a946d8174277fcf59439f30c04 /src/main/java/de/pixart/messenger/services/XmppConnectionService.java
parent6086d9c45fe88183ae0e4c1ec2e5c316a281f028 (diff)
migrate copy ond write list to synchronized hashset for pending mucs
Diffstat (limited to 'src/main/java/de/pixart/messenger/services/XmppConnectionService.java')
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java51
1 files changed, 38 insertions, 13 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index b75dd0225..7fabd1806 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -394,8 +394,12 @@ public class XmppConnectionService extends Service {
synchronized (account.inProgressConferenceJoins) {
inProgressJoin = account.inProgressConferenceJoins.contains(conversation);
}
+ final boolean pendingJoin;
+ synchronized (account.pendingConferenceJoins) {
+ pendingJoin = account.pendingConferenceJoins.contains(conversation);
+ }
if (conversation.getAccount() == account
- && !account.pendingConferenceJoins.contains(conversation)
+ && !pendingJoin
&& !inProgressJoin) {
if (!conversation.startOtrIfNeeded()) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": couldn't start OTR with " + conversation.getContact().getJid() + " when needed");
@@ -404,14 +408,23 @@ public class XmppConnectionService extends Service {
resendFailedFileMessages(conversation);
}
}
- for (Conversation conversation : account.pendingConferenceLeaves) {
+ final List<Conversation> pendingLeaves;
+ synchronized (account.pendingConferenceLeaves) {
+ pendingLeaves = new ArrayList<>(account.pendingConferenceLeaves);
+ account.pendingConferenceLeaves.clear();
+
+ }
+ for (Conversation conversation : pendingLeaves) {
leaveMuc(conversation);
}
- account.pendingConferenceLeaves.clear();
- for (Conversation conversation : account.pendingConferenceJoins) {
+ final List<Conversation> pendingJoins;
+ synchronized (account.pendingConferenceJoins) {
+ pendingJoins = new ArrayList<>(account.pendingConferenceJoins);
+ account.pendingConferenceJoins.clear();
+ }
+ for (Conversation conversation : pendingJoins) {
joinMuc(conversation);
}
- account.pendingConferenceJoins.clear();
scheduleWakeUpCall(Config.PING_MAX_INTERVAL, account.getUuid().hashCode());
} else if (account.getStatus() == Account.State.OFFLINE || account.getStatus() == Account.State.DISABLED) {
resetSendingToWaiting(account);
@@ -2792,9 +2805,13 @@ public class XmppConnectionService extends Service {
}
private void joinMuc(Conversation conversation, final OnConferenceJoined onConferenceJoined, final boolean followedInvite) {
- Account account = conversation.getAccount();
- account.pendingConferenceJoins.remove(conversation);
- account.pendingConferenceLeaves.remove(conversation);
+ final Account account = conversation.getAccount();
+ synchronized (account.pendingConferenceJoins) {
+ account.pendingConferenceJoins.remove(conversation);
+ }
+ synchronized (account.pendingConferenceLeaves) {
+ account.pendingConferenceLeaves.remove(conversation);
+ }
if (account.getStatus() == Account.State.ONLINE) {
synchronized (account.inProgressConferenceJoins) {
account.inProgressConferenceJoins.add(conversation);
@@ -2890,7 +2907,9 @@ public class XmppConnectionService extends Service {
});
updateConversationUi();
} else {
- account.pendingConferenceJoins.add(conversation);
+ synchronized (account.pendingConferenceJoins) {
+ account.pendingConferenceJoins.add(conversation);
+ }
conversation.resetMucOptions();
conversation.setHasMessagesLeftOnServer(false);
updateConversationUi();
@@ -3106,9 +3125,13 @@ public class XmppConnectionService extends Service {
}
private void leaveMuc(Conversation conversation, boolean now) {
- Account account = conversation.getAccount();
- account.pendingConferenceJoins.remove(conversation);
- account.pendingConferenceLeaves.remove(conversation);
+ final Account account = conversation.getAccount();
+ synchronized (account.pendingConferenceJoins) {
+ account.pendingConferenceJoins.remove(conversation);
+ }
+ synchronized (account.pendingConferenceLeaves) {
+ account.pendingConferenceLeaves.remove(conversation);
+ }
if (account.getStatus() == Account.State.ONLINE || now) {
if (conversation.getMucOptions().push()) {
disableDirectMucPush(conversation);
@@ -3122,7 +3145,9 @@ public class XmppConnectionService extends Service {
}
Log.d(Config.LOGTAG, conversation.getAccount().getJid().asBareJid() + ": leaving muc " + conversation.getJid());
} else {
- account.pendingConferenceLeaves.add(conversation);
+ synchronized (account.pendingConferenceLeaves) {
+ account.pendingConferenceLeaves.add(conversation);
+ }
}
}