Skip to content

Commit

Permalink
fix concurrent async (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntVil authored Dec 8, 2023
1 parent f08b1a6 commit e7b1b81
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Sources/ClickHouseVapor/Application+ClickHouseNIO.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,13 @@ extension Application {
}

internal var pool: EventLoopGroupConnectionPool<ClickHouseConfiguration> {
let lock = self.application.locks.lock(for: PoolKey.self)
lock.lock()
defer { lock.unlock() }

if let existing = self.application.storage[PoolKey.self] {
return existing
} else {
let lock = self.application.locks.lock(for: PoolKey.self)
lock.lock()
defer { lock.unlock() }
guard let configuration = self.configuration else {
fatalError("ClickHouse not configured. Use app.clickHouse.configuration = ...")
}
Expand Down

0 comments on commit e7b1b81

Please sign in to comment.