Skip to content

Commit 43df969

Browse files
authored
fix concurrent async
1 parent f08b1a6 commit 43df969

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Sources/ClickHouseVapor/Application+ClickHouseNIO.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,13 @@ extension Application {
8787
}
8888

8989
internal var pool: EventLoopGroupConnectionPool<ClickHouseConfiguration> {
90+
let lock = self.application.locks.lock(for: PoolKey.self)
91+
lock.lock()
92+
defer { lock.unlock() }
93+
9094
if let existing = self.application.storage[PoolKey.self] {
9195
return existing
9296
} else {
93-
let lock = self.application.locks.lock(for: PoolKey.self)
94-
lock.lock()
95-
defer { lock.unlock() }
9697
guard let configuration = self.configuration else {
9798
fatalError("ClickHouse not configured. Use app.clickHouse.configuration = ...")
9899
}

0 commit comments

Comments
 (0)