From f2773e525c415bb9624fb7aa2cbf380fc706e3be Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 26 Jan 2016 12:47:54 -0600 Subject: [PATCH] wwan: retry connect on some errors and save them for log messages First, cb751012a2f4b8ef236eab2a7c65687c99205806 mistakenly converted the act_stage_context_step() in connect_ready() to connect_context_clear() instead of connect_context_step(). This would cause the IP Type retry logic to fail and no further types to be tried. It also throws away the ctx->first_error and causes all errors that MM returns on the connect attempt to be dropped on the floor. Second, not all errors should cause an advance to the next IP Type, since some errors aren't related to it. Specifically, MM_CORE_ERROR_RETRY when using Simple.Connect() means that a timeout was reached in the internal connect logic, not a modem or network error. In that case, try the connect again with the same IP Type before advancing to the next type. Fixes: cb751012a2f4b8ef236eab2a7c65687c99205806 Tested-by: Ladislav Michl Tested-by: Tore Anderson (cherry picked from commit 1cf47277662eda3bf3e049dc26c78f1022100169) --- src/devices/wwan/nm-modem-broadband.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/devices/wwan/nm-modem-broadband.c b/src/devices/wwan/nm-modem-broadband.c index 75d2b3eb5e..7248215656 100644 --- a/src/devices/wwan/nm-modem-broadband.c +++ b/src/devices/wwan/nm-modem-broadband.c @@ -53,6 +53,7 @@ typedef struct { MMSimpleConnectProperties *connect_properties; GArray *ip_types; guint ip_types_i; + guint ip_type_tries; GError *first_error; } ConnectContext; @@ -332,11 +333,17 @@ connect_ready (MMModemSimple *simple_iface, } else g_error_free (error); - /* If the modem/provider lies and the IP type we tried isn't supported, - * retry with the next one, if any. - */ - ctx->ip_types_i++; - connect_context_clear (self); + if (ctx->ip_type_tries == 0 && g_error_matches (error, MM_CORE_ERROR, MM_CORE_ERROR_RETRY)) { + /* Try one more time */ + ctx->ip_type_tries++; + } else { + /* If the modem/provider lies and the IP type we tried isn't supported, + * retry with the next one, if any. + */ + ctx->ip_types_i++; + ctx->ip_type_tries = 0; + } + connect_context_step (self); return; } @@ -486,9 +493,10 @@ connect_context_step (NMModemBroadband *self) else g_assert_not_reached (); - nm_log_dbg (LOGD_MB, "(%s): launching connection with ip type '%s'", + nm_log_dbg (LOGD_MB, "(%s): launching connection with ip type '%s' (try %d)", nm_modem_get_uid (NM_MODEM (self)), - nm_modem_ip_type_to_string (current)); + nm_modem_ip_type_to_string (current), + ctx->ip_type_tries + 1); mm_modem_simple_connect (self->priv->simple_iface, ctx->connect_properties,