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()
361
361
362
362
void FileSecurityDb::sync (entry_handle_t db_handle)
363
363
{
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
+
364
380
entry_t *entry = as_entry (db_handle);
365
381
if (!entry) {
366
382
return ;
Original file line number Diff line number Diff line change @@ -333,6 +333,22 @@ void KVStoreSecurityDb::restore()
333
333
334
334
void KVStoreSecurityDb::sync (entry_handle_t db_handle)
335
335
{
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
+
336
352
entry_t *entry = as_entry (db_handle);
337
353
if (!entry) {
338
354
return ;
Original file line number Diff line number Diff line change @@ -522,7 +522,11 @@ class SecurityDb {
522
522
virtual void restore ();
523
523
524
524
/* *
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).
526
530
*/
527
531
virtual void sync (entry_handle_t db_handle = invalid_entry_handle);
528
532
You can’t perform that action at this time.
0 commit comments