From 3068180f8ed1ed5b56cd9357a7fbd6a81507a465 Mon Sep 17 00:00:00 2001 From: Oliver Giles Date: Mon, 31 Jul 2017 08:53:50 +0300 Subject: [PATCH] give capnp ownership of process output fd this fixes an intermittent issue (race condition?) where the IoContext attempts to poll an already-closed fd --- src/laminar.cpp | 1 - src/server.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/laminar.cpp b/src/laminar.cpp index 4909473..51847bb 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -518,7 +518,6 @@ void Laminar::reapAdvance() { std::shared_ptr run = *it; bool completed = true; activeJobs.get<0>().modify(it, [&](std::shared_ptr run){ - close(run->fd); run->reaped(ret); completed = stepRun(run); }); diff --git a/src/server.cpp b/src/server.cpp index 96d19d5..a4547af 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -389,7 +389,7 @@ void Server::stop() { } void Server::addDescriptor(int fd, std::function cb) { - auto event = this->ioContext.lowLevelProvider->wrapInputFd(fd); + auto event = this->ioContext.lowLevelProvider->wrapInputFd(fd, kj::LowLevelAsyncIoProvider::TAKE_OWNERSHIP); tasks.add(handleFdRead(event, cb).attach(std::move(event))); }