Skip to content

Commit 96d56cc

Browse files
Vudentznashif
authored andcommitted
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 <[email protected]>
1 parent 3f19a2e commit 96d56cc

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

subsys/bluetooth/host/gatt.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,18 @@ static void db_changed(void)
796796
continue;
797797
}
798798

799-
if (CF_ROBUST_CACHING(cfg) &&
800-
atomic_test_and_clear_bit(cfg->flags, CF_CHANGE_AWARE)) {
801-
BT_DBG("%s change-unaware", bt_addr_le_str(&cfg->peer));
799+
if (CF_ROBUST_CACHING(cfg)) {
800+
/* Core Spec 5.1 | Vol 3, Part G, 2.5.2.1 Robust Caching
801+
*... the database changes again before the client
802+
* becomes change-aware in which case the error response
803+
* shall be sent again.
804+
*/
805+
atomic_clear_bit(cfg->flags, CF_OUT_OF_SYNC);
806+
if (atomic_test_and_clear_bit(cfg->flags,
807+
CF_CHANGE_AWARE)) {
808+
BT_DBG("%s change-unaware",
809+
bt_addr_le_str(&cfg->peer));
810+
}
802811
}
803812
}
804813
#endif

0 commit comments

Comments
 (0)