Keep media task ownership through synchronous submission events
This commit is contained in:
1 parent
87724433b1
commit
41057ee9d5
2 files changed
+4
-2
No files matched your search
+2
-1
@@ -178,12 +178,13 @@ static void media_submit_finish(struct media_submit_ctx* ctx, int success) {
|
||||
struct UTUN_INSTANCE* inst = ctx->inst;
|
||||
struct chat_core_ctx* cc = CC(inst);
|
||||
char channel[64]; snprintf(channel, sizeof(channel), "%s", ctx->channel_id);
|
||||
/* Синхронный обработчик события может запросить удаление; ctx пока остаётся в списке владельца. */
|
||||
chat_event_submitted(ctx->inst, ctx->request_id, success);
|
||||
int delete_pending = ctx->delete_pending;
|
||||
struct media_submit_ctx** slot = &cc->media_submissions;
|
||||
while (*slot && *slot != ctx) slot = &(*slot)->next;
|
||||
if (*slot) *slot = ctx->next;
|
||||
else DEBUG_ERROR(DEBUG_CATEGORY_MEDIA, "media submission missing from owner ch=%s", channel);
|
||||
chat_event_submitted(ctx->inst, ctx->request_id, success);
|
||||
u_free(ctx);
|
||||
if (delete_pending) {
|
||||
for (struct media_submit_ctx* pending = cc->media_submissions; pending; pending = pending->next)
|
||||
|
||||
@@ -189,7 +189,8 @@ static void pending_deletion(void) {
|
||||
snprintf(req.media_dest, sizeof(req.media_dest), "%s", destinations[i]);
|
||||
req.request_id = i + 1; chat_core_submit_media_message(inst, &req);
|
||||
}
|
||||
assert(CC(inst)->media_submissions && CC(inst)->media_submissions->next); /* completions не обработаны */
|
||||
assert(CC(inst)->media_submissions && !failed_submissions);
|
||||
assert(scalar(db, "SELECT count(*) FROM media_preparations") == 2); /* completions не обработаны */
|
||||
chat_core_delete_channel(inst, channel); chat_core_delete_channel(inst, channel);
|
||||
assert(!deleted_events && scalar(db, "SELECT count(*) FROM channels WHERE name='pending'") == 1);
|
||||
req.request_id = 3; chat_core_submit_media_message(inst, &req); assert(failed_submissions == 1);
|
||||
|
||||
Reference in new issue
Block a user