From 74b1503c602e1268b5199ef36c9611d7cb08adc1 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Mon, 18 Apr 2011 17:39:59 -0500 Subject: [PATCH] core: tear down all pending work when closing a port Make sure all pending work, if any, is torn down when closing the port, since it's closed, and is likely going to get unreffed soon and we don't want anything running after the port is dead. --- src/mm-serial-port.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 8b683dd3..18a616d9 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -837,6 +837,8 @@ mm_serial_port_close (MMSerialPort *self) priv->connected_id = 0; } + mm_serial_port_flash_cancel (self); + if (priv->fd >= 0) { GTimeVal tv_start, tv_end; @@ -852,8 +854,6 @@ mm_serial_port_close (MMSerialPort *self) priv->channel = NULL; } - mm_serial_port_flash_cancel (self); - g_get_current_time (&tv_start); tcsetattr (priv->fd, TCSANOW, &priv->old_t); @@ -901,6 +901,16 @@ mm_serial_port_close (MMSerialPort *self) g_slice_free (MMQueueData, item); } g_queue_clear (priv->queue); + + if (priv->timeout_id) { + g_source_remove (priv->timeout_id); + priv->timeout_id = 0; + } + + if (priv->queue_id) { + g_source_remove (priv->queue_id); + priv->queue_id = 0; + } } void