Skip to content

Commit e18695b

Browse files
Fix a deadlock in group poller (#1663)
1 parent aa2c8e8 commit e18695b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

app/src/main/java/org/thoughtcrime/securesms/groups/GroupPoller.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class GroupPoller @AssistedInject constructor(
121121
).also { emit(it) }
122122

123123
// Notify all pending tokens
124-
pendingTokens.forEach { it.resultCallback.send(pollResult) }
124+
pendingTokens.forEach {
125+
it.resultCallback.trySend(pollResult)
126+
}
125127
pendingTokens.clear()
126128
}
127129
}.stateIn(scope, SharingStarted.Eagerly, State())
@@ -135,10 +137,12 @@ class GroupPoller @AssistedInject constructor(
135137
appVisibilityManager.isAppVisible.first { visible -> visible }
136138

137139
// As soon as the app becomes visible, start polling
140+
Log.d(TAG, "Requesting routine poll for group($groupId)")
138141
if (requestPollOnce().hasNonRetryableError()) {
139142
Log.v(TAG, "Error polling group $groupId and stopped polling")
140143
break
141144
}
145+
Log.d(TAG, "Routine poll done once for group($groupId)")
142146

143147
// As long as the app is visible, keep polling
144148
while (true) {
@@ -152,10 +156,14 @@ class GroupPoller @AssistedInject constructor(
152156
break
153157
}
154158

159+
Log.d(TAG, "Requesting routine poll for group($groupId)")
160+
155161
if (requestPollOnce().hasNonRetryableError()) {
156162
Log.v(TAG, "Error polling group $groupId and stopped polling")
157163
return@launch
158164
}
165+
166+
Log.d(TAG, "Routine poll done once for group($groupId)")
159167
}
160168
}
161169
}

0 commit comments

Comments
 (0)