From 7d1c404a6ae9b8076c4e43c15000340f7b452a58 Mon Sep 17 00:00:00 2001 From: Pekka Pessi Date: Thu, 27 May 2010 19:29:51 +0300 Subject: modem: Fix inconsistent state Keep modem state consistent if sim is removed while set_online driver call is pending. This results in set_online callback being called and modem entering an invalid state. --- src/modem.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/modem.c b/src/modem.c index a99d792a..5f3821bb 100644 --- a/src/modem.c +++ b/src/modem.c @@ -410,14 +410,16 @@ static void online_cb(const struct ofono_error *error, void *data) struct ofono_modem *modem = data; DBusMessage *reply; - if (error->type == OFONO_ERROR_TYPE_NO_ERROR) + if (error->type == OFONO_ERROR_TYPE_NO_ERROR && + modem->modem_state == MODEM_STATE_OFFLINE) reply = dbus_message_new_method_return(modem->pending); else reply = __ofono_error_failed(modem->pending); __ofono_dbus_pending_reply(&modem->pending, reply); - if (error->type == OFONO_ERROR_TYPE_NO_ERROR) + if (error->type == OFONO_ERROR_TYPE_NO_ERROR && + modem->modem_state == MODEM_STATE_OFFLINE) modem_change_state(modem, MODEM_STATE_ONLINE); } @@ -433,7 +435,8 @@ static void offline_cb(const struct ofono_error *error, void *data) __ofono_dbus_pending_reply(&modem->pending, reply); - if (error->type == OFONO_ERROR_TYPE_NO_ERROR) + if (error->type == OFONO_ERROR_TYPE_NO_ERROR && + modem->modem_state == MODEM_STATE_ONLINE) modem_change_state(modem, MODEM_STATE_OFFLINE); } -- cgit v1.2.3