Bluetooth: GATT: Fix not clearing out of sync flag

When the database changes and a client becomes change unware it should
also clear the out of sync flag as the following request should return
an error:

Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching:

  'The error response is sent only once after the client becomes
  change-unaware, unless the client disconnects or the database changes
  again before the client becomes change-aware in which case the error
  response shall be sent again.'

Fixes: #18183

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
Luiz Augusto von Dentz 2019-08-16 13:55:42 +03:00 committed by Johan Hedberg
commit 692d7d523e

View file

@ -824,9 +824,18 @@ static void db_changed(void)
continue;
}
if (CF_ROBUST_CACHING(cfg) &&
atomic_test_and_clear_bit(cfg->flags, CF_CHANGE_AWARE)) {
BT_DBG("%s change-unaware", bt_addr_le_str(&cfg->peer));
if (CF_ROBUST_CACHING(cfg)) {
/* Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching
*... the database changes again before the client
* becomes change-aware in which case the error response
* shall be sent again.
*/
atomic_clear_bit(cfg->flags, CF_OUT_OF_SYNC);
if (atomic_test_and_clear_bit(cfg->flags,
CF_CHANGE_AWARE)) {
BT_DBG("%s change-unaware",
bt_addr_le_str(&cfg->peer));
}
}
}
#endif