Skip to content

Commit

Permalink
fix: edge case deadlock in ping interval
Browse files Browse the repository at this point in the history
  • Loading branch information
koraykoska committed Aug 13, 2023
1 parent 324d9ed commit c705625
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/libwebsockets/WebsocketClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,13 @@ public class WebsocketClient: WebsocketConnection {
$0?.cancel()
waitingForPong.withLockedValue { $0 = false }

self.pingAndScheduleNextTimeoutTask()
// This should not block as we would be in a deadlock
// in certain cases (if we are in the correct EventLoop).
// Hence we schedule it into the EventLoop to return immediately
// without blocking.
self.eventLoop.execute {
self.pingAndScheduleNextTimeoutTask()
}
})
} else {
scheduledPingIntervalTimeoutTask.withLockedValue {
Expand Down

0 comments on commit c705625

Please sign in to comment.