Huawei modem closes the modem port after PPP disconnect. So the channel
of gatchat is NULL in ppp_disconnect. In such case, we should not resume
the chat and call disconnect function when removing the context.
Secondly, before removing the gprs context, we should reply the pending
DBus message to the client.
---
 drivers/atmodem/gprs-context.c |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index fea80b0..e2f291a 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -88,11 +88,22 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, 
gpointer user_data)
 {
        struct ofono_gprs_context *gc = user_data;
        struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
+       GAtIO *io = g_at_chat_get_io(gcd->chat);
 
        DBG("");
 
        g_at_ppp_unref(gcd->ppp);
        gcd->ppp = NULL;
+
+       if (g_at_io_get_channel(io) == NULL) {
+               CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL,
+                                       NULL, NULL, NULL, gcd->cb_data);
+               gcd->active_context = 0;
+               gcd->state = STATE_IDLE;
+               g_at_chat_resume(gcd->chat);
+               return;
+       }
+
        g_at_chat_resume(gcd->chat);
 
        switch (gcd->state) {
@@ -257,7 +268,7 @@ static void at_gprs_context_remove(struct 
ofono_gprs_context *gc)
 
        DBG("");
 
-       if (gcd->state != STATE_IDLE) {
+       if (gcd->state != STATE_IDLE && gcd->ppp) {
                g_at_ppp_unref(gcd->ppp);
                g_at_chat_resume(gcd->chat);
        }
-- 
1.7.0.4

_______________________________________________
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono

Reply via email to