Skip to content

Commit 5eeb82c

Browse files
authored
Merge pull request #5533 from cloudflare/jasnell/lazy-tmpdirstorescope
2 parents 9fe0282 + 0191fa3 commit 5eeb82c

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/workerd/io/io-context.c++

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ IoContext::IoContext(ThreadContext& thread,
149149
kj::Maybe<Worker::Actor&> actorParam,
150150
kj::Own<LimitEnforcer> limitEnforcerParam)
151151
: thread(thread),
152-
tmpDirStoreScope(TmpDirStoreScope::create()),
153152
worker(kj::mv(workerParam)),
154153
actor(actorParam),
155154
limitEnforcer(kj::mv(limitEnforcerParam)),

src/workerd/io/io-context.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,10 @@ class IoContext final: public kj::Refcounted, private kj::TaskSet::ErrorHandler
729729
kj::Date now();
730730

731731
TmpDirStoreScope& getTmpDirStoreScope() {
732-
return *tmpDirStoreScope;
732+
KJ_IF_SOME(scope, tmpDirStoreScope) {
733+
return *scope;
734+
}
735+
return *tmpDirStoreScope.emplace(TmpDirStoreScope::create());
733736
}
734737

735738
// Returns a promise that resolves once `now() >= when`.
@@ -975,7 +978,7 @@ class IoContext final: public kj::Refcounted, private kj::TaskSet::ErrorHandler
975978

976979
kj::Own<WeakRef> selfRef = kj::refcounted<WeakRef>(kj::Badge<IoContext>(), *this);
977980

978-
kj::Own<TmpDirStoreScope> tmpDirStoreScope;
981+
kj::Maybe<kj::Own<TmpDirStoreScope>> tmpDirStoreScope;
979982

980983
kj::Own<const Worker> worker;
981984
kj::Maybe<Worker::Actor&> actor;

0 commit comments

Comments
 (0)