Fix write error handling
Fixes https://github.com/anacrolix/torrent/issues/798. Prior to this fix, it looks like the writer would just keep writing chunks of the front buffer (incorrectly if there was an error), until presumably the writer would be killed by read hangup elsewhere.
This commit is contained in:
parent
48ad1a8aca
commit
fed765b2a0
|
@ -104,6 +104,9 @@ func (cn *peerConnMsgWriter) run(keepAliveTimeout time.Duration) {
|
|||
if err == nil && n != len(next) {
|
||||
panic("expected full write")
|
||||
}
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
cn.logger.WithDefaultLevel(log.Debug).Printf("error writing: %v", err)
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/anacrolix/torrent"
|
||||
)
|
||||
|
||||
func main() {
|
||||
config := torrent.NewDefaultClientConfig()
|
||||
config.DataDir = "./output"
|
||||
c, _ := torrent.NewClient(config)
|
||||
defer c.Close()
|
||||
t, _ := c.AddMagnet("magnet:?xt=urn:btih:99c82bb73505a3c0b453f9fa0e881d6e5a32a0c1&tr=https%3A%2F%2Ftorrent.ubuntu.com%2Fannounce&tr=https%3A%2F%2Fipv6.torrent.ubuntu.com%2Fannounce")
|
||||
<-t.GotInfo()
|
||||
fmt.Println("start downloading")
|
||||
t.DownloadAll()
|
||||
c.WaitAll()
|
||||
}
|
Loading…
Reference in New Issue