mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-20 17:52:52 +00:00
os: fix race in 'os/child_policy_dynamic_rom.h'
This commit is contained in:
parent
c48a4ebce8
commit
3a1ecdd5a7
@ -28,6 +28,15 @@ namespace Genode {
|
||||
|
||||
Ram_session *_ram;
|
||||
|
||||
/*
|
||||
* The ROM module may be written and consumed by different threads,
|
||||
* e.g., written by the main thread and consumed by the child's
|
||||
* entrypoint that manages the local ROM service for handing out a
|
||||
* dynamic config. Hence, the '_lock' is used to synchronize the
|
||||
* 'load' and 'dataspace' functions.
|
||||
*/
|
||||
Lock _lock;
|
||||
|
||||
/*
|
||||
* We keep two dataspaces around. The foreground ('_fg') dataspace
|
||||
* is the one we present to the client. While the foreground
|
||||
@ -87,6 +96,8 @@ namespace Genode {
|
||||
*/
|
||||
void load(void const *data, size_t data_len)
|
||||
{
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
if (!_ram) {
|
||||
PERR("Error: No backing store for loading ROM data");
|
||||
return;
|
||||
@ -110,6 +121,8 @@ namespace Genode {
|
||||
|
||||
Rom_dataspace_capability dataspace()
|
||||
{
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
if (!_fg.size() && !_bg_has_pending_data) {
|
||||
PERR("Error: no data loaded");
|
||||
return Rom_dataspace_capability();
|
||||
|
Loading…
x
Reference in New Issue
Block a user