mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-19 03:06:39 +00:00
rom_filter: expand target buffer on demand
The ROM filter did not handle the situation where the generated content exceeds the size of the initially allocated dataspace for the target buffer. This patch wraps the XML generation in a retry loop that expands the buffer as needed.
This commit is contained in:
parent
f3988a27d4
commit
1ccd9a2fdb
@ -15,6 +15,7 @@
|
||||
#include <util/reconstructible.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <util/xml_generator.h>
|
||||
#include <util/retry.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/component.h>
|
||||
#include <base/attached_ram_dataspace.h>
|
||||
@ -329,12 +330,22 @@ void Rom_filter::Main::_evaluate()
|
||||
Node_type_name const node_type =
|
||||
output.attribute_value("node", Node_type_name(""));
|
||||
|
||||
/* generate output */
|
||||
Xml_generator xml(_xml_ds->local_addr<char>(),
|
||||
_xml_ds->size(), node_type.string(),
|
||||
[&] () { _evaluate_node(output, xml); });
|
||||
|
||||
_xml_output_len = xml.used();
|
||||
/*
|
||||
* Generate output, expand dataspace on demand
|
||||
*/
|
||||
enum { UPGRADE = 4096, NUM_ATTEMPTS = ~0L };
|
||||
Genode::retry<Xml_generator::Buffer_exceeded>(
|
||||
[&] () {
|
||||
Xml_generator xml(_xml_ds->local_addr<char>(),
|
||||
_xml_ds->size(), node_type.string(),
|
||||
[&] () { _evaluate_node(output, xml); });
|
||||
_xml_output_len = xml.used();
|
||||
},
|
||||
[&] () {
|
||||
Genode::log("UPGRADING XML DATASPACE");
|
||||
_xml_ds.construct(_env.ram(), _env.rm(), _xml_ds->size() + UPGRADE);
|
||||
},
|
||||
NUM_ATTEMPTS);
|
||||
|
||||
} catch (Xml_node::Nonexistent_sub_node) { }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user