Skip to content

Commit

Permalink
Lock furi record for the whole notification process (#119)
Browse files Browse the repository at this point in the history
Co-authored-by: aanper <[email protected]>
  • Loading branch information
Disasm and glitchcore authored Sep 17, 2020
1 parent 892a3b1 commit 06ee165
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/furi.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ void furi_give(FuriRecordSubscriber* handler) {
void furi_commit(FuriRecordSubscriber* handler) {
if(handler == NULL || handler->record == NULL) return;

furi_give(handler);
furi_notify(handler, handler->record->value, handler->record->size);
furi_give(handler);
}

bool furi_read(FuriRecordSubscriber* handler, void* value, size_t size) {
Expand All @@ -227,8 +227,8 @@ bool furi_read(FuriRecordSubscriber* handler, void* value, size_t size) {

furi_take(handler);
memcpy(value, handler->record->value, size);
furi_give(handler);
furi_notify(handler, value, size);
furi_give(handler);

return true;
}
Expand Down Expand Up @@ -272,17 +272,17 @@ bool furi_write(FuriRecordSubscriber* handler, const void* value, size_t size) {
return false;
}

furi_take(handler);
if(handler->record->value != NULL) {
// real write to value
furi_take(handler);
memcpy(handler->record->value, value, size);
furi_give(handler);

// notify subscribers
furi_notify(handler, handler->record->value, handler->record->size);
} else {
furi_notify(handler, value, size);
}
furi_give(handler);

return true;
}

0 comments on commit 06ee165

Please sign in to comment.