diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-09-10 15:29:03 +0200 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2019-09-11 14:34:40 +0000 |
commit | 25011ec733f75e4b4d4b8c4124428ab341d735a2 (patch) | |
tree | 8701a2430c4d57e375096ef24a696abbe5b7f8e8 /src | |
parent | 7b3df735cdb905fe5edd9c5619a7463752561bb6 (diff) |
port-serial: flash cancellation always completed in idle
We cannot complete the flash task cancellation right away because this
may be called from within _close_internal() during a forced port close
after the TTY has gone, which would mean the object is fully disposed
already after the flash cancellation has been requested.
By making the task cancellation complete in idle, we're sure that
there will be at least one reference valid (the one in the task)
during the port close operation.
ModemManager[25156]: <debug> [1568121341.696563] Modem (Generic) '/sys/devices/pci0000:00/0000:00:00.0' completely disposed
**
ERROR:mm-port-serial.c:2067:finalize: assertion failed: (self->priv->iochannel == NULL)
(gdb) bt
#0 0x00007ffff757c755 in raise () at /usr/lib/libc.so.6
#1 0x00007ffff7567851 in abort () at /usr/lib/libc.so.6
#2 0x00007ffff7741062 in () at /usr/lib/libglib-2.0.so.0
#3 0x00007ffff776d99d in g_assertion_message_expr () at /usr/lib/libglib-2.0.so.0
#4 0x0000555555662f0a in finalize (object=0x55555577a380) at mm-port-serial.c:2067
#5 0x0000555555664d81 in finalize (object=0x55555577a380) at mm-port-serial-at.c:632
#6 0x00007ffff787b351 in g_object_unref () at /usr/lib/libgobject-2.0.so.0
#7 0x00007ffff795d5eb in () at /usr/lib/libgio-2.0.so.0
#8 0x00007ffff787b351 in g_object_unref () at /usr/lib/libgobject-2.0.so.0
#9 0x0000555555662126 in mm_port_serial_flash_cancel (self=0x55555577a380) at mm-port-serial.c:1747
#10 0x0000555555661224 in _close_internal (self=0x55555577a380, force=1) at mm-port-serial.c:1397
#11 0x000055555566197b in port_serial_close_force (self=0x55555577a380) at mm-port-serial.c:1526
#12 0x000055555565fbe5 in common_input_available (self=0x55555577a380, condition=(G_IO_IN | G_IO_ERR | G_IO_HUP)) at mm-port-serial.c:971
#13 0x00005555556600c0 in iochannel_input_available (iochannel=0x55555578a0a0, condition=(G_IO_IN | G_IO_ERR | G_IO_HUP), data=0x55555577a380) at mm-port-serial.c:1073
#14 0x00007ffff778ebb0 in g_main_context_dispatch () at /usr/lib/libglib-2.0.so.0
#15 0x00007ffff7790b11 in () at /usr/lib/libglib-2.0.so.0
#16 0x00007ffff7791a63 in g_main_loop_run () at /usr/lib/libglib-2.0.so.0
#17 0x000055555559afb0 in main (argc=3, argv=0x7fffffffea58) at main.c:181
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-port-serial.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/mm-port-serial.c b/src/mm-port-serial.c index 1c2fd2d3..bd3b92a7 100644 --- a/src/mm-port-serial.c +++ b/src/mm-port-serial.c @@ -1728,23 +1728,30 @@ mm_port_serial_flash_finish (MMPortSerial *port, return g_task_propagate_boolean (G_TASK (res), error); } +static gboolean +flash_cancel_cb (GTask *task) +{ + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_CANCELLED, "Flash cancelled"); + g_object_unref (task); + return G_SOURCE_REMOVE; +} + void mm_port_serial_flash_cancel (MMPortSerial *self) { GTask *task; + /* Do nothing if there is no flash task */ if (!self->priv->flash_task) return; - /* Recover task */ + /* Recover task and schedule it 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_task_return_new_error (task, - MM_CORE_ERROR, - MM_CORE_ERROR_CANCELLED, - "Flash cancelled"); - g_object_unref (task); + g_idle_add ((GSourceFunc)flash_cancel_cb, task); } static gboolean |