huawei: only retry DHCP? check on specific errors

We don't want to retry DHCP? on every possible GError reported; specially if the
error is about the port being forced to get closed when the modem gets
unplugged or the like. So just retry on very specific errors reported.

The main cause for retry is really when the modem replies the following:
-->  AT^DHCP?
<--  ERROR

Which in our case gets translated to a 'unknown' mobile equipment error. We'll
also consider any kind of mobile equipment error, as the modems may reply a
CME ERROR instead.
This commit is contained in:
Aleksander Morgado
2013-01-16 10:56:53 +01:00
parent 2b3f353770
commit 2550cb20a9
+20 -5
View File
@@ -115,6 +115,7 @@ connect_dhcp_check_ready (MMBaseModem *modem,
MMBroadbandBearerHuawei *self)
{
Connect3gppContext *ctx;
GError *error = NULL;
ctx = self->priv->connect_pending;
g_assert (ctx != NULL);
@@ -122,11 +123,25 @@ connect_dhcp_check_ready (MMBaseModem *modem,
/* Balance refcount */
g_object_unref (self);
if (!mm_base_modem_at_command_full_finish (modem, res, NULL)) {
/* Setup timeout to retry the same step */
g_timeout_add_seconds (1,
(GSourceFunc)connect_retry_dhcp_check_cb,
g_object_ref (self));
if (!mm_base_modem_at_command_full_finish (modem, res, &error)) {
/* Only retry the DHCP check if we get a mobile equipment error, or if
* the command timed out. */
if (error->domain == MM_MOBILE_EQUIPMENT_ERROR ||
g_error_matches (error,
MM_SERIAL_ERROR,
MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) {
g_error_free (error);
/* Setup timeout to retry the same step */
g_timeout_add_seconds (1,
(GSourceFunc)connect_retry_dhcp_check_cb,
g_object_ref (self));
return;
}
/* Fatal error happened; e.g. modem unplugged */
self->priv->connect_pending = NULL;
g_simple_async_result_take_error (ctx->result, error);
connect_3gpp_context_complete_and_free (ctx);
return;
}