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

Concurrency. Corrupted data issues #22

Closed NailxSharipov closed 4 years ago

NailxSharipov commented 4 years ago

It's not safe to read and write memory at the same time. If it's happened it's end like a crash.

In functions 'waitForReply' and 'waitForConnect' we have two closures which run on difference threads. And we have an unsafe operations with variable 'groupLeft'. In other hand for variable 'group' it's ok case it threads safe class. Sadly but we don't have any atomic variables in swift to make our work easy, so we must add here 'NSLock' or just simple jump in 'timeoutTask' to 'syncQueue'.

NailxSharipov commented 4 years ago

There is no problem cause both run on syncQueue. My fault. But it still has some moment on which I am thinking on