centrifugal / centrifuge-swift

Swift client SDK for bidirectional real-time communication with Centrifugo and Centrifuge-based server over WebSocket
MIT License
49 stars 44 forks source link

Synchronize memory access, avoid duplicate state change events #69

Closed FZambia closed 2 years ago

FZambia commented 2 years ago

Relates #68

I was able to reproduce several crashes due to non synchronized memory access by stressing out some SDK paths - connecting, disconnecting, and having no-ping timer event in parallel. Using sync queue for processDisconnect call inside no ping timer callback crashes gone away.

Still possible that the root cause in #68 is different, but hopefully that was caused by missing synchronization of disconnect processing inside no ping handler.

Also fixing issuing duplicate events here – i.e. if SDK emitted connecting event, it must not emit it again while in connecting state.