Arman92 / go-tdlib

Golang Telegram TdLib JSON bindings
GNU General Public License v3.0
437 stars 100 forks source link

Access to rawUpdates isn't synchronized #6

Open kostanovych opened 6 years ago

kostanovych commented 6 years ago

rawUpdates can be accessed from multiple goroutines, but it's not synchronized.

https://github.com/Arman92/go-tdlib/blob/2f743ae341ab7b1fc6a43de1625ba76b46fdebf1/tdlib.go#L109-L112

https://github.com/Arman92/go-tdlib/blob/2f743ae341ab7b1fc6a43de1625ba76b46fdebf1/tdlib.go#L161-L164

Should use lock for it. Here's related question on Stack Overflow. Also, looks like it's possible to miss some updates, if GetRawUpdatesChannel was called with some delay.

Arman92 commented 6 years ago

You're correct, also if GetRawUpdatesChannel get's called twice, the first channel will be lost.

I'll fix this as soon as I got the time.