mirror of https://github.com/cbeuw/Cloak
Fix race condition in allocating obfsBuf
This commit is contained in:
parent
5c5e9f8c14
commit
9108794362
|
|
@ -174,9 +174,11 @@ func (s *Stream) Write(in []byte) (n int, err error) {
|
||||||
// ReadFrom continuously read data from r and send it off, until either r returns error or nothing has been read
|
// ReadFrom continuously read data from r and send it off, until either r returns error or nothing has been read
|
||||||
// for readFromTimeout amount of time
|
// for readFromTimeout amount of time
|
||||||
func (s *Stream) ReadFrom(r io.Reader) (n int64, err error) {
|
func (s *Stream) ReadFrom(r io.Reader) (n int64, err error) {
|
||||||
|
s.writingM.Lock()
|
||||||
if s.obfsBuf == nil {
|
if s.obfsBuf == nil {
|
||||||
s.obfsBuf = make([]byte, s.session.StreamSendBufferSize)
|
s.obfsBuf = make([]byte, s.session.StreamSendBufferSize)
|
||||||
}
|
}
|
||||||
|
s.writingM.Unlock()
|
||||||
for {
|
for {
|
||||||
if s.readFromTimeout != 0 {
|
if s.readFromTimeout != 0 {
|
||||||
if rder, ok := r.(net.Conn); !ok {
|
if rder, ok := r.(net.Conn); !ok {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue