Skip to content

Commit

Permalink
Use higher stack size for archive read generator
Browse files Browse the repository at this point in the history
Libarchive may use more space than D fibers give by default, so we just
increase the fiber stack size and hope that this will not cause any
trouble later when we are reading a lot of archives in parallel.

Resolves: #101
  • Loading branch information
ximion committed Mar 27, 2022
1 parent c946f6a commit c5d28f2
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/asgen/zarchive.d
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,17 @@ public:
import core.sys.posix.sys.stat;
import std.path;

// we set a high fiber stack size, because having a lower size
// may make functions crash that need a bigger stack (and libarchive
// might do that). See https://github.com/ximion/appstream-generator/issues/101
const size_t fiberStackSize = 65536;

auto gen = new Generator!ArchiveEntry (
{
archive_entry *en;

auto ar = openArchive ();
scope (exit) archive_read_free (ar);

archive_entry *en;
while (archive_read_next_header (ar, &en) == ARCHIVE_OK) {
auto pathname = fromStringz (archive_entry_pathname (en));

Expand Down Expand Up @@ -436,7 +440,7 @@ public:
aentry.data = this.readEntry (ar);
yield (aentry);
}
});
}, fiberStackSize);

return gen;
}
Expand Down

0 comments on commit c5d28f2

Please sign in to comment.