diff options
author | Daniel Orstadius <daniel.orstadius@nokia.com> | 2010-08-18 15:48:28 +0300 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2010-08-18 16:30:50 +0300 |
commit | 5ac50f2903c857c52a721a9419793885e3358d83 (patch) | |
tree | 6fc74724137b7f092ee9b73835f9e282ffddca2b /plugins/maemo6.c | |
parent | 65f8694909ec6c592c26b5905ca17d505ff24663 (diff) |
Maemo6 MCE: handle race condition at startup
Since bluetoothd power cycles the adapter at startup, it is possible
that the plugin gets a reply from reading the state of the MCE and
tries to power the adapter before it is down. The patch checks for
that situation and if it occurs postpones powering the adapter to
the powered state callback.
Diffstat (limited to 'plugins/maemo6.c')
-rw-r--r-- | plugins/maemo6.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/plugins/maemo6.c b/plugins/maemo6.c index 55ea508f..c96731d6 100644 --- a/plugins/maemo6.c +++ b/plugins/maemo6.c @@ -50,6 +50,7 @@ static guint watch_id; static DBusConnection *conn = NULL; static gboolean mce_bt_set = FALSE; +static gboolean collision = FALSE; static gboolean mce_signal_callback(DBusConnection *connection, DBusMessage *message, void *user_data) @@ -112,6 +113,13 @@ static void read_radio_states_cb(DBusPendingCall *call, void *user_data) mce_bt_set = radio_states & MCE_RADIO_STATE_BLUETOOTH; + /* check if the adapter has not completed the initial power + * cycle, if so delay action to mce_notify_powered */ + collision = mce_bt_set && adapter_powering_down(adapter); + + if (collision) + goto done; + if (mce_bt_set) btd_adapter_switch_online(adapter); else @@ -129,6 +137,19 @@ static void adapter_powered(struct btd_adapter *adapter, gboolean powered) DBG("adapter_powered called with %d", powered); + /* check if the plugin got the get_radio_states reply from the + * mce when the adapter was not yet down during the power + * cycling when bluetoothd is started */ + if (collision) { + error("maemo6: powered state collision"); + collision = FALSE; + + if (mce_bt_set) + btd_adapter_switch_online(adapter); + + return; + } + /* nothing to do if the states match */ if (mce_bt_set == powered) return; |