[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
---
 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 427f3ed..44ac1021 100644
--- a/src/devices/wwan/nm-modem-broadband.c
+++ b/src/devices/wwan/nm-modem-broadband.c
@@ -52,6 +52,7 @@ typedef struct {
        MMSimpleConnectProperties *connect_properties;
        GArray *ip_types;
        guint ip_types_i;
+       guint ip_type_tries;
        GError *first_error;
 } ConnectContext;
 
@@ -331,11 +332,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;
        }
 
@@ -485,9 +492,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,
-- 
2.4.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]