Skip to content

Commit

Permalink
Merge pull request #481 from nova-wallet/fix/connection-pool-crash
Browse files Browse the repository at this point in the history
Fix race codition in connection pool
  • Loading branch information
ERussel committed Nov 23, 2022
2 parents fe6ce29 + 022d2d5 commit dad9e69
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ extension ConnectionPool: WebSocketEngineDelegate {

extension ConnectionPool: ApplicationHandlerDelegate {
func didReceiveDidBecomeActive(notification _: Notification) {
mutex.lock()

defer {
mutex.unlock()
}

connections.values.forEach { wrapper in
guard let connection = wrapper.target as? ChainConnection else {
return
Expand All @@ -145,6 +151,12 @@ extension ConnectionPool: ApplicationHandlerDelegate {
}

func didReceiveDidEnterBackground(notification _: Notification) {
mutex.lock()

defer {
mutex.unlock()
}

connections.values.forEach { wrapper in
guard let connection = wrapper.target as? ChainConnection else {
return
Expand Down

0 comments on commit dad9e69

Please sign in to comment.