[PATCH] huawei: avoid creating Connect3gppContext when no data port is available
Aleksander Morgado
aleksander at aleksander.es
Thu Jan 9 04:13:21 PST 2014
On 09/01/14 01:10, Ben Chan wrote:
> This patch modifies MMBroadbandBearerHuawei such that connect_3gpp
> simply reports an error via g_simple_async_report_error_in_idle, without
> creating a Connect3gppContext, if no data port is available.
> ---
> plugins/huawei/mm-broadband-bearer-huawei.c | 30 ++++++++++++++---------------
> 1 file changed, 15 insertions(+), 15 deletions(-)
>
Pushed, thanks.
> diff --git a/plugins/huawei/mm-broadband-bearer-huawei.c b/plugins/huawei/mm-broadband-bearer-huawei.c
> index be84ff8..df2d6d4 100644
> --- a/plugins/huawei/mm-broadband-bearer-huawei.c
> +++ b/plugins/huawei/mm-broadband-bearer-huawei.c
> @@ -69,8 +69,7 @@ connect_3gpp_context_complete_and_free (Connect3gppContext *ctx)
> g_simple_async_result_complete_in_idle (ctx->result);
> g_object_unref (ctx->cancellable);
> g_object_unref (ctx->result);
> - if (ctx->data)
> - g_object_unref (ctx->data);
> + g_object_unref (ctx->data);
> g_object_unref (ctx->primary);
> g_object_unref (ctx->modem);
> g_object_unref (ctx->self);
> @@ -377,14 +376,28 @@ connect_3gpp (MMBroadbandBearer *self,
> gpointer user_data)
> {
> Connect3gppContext *ctx;
> + MMPort *data;
>
> g_assert (primary != NULL);
>
> + /* We need a net data port */
> + data = mm_base_modem_peek_best_data_port (MM_BASE_MODEM (modem), MM_PORT_TYPE_NET);
> + if (!data) {
> + g_simple_async_report_error_in_idle (G_OBJECT (self),
> + callback,
> + user_data,
> + MM_CORE_ERROR,
> + MM_CORE_ERROR_NOT_FOUND,
> + "No valid data port found to launch connection");
> + return;
> + }
> +
> /* Setup connection context */
> ctx = g_slice_new0 (Connect3gppContext);
> ctx->self = g_object_ref (self);
> ctx->modem = g_object_ref (modem);
> ctx->primary = g_object_ref (primary);
> + ctx->data = g_object_ref (data);
> ctx->result = g_simple_async_result_new (G_OBJECT (self),
> callback,
> user_data,
> @@ -395,19 +408,6 @@ connect_3gpp (MMBroadbandBearer *self,
> g_assert (ctx->self->priv->connect_pending == NULL);
> g_assert (ctx->self->priv->disconnect_pending == NULL);
>
> - /* We need a net data port */
> - ctx->data = mm_base_modem_get_best_data_port (MM_BASE_MODEM (modem),
> - MM_PORT_TYPE_NET);
> - if (!ctx->data) {
> - g_simple_async_result_set_error (
> - ctx->result,
> - MM_CORE_ERROR,
> - MM_CORE_ERROR_NOT_FOUND,
> - "No valid data port found to launch connection");
> - connect_3gpp_context_complete_and_free (ctx);
> - return;
> - }
> -
> /* Run! */
> connect_3gpp_context_step (ctx);
> }
>
--
Aleksander Morgado
http://aleksander.es
More information about the ModemManager-devel
mailing list