diff options
author | Dan Williams <dcbw@redhat.com> | 2010-05-26 11:43:06 -0700 |
---|---|---|
committer | Dan Williams <dcbw@redhat.com> | 2010-05-26 11:43:06 -0700 |
commit | d5b8019d66870ed98d58095fa6b173a880fd3966 (patch) | |
tree | b9e8e2eb57b1c57440c1881fc56e5886f3af99c5 /src | |
parent | 6c3ae7d8fd3665eab02aab014c5ea46809312a29 (diff) |
serial: fix cleanup of flash function (rh #591728)
The flash function could be called when the port was closed, and since
the flash function would only be canceled when the port was open,
it could trigger after the port object was destroyed.
Diffstat (limited to 'src')
-rw-r--r-- | src/mm-errors.c | 1 | ||||
-rw-r--r-- | src/mm-errors.h | 1 | ||||
-rw-r--r-- | src/mm-serial-port.c | 16 |
3 files changed, 14 insertions, 4 deletions
diff --git a/src/mm-errors.c b/src/mm-errors.c index aa900608..e4fdda7f 100644 --- a/src/mm-errors.c +++ b/src/mm-errors.c @@ -44,6 +44,7 @@ mm_serial_error_get_type (void) ENUM_ENTRY (MM_SERIAL_ERROR_RESPONSE_TIMEOUT, "SerialResponseTimeout"), ENUM_ENTRY (MM_SERIAL_ERROR_OPEN_FAILED_NO_DEVICE, "SerialOpenFailedNoDevice"), ENUM_ENTRY (MM_SERIAL_ERROR_FLASH_FAILED, "SerialFlashFailed"), + ENUM_ENTRY (MM_SERIAL_ERROR_NOT_OPEN, "SerialNotOpen"), { 0, 0, 0 } }; diff --git a/src/mm-errors.h b/src/mm-errors.h index b6891c35..13a531d5 100644 --- a/src/mm-errors.h +++ b/src/mm-errors.h @@ -25,6 +25,7 @@ enum { MM_SERIAL_ERROR_RESPONSE_TIMEOUT = 2, MM_SERIAL_ERROR_OPEN_FAILED_NO_DEVICE = 3, MM_SERIAL_ERROR_FLASH_FAILED = 4, + MM_SERIAL_ERROR_NOT_OPEN = 5, }; #define MM_SERIAL_ERROR (mm_serial_error_quark ()) diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c index 18b39f72..df704af3 100644 --- a/src/mm-serial-port.c +++ b/src/mm-serial-port.c @@ -814,10 +814,7 @@ mm_serial_port_close (MMSerialPort *self) priv->channel = NULL; } - if (priv->flash_id > 0) { - g_source_remove (priv->flash_id); - priv->flash_id = 0; - } + mm_serial_port_flash_cancel (self); tcsetattr (priv->fd, TCSANOW, &priv->old_t); close (priv->fd); @@ -1032,6 +1029,15 @@ mm_serial_port_flash (MMSerialPort *self, priv = MM_SERIAL_PORT_GET_PRIVATE (self); + if (!mm_serial_port_is_open (self)) { + error = g_error_new_literal (MM_SERIAL_ERROR, + MM_SERIAL_ERROR_NOT_OPEN, + "The serial port is not open."); + callback (self, error, user_data); + g_error_free (error); + return FALSE; + } + if (priv->flash_id > 0) { error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_OPERATION_IN_PROGRESS, @@ -1215,6 +1221,8 @@ dispose (GObject *object) if (mm_serial_port_is_open (MM_SERIAL_PORT (object))) mm_serial_port_close_force (MM_SERIAL_PORT (object)); + mm_serial_port_flash_cancel (MM_SERIAL_PORT (object)); + G_OBJECT_CLASS (mm_serial_port_parent_class)->dispose (object); } |