Fix single-client handling in some block providers

This commit is contained in:
Christian Helmuth 2023-03-20 09:13:19 +01:00
parent 927d71ad59
commit 34db8f5360
4 changed files with 11 additions and 4 deletions

View File

@ -2239,7 +2239,10 @@ struct Nvme::Main : Rpc_object<Typed_root<Block::Session>>
Capability<Session> session(Root::Session_args const &args,
Affinity const &) override
{
log("new block session: ", args.string());
if (_block_session.constructed()) {
error("device is already in use");
throw Service_denied();
}
Session_label const label { label_from_args(args.string()) };
Session_policy const policy { label, _config_rom.xml() };

View File

@ -1034,8 +1034,6 @@ struct Usb::Main : Rpc_object<Typed_root<Block::Session>>
Genode::Session_capability session(Root::Session_args const &args,
Affinity const &) override
{
log("new block session: ", args.string());
if (block_session.constructed()) {
error("device is already in use");
throw Service_denied();

View File

@ -383,6 +383,9 @@ struct Main : Rpc_object<Typed_root<Block::Session>>,
void close(Capability<Session> cap) override
{
if (!_block_session.constructed())
return;
if (cap == _block_session->cap()) {
_block_session.destruct();
_block_file.destruct();

View File

@ -212,7 +212,10 @@ struct Test::Main : Rpc_object<Typed_root<Block::Session> >
Capability<Session> session(Root::Session_args const &args,
Affinity const &) override
{
log("new block session: ", args.string());
if (_block_session.constructed()) {
error("already in use");
throw Service_denied();
}
size_t const ds_size =
Arg_string::find_arg(args.string(), "tx_buf_size").ulong_value(0);