expanding_report: make expandable for XML node generation

'generate(Xml_node node)', as used by the Sculpt manager, calls this
function instead of the lambda version. The 'report' function of the
'Genode::Reporter' does not throw an exception in case there is not
enough backing storage for the 'generate' request. Therefore, we have to
check this condition in a loop and call '_increase_report_buffer' in
case size limits are reached.

Patch by Norman Feske.

issue #4369
This commit is contained in:
Sebastian Sumpf 2022-02-14 17:57:27 +01:00 committed by Norman Feske
parent dd1596aa53
commit 300cdc435d

View File

@ -203,14 +203,18 @@ class Genode::Expanding_reporter
void generate(Xml_node node)
{
retry<Xml_generator::Buffer_exceeded>(
for (bool done = false; !done; ) {
node.with_raw_node([&] (char const *start, size_t length) {
if (length > _buffer_size)
return;
[&] () {
node.with_raw_node([&] (char const *start, size_t length) {
_reporter->report(start, length); }); },
_reporter->report(start, length);
done = true;
});
[&] () { _increase_report_buffer(); }
);
if (!done)
_increase_report_buffer();
}
}
};