centrifugal / centrifuge-swift

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

Synchronize memory access, avoid duplicate state change events #69

Closed FZambia closed 1 year ago

FZambia commented 1 year 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.