From a7b8cbb71d1447a5cc870aefed99ccc6b3325cd3 Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Fri, 29 Mar 2013 12:33:20 +0100 Subject: port-probe: don't reschedule next probing step when serial port buffer full When the serial port buffer gets full of non-AT garbage during port probing, we were re-scheduling the next probing step, which is completely wrong, as we then would be processing the same probing task twice. If we get a buffer full, just cancel the AT probing cancellable, which would cancel not only the possible AT probings, but also the custom init if there is any. Also, make sure that the custom_init() of the plugins out there don't return an error if the GCancellable is cancelled. Cancelling the GCancellable means we should just stop the custom_init(), and actually sending an error in custom_init() means that the port should be set as unsupported by the plugin, so completely different things. Should fix https://bugzilla.gnome.org/show_bug.cgi?id=696695 --- plugins/huawei/mm-plugin-huawei.c | 5 +---- plugins/longcheer/mm-plugin-longcheer.c | 5 +---- plugins/sierra/mm-plugin-sierra.c | 10 ++++------ plugins/x22x/mm-plugin-x22x.c | 5 +---- src/mm-port-probe.c | 10 ++++++++-- 5 files changed, 15 insertions(+), 20 deletions(-) diff --git a/plugins/huawei/mm-plugin-huawei.c b/plugins/huawei/mm-plugin-huawei.c index b7d2eaad..e6ebafb4 100644 --- a/plugins/huawei/mm-plugin-huawei.c +++ b/plugins/huawei/mm-plugin-huawei.c @@ -235,10 +235,7 @@ huawei_custom_init_step (HuaweiCustomInitContext *ctx) if (g_cancellable_is_cancelled (ctx->cancellable)) { mm_dbg ("(Huawei) no need to keep on running custom init in (%s)", mm_port_get_device (MM_PORT (ctx->port))); - g_simple_async_result_set_error (ctx->result, - MM_CORE_ERROR, - MM_CORE_ERROR_CANCELLED, - "Custom initialization cancelled"); + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); huawei_custom_init_context_complete_and_free (ctx); return; } diff --git a/plugins/longcheer/mm-plugin-longcheer.c b/plugins/longcheer/mm-plugin-longcheer.c index 4d9596d8..aa516568 100644 --- a/plugins/longcheer/mm-plugin-longcheer.c +++ b/plugins/longcheer/mm-plugin-longcheer.c @@ -107,10 +107,7 @@ longcheer_custom_init_step (LongcheerCustomInitContext *ctx) if (g_cancellable_is_cancelled (ctx->cancellable)) { mm_dbg ("(Longcheer) no need to keep on running custom init in (%s)", mm_port_get_device (MM_PORT (ctx->port))); - g_simple_async_result_set_error (ctx->result, - MM_CORE_ERROR, - MM_CORE_ERROR_CANCELLED, - "Custom initialization cancelled"); + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); longcheer_custom_init_context_complete_and_free (ctx); return; } diff --git a/plugins/sierra/mm-plugin-sierra.c b/plugins/sierra/mm-plugin-sierra.c index dc7ae3b5..0e4eceb0 100644 --- a/plugins/sierra/mm-plugin-sierra.c +++ b/plugins/sierra/mm-plugin-sierra.c @@ -126,18 +126,16 @@ sierra_custom_init_step (SierraCustomInitContext *ctx) { /* If cancelled, end */ if (g_cancellable_is_cancelled (ctx->cancellable)) { - mm_dbg ("(Sierra) no need to keep on running custom init in (%s)", + mm_dbg ("(Sierra) no need to keep on running custom init in '%s'", mm_port_get_device (MM_PORT (ctx->port))); - g_simple_async_result_set_error (ctx->result, - MM_CORE_ERROR, - MM_CORE_ERROR_CANCELLED, - "Custom initialization cancelled"); + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); sierra_custom_init_context_complete_and_free (ctx); return; } if (ctx->retries == 0) { - mm_dbg ("(Sierra) Couldn't get port type hints"); + mm_dbg ("(Sierra) Couldn't get port type hints from '%s'", + mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); sierra_custom_init_context_complete_and_free (ctx); return; diff --git a/plugins/x22x/mm-plugin-x22x.c b/plugins/x22x/mm-plugin-x22x.c index 53440d14..c729469e 100644 --- a/plugins/x22x/mm-plugin-x22x.c +++ b/plugins/x22x/mm-plugin-x22x.c @@ -106,10 +106,7 @@ x22x_custom_init_step (X22xCustomInitContext *ctx) if (g_cancellable_is_cancelled (ctx->cancellable)) { mm_dbg ("(X22X) no need to keep on running custom init in (%s)", mm_port_get_device (MM_PORT (ctx->port))); - g_simple_async_result_set_error (ctx->result, - MM_CORE_ERROR, - MM_CORE_ERROR_CANCELLED, - "Custom initialization cancelled"); + g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); x22x_custom_init_context_complete_and_free (ctx); return; } diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c index 77349250..788c1045 100644 --- a/src/mm-port-probe.c +++ b/src/mm-port-probe.c @@ -940,10 +940,16 @@ serial_buffer_full (MMSerialPort *serial, GByteArray *buffer, MMPortProbe *self) { + PortProbeRunTask *task = self->priv->task; + if (is_non_at_response (buffer->data, buffer->len)) { - mm_serial_port_close (serial); + mm_dbg ("(%s/%s) serial buffer full", + g_udev_device_get_subsystem (self->priv->port), + g_udev_device_get_name (self->priv->port)); + /* Don't explicitly close the AT port, just end the AT probing + * (or custom init probing) */ mm_port_probe_set_result_at (self, FALSE); - serial_probe_schedule (self); + g_cancellable_cancel (task->at_probing_cancellable); } } -- cgit v1.2.3