Lock furi record for the whole notification process (#119)

Co-authored-by: aanper <mail@s3f.ru>
This commit is contained in:
Vadim Kaushan 2020-09-17 12:58:45 +03:00 committed by GitHub
parent 892a3b16da
commit 06ee165ab6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) {
@ -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;
}
@ -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;
}