aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2010-06-10 10:41:10 -0700
committerDan Williams <dcbw@redhat.com>2010-06-10 10:41:10 -0700
commit962a6b0939cd4b3ea7306492cb25f88b77668ef5 (patch)
tree609e589099790b658c3f3c5aa70d66a010e62205 /src
parent164e5dfd498d2e746014cacbd3cc1a5bbf8528d1 (diff)
core: return errors to outstanding requests when serial ports are closed
Prevents crashes when the callback info completes when the modem is removed, plus it's the right thing to do anyway...
Diffstat (limited to 'src')
-rw-r--r--src/mm-serial-port.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index df704af3..ed44167b 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -825,6 +825,25 @@ mm_serial_port_close (MMSerialPort *self)
for (i = 0; i < g_queue_get_length (priv->queue); i++) {
MMQueueData *item = g_queue_peek_nth (priv->queue, i);
+ if (item->callback) {
+ GError *error;
+ GByteArray *response;
+
+ g_warn_if_fail (MM_SERIAL_PORT_GET_CLASS (self)->handle_response != NULL);
+ error = g_error_new_literal (MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_SEND_FAILED,
+ "Serial port is now closed");
+ response = g_byte_array_sized_new (1);
+ g_byte_array_append (response, (const guint8 *) "\0", 1);
+ MM_SERIAL_PORT_GET_CLASS (self)->handle_response (self,
+ response,
+ error,
+ item->callback,
+ item->user_data);
+ g_error_free (error);
+ g_byte_array_free (response, TRUE);
+ }
+
g_byte_array_free (item->command, TRUE);
g_slice_free (MMQueueData, item);
}