util/HugeAllocator: move MADV_DONTFORK setting to HugeForkCow()

Enforcing MADV_DONTFORK is a surprising limitation for this library
which aims to be generic.
This commit is contained in:
Max Kellermann
2017-09-19 19:52:02 +02:00
parent f6691579de
commit 8753e558f2
5 changed files with 38 additions and 7 deletions

View File

@@ -38,7 +38,10 @@ AsyncInputStream::AsyncInputStream(EventLoop &event_loop, const char *_url,
deferred_seek(event_loop, BIND_THIS_METHOD(DeferredSeek)),
allocation(_buffer_size),
buffer((uint8_t *)allocation.get(), _buffer_size),
resume_at(_resume_at) {}
resume_at(_resume_at)
{
allocation.ForkCow(false);
}
AsyncInputStream::~AsyncInputStream()
{

View File

@@ -53,6 +53,8 @@ ThreadInputStream::Start()
void *p = HugeAllocate(buffer_size);
assert(p != nullptr);
HugeForkCow(p, buffer_size, false);
buffer = new CircularBuffer<uint8_t>((uint8_t *)p, buffer_size);
thread.Start();
}