File tree Expand file tree Collapse file tree 3 files changed +37
-1
lines changed
connectivity/FEATURE_BLE/source/generic Expand file tree Collapse file tree 3 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -361,6 +361,22 @@ void FileSecurityDb::restore()
361361
362362void FileSecurityDb::sync (entry_handle_t db_handle)
363363{
364+ /* if no entry is selected we will sync all entries */
365+ if (db_handle == invalid_entry_handle) {
366+ /* only write the connected devices as others are already written */
367+ for (size_t i = 0 ; i < get_entry_count (); i++) {
368+ entry_handle_t db_handle = get_entry_handle_by_index (i);
369+ SecurityDistributionFlags_t* flags = get_distribution_flags (db_handle);
370+
371+ if (flags && flags->connected ) {
372+ sync (db_handle);
373+ }
374+ }
375+ /* global sync triggers a flush */
376+ fflush (_db_file);
377+ return ;
378+ }
379+
364380 entry_t *entry = as_entry (db_handle);
365381 if (!entry) {
366382 return ;
Original file line number Diff line number Diff line change @@ -333,6 +333,22 @@ void KVStoreSecurityDb::restore()
333333
334334void KVStoreSecurityDb::sync (entry_handle_t db_handle)
335335{
336+ /* storage synchronisation is handled by KVStore itself, no explicit flushing */
337+
338+ /* if no entry is selected we will sync all entries */
339+ if (db_handle == invalid_entry_handle) {
340+ /* only write the connected devices as others are already written */
341+ for (size_t i = 0 ; i < get_entry_count (); i++) {
342+ entry_handle_t db_handle = get_entry_handle_by_index (i);
343+ SecurityDistributionFlags_t* flags = get_distribution_flags (db_handle);
344+
345+ if (flags && flags->connected ) {
346+ sync (db_handle);
347+ }
348+ }
349+ return ;
350+ }
351+
336352 entry_t *entry = as_entry (db_handle);
337353 if (!entry) {
338354 return ;
Original file line number Diff line number Diff line change @@ -522,7 +522,11 @@ class SecurityDb {
522522 virtual void restore ();
523523
524524 /* *
525- * Flush all values which might be stored in memory into NVM.
525+ * Write all values and attempt to sync persistent storage. Passing in an optional valid
526+ * db_handle will only write the given entry and not attempt to flush buffers.
527+ *
528+ * @param db_handle database entry to write. If invalid all entries are written and
529+ * persistent storage attempts to sync (flush buffers).
526530 */
527531 virtual void sync (entry_handle_t db_handle = invalid_entry_handle);
528532
You can’t perform that action at this time.
0 commit comments