Open ovalseven8 opened 5 years ago
Thanks, this should do the trick for now.
Oh je, die Synchronized-Seuche... :crying_cat_face:
Oh je, die Synchronized-Seuche... :crying_cat_face:
Yeah, it's not perfect. However, after looking at the code other solutions would result in major refactorings, especially in the Signaling
class and encapsulation of the websocket handling. At least, I could not find another way...
So, for the time being, this should at least improve the current situation. As there is a public API, some synchronized
blocks are needed nonetheless. Another way would be more of a actor-like approach (see Akka), what means a complete restructure of the code.
I think we need to carefully investigate and ensure this doesn't deadlock anything in Threema.
What is it with you closing PRs? :wink:
Before that change, the handler methods for the WebSocket library were synchronized on the WebSocketAdapter while other methods in Signaling class were synchronized on the class itself.
Also, the public SaltyRTC API is also synchronized on the Signaling class now. With this change, the WebSocket library and the public API are synchronized on the same class which should guarantee thread-safety.