From 426ec1fc346469ab252693355b6abdc7eef5c3f5 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 22:53:25 +0000 Subject: Apply patch 0002-port-serial-un-schedule-flash-operation-as-soon-as-i.patch patch_name: 0002-port-serial-un-schedule-flash-operation-as-soon-as-i.patch present_in_specfile: true --- diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c index 052d0dd..4762daf 100644 --- a/src/mm-port-serial.c +++ b/src/mm-port-serial.c @@ -1748,18 +1748,28 @@ flash_cancel_cb (GTask *task) void mm_port_serial_flash_cancel (MMPortSerial *self) { - GTask *task; + FlashContext *ctx; + GTask *task; /* Do nothing if there is no flash task */ if (!self->priv->flash_task) return; - /* Recover task and schedule it to be cancelled in an idle. + /* Recover task */ + task = self->priv->flash_task; + self->priv->flash_task = NULL; + + /* If flash operation is scheduled, unschedule it */ + ctx = g_task_get_task_data (task); + if (ctx->flash_id) { + g_source_remove (ctx->flash_id); + ctx->flash_id = 0; + } + + /* Schedule task to be cancelled in an idle. * We do NOT want this cancellation to happen right away, * because the object reference in the flashing task may * be the last one valid. */ - task = self->priv->flash_task; - self->priv->flash_task = NULL; g_idle_add ((GSourceFunc)flash_cancel_cb, task); }