summaryrefslogtreecommitdiffstats
path: root/drivers/atmodem/gprs-context.c
diff options
context:
space:
mode:
authorKalle Valo <kalle.valo@canonical.com>2010-05-26 18:36:21 +0300
committerDenis Kenzior <denkenz@gmail.com>2010-05-26 12:34:07 -0500
commit125c7c392f266bb4700ff97ed2de944f40fde515 (patch)
tree661e70e52c112d2cff20bfd4f9dc84beba27e461 /drivers/atmodem/gprs-context.c
parentbf7243eda4300b44753673bffc8f8175b07a43f3 (diff)
downloadofono-125c7c392f266bb4700ff97ed2de944f40fde515.tar.bz2
atmodem: fix crash during context deactivation
Ofono either crashed or busy looped with my Huawei E1552 3G modem when I tried to deactivate GPRS context. The reason was that gcd->chat was unreferenced already in setup_ppp() but the chat was still accessed later in at_gprs_deactivate_primary(). To fix the problem, change the logic instead to suspend chat session for PPP and resume when PPP has disconnected. Now it doesn't crash anymore. Deactivation still doesn't work properly with Huawei E1552, and most probably with other Huawei modems, because the modem hangs up the chat line after PPP deactivation. This needs to be fixed separately. The workaround is to reboot the modem, for example physically unplug and plug it in again.
Diffstat (limited to 'drivers/atmodem/gprs-context.c')
-rw-r--r--drivers/atmodem/gprs-context.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c
index 9b32d594..24d1c58c 100644
--- a/drivers/atmodem/gprs-context.c
+++ b/drivers/atmodem/gprs-context.c
@@ -90,6 +90,8 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
DBG("");
+ g_at_chat_resume(gcd->chat);
+
switch (gcd->state) {
case STATE_ENABLING:
CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL,
@@ -110,16 +112,19 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data)
static gboolean setup_ppp(struct ofono_gprs_context *gc)
{
struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
- GIOChannel *channel;
+ GAtIO *io;
+
+ io = g_at_chat_get_io(gcd->chat);
- channel = g_at_chat_get_channel(gcd->chat);
- g_at_chat_unref(gcd->chat);
+ g_at_chat_suspend(gcd->chat);
/* open ppp */
- gcd->ppp = g_at_ppp_new(channel);
+ gcd->ppp = g_at_ppp_new_from_io(io);
- if (gcd->ppp == NULL)
+ if (gcd->ppp == NULL) {
+ g_at_chat_resume(gcd->chat);
return FALSE;
+ }
g_at_ppp_set_credentials(gcd->ppp, gcd->username, gcd->password);