xtaci / smux

A Stream Multiplexing Library for golang with least memory usage(TDMA)
MIT License
1.31k stars 196 forks source link

broken pipe returned when reading half closed stream #28

Open SyuTingSong opened 6 years ago

SyuTingSong commented 6 years ago

I am using smux.Stream for reading and writing in two concurrency goroutines. After all data written, the stream.Close is called for ending writing.

The method stream.Read running at the local endpoint will get an error broken pipe immediately. Reading at the remote endpoint will get io.EOF as expected. Even I call stream.Close when EOF reached, the local endpoint still get the broken pipe error.

I read the source code of smux. It seems that smux does not support half closing a stream. Any idea to avoid the broken pipe issue?

cs8425 commented 5 years ago

Maybe you can take a look of my branch : https://github.com/cs8425/smux/tree/implement-half-close I implement half-close feature but not fully tested if there were data racing.

dotqi commented 5 years ago

也许你可以看看我的分支:https//github.com/cs8425/smux/tree/implement-half-close 我实现半关闭功能,但如果有数据竞争则没有完全测试。

你都改写了什么功能?最近也在用这个包,发现有Read Stream Error broken pipe 错误,不知道如何发生的。

cs8425 commented 5 years ago

@dotqi Read Stream回傳broken pipe的原因有很多 有正常的被close也有因為缺陷造成的不正常close 麻煩給更詳細資料 最好是簡單的demo code可以複現問題 至於我改了什麼功能請到PR https://github.com/xtaci/smux/pull/47#issuecomment-471889073