Skip to content
This repository has been archived by the owner on Apr 9, 2020. It is now read-only.

Read/Write on shadowsocks/conn should be thread safe #459

Open
dunjut opened this issue Jan 2, 2019 · 2 comments
Open

Read/Write on shadowsocks/conn should be thread safe #459

dunjut opened this issue Jan 2, 2019 · 2 comments

Comments

@dunjut
Copy link

dunjut commented Jan 2, 2019

GoDoc on net.Conn says Multiple goroutines may invoke methods on a Conn simultaneously.

shadowsocks/conn doesn't follow the thread-safe assumption, this may break some code in future use.

@arthurkiller
Copy link
Collaborator

I did not understand what's wrong.

@dunjut
Copy link
Author

dunjut commented Jan 3, 2019

When multiple goroutines invoke Read/Write simultaneously, there will be race conditions loading/assigning on Cipher, readBuf and writeBuf. There's no any lock mechanism protecting this.

It wouldn't cause any problems so far because shadowsocks seems not using Conn anywhere in concurrent context.

I'm just suggesting that Conn should eventually be thread-safe because that's how a net.Conn interface behaves.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants