[ModemManager] [PATCH] serial: report port-not-open in queueing commands via callback instead of just returning.
- From: Nathan Williams <njw google com>
- To: networkmanager-list gnome org
- Subject: [ModemManager] [PATCH] serial: report port-not-open in queueing commands via callback instead of just returning.
- Date: Mon, 28 Nov 2011 15:12:23 -0500
This is a followup to my previous change here; the port-not-open
situation is better treated as a manageable error condition rather
than a programming error.
- Nathan
From cec1bb628cd736fd0ac251e77e87f970cd78a4fb Mon Sep 17 00:00:00 2001
From: Nathan Williams <njw chromium org>
Date: Wed, 23 Nov 2011 16:16:20 -0500
Subject: [PATCH] serial: report port-not-open in queueing commands via callback instead of just returning.
This permits routines like mm-generic-gsm.c:simple_get_status() to
work again, as their callbacks get the error they are expecting. To
make this work, adapt get_csq_done() to handle a NULL response when
error is set, and make sure that multiple errors don't step on each
other in the mm_callback_info_chain() sequence created by
simple_get_status().
Change-Id: Ie3a72b1ce71b7f117e8b1f3da7a406c4d2da9e02
---
src/mm-generic-gsm.c | 14 +++++++++++---
src/mm-serial-port.c | 10 +++++++++-
2 files changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/mm-generic-gsm.c b/src/mm-generic-gsm.c
index d7a232e..d8ba4be 100644
--- a/src/mm-generic-gsm.c
+++ b/src/mm-generic-gsm.c
@@ -4187,7 +4187,7 @@ get_csq_done (MMAtSerialPort *port,
gpointer user_data)
{
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
- char *reply = response->str;
+ char *reply;
gboolean parsed = FALSE;
/* If the modem has already been removed, return without
@@ -4200,6 +4200,7 @@ get_csq_done (MMAtSerialPort *port,
goto done;
}
+ reply = response->str;
if (!strncmp (reply, "+CSQ: ", 6)) {
/* Got valid reply */
int quality;
@@ -5596,6 +5597,9 @@ simple_status_got_signal_quality (MMModem *modem,
if (!error) {
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
g_hash_table_insert (properties, "signal_quality", simple_uint_value (result));
+ } else {
+ g_clear_error (&info->error);
+ info->error = g_error_copy (error);
}
mm_callback_info_chain_complete_one (info);
}
@@ -5612,6 +5616,9 @@ simple_status_got_band (MMModem *modem,
if (!error) {
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
g_hash_table_insert (properties, "band", simple_uint_value (result));
+ } else {
+ g_clear_error (&info->error);
+ info->error = g_error_copy (error);
}
mm_callback_info_chain_complete_one (info);
}
@@ -5631,9 +5638,10 @@ simple_status_got_reg_info (MMModemGsmNetwork *modem,
if (!modem || mm_callback_info_check_modem_removed (info))
return;
- if (error)
+ if (error) {
+ g_clear_error (&info->error);
info->error = g_error_copy (error);
- else {
+ } else {
properties = (GHashTable *) mm_callback_info_get_data (info, SS_HASH_TAG);
g_hash_table_insert (properties, "registration_status", simple_uint_value (status));
diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index 2d07214..ad5cd91 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -969,9 +969,17 @@ internal_queue_command (MMSerialPort *self,
MMQueueData *info;
g_return_if_fail (MM_IS_SERIAL_PORT (self));
- g_return_if_fail (priv->open_count > 0);
g_return_if_fail (command != NULL);
+ if (!(priv->open_count > 0)) {
+ GError *error = g_error_new_literal (MM_SERIAL_ERROR,
+ MM_SERIAL_ERROR_SEND_FAILED,
+ "Sending command failed: device is not enabled");
+ callback (self, NULL, error, user_data);
+ g_error_free (error);
+ return;
+ }
+
info = g_slice_new0 (MMQueueData);
if (take_command)
info->command = command;
--
1.7.3.1
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]