Prevent send/cancel race condition

This commit is contained in:
M66B
2021-03-22 08:04:52 +01:00
parent 0d74924c99
commit b787d889de
3 changed files with 18 additions and 6 deletions

View File

@@ -482,6 +482,10 @@ public class ServiceSend extends ServiceBase implements SharedPreferences.OnShar
private void onSend(EntityMessage message) throws MessagingException, IOException {
DB db = DB.getInstance(this);
EntityOperation operation = db.operation().getOperation(message.id, EntityOperation.SEND);
if (operation == null)
throw new IllegalArgumentException("Send cancelled");
// Mark attempt
if (message.last_attempt == null) {
message.last_attempt = new Date().getTime();