Don't leak sendIndexes on disconnect (fixes #2589)

Adds a Closed() method on protocol.Connection and clears up
wireformatConnection a little too.
This commit is contained in:
Jakob Borg
2016-01-11 16:49:44 +01:00
parent 01c70caa8f
commit acdddc0b79
5 changed files with 32 additions and 30 deletions

View File

@@ -113,6 +113,7 @@ type Connection interface {
Request(folder string, name string, offset int64, size int, hash []byte, flags uint32, options []Option) ([]byte, error)
ClusterConfig(config ClusterConfigMessage)
Statistics() Statistics
Closed() bool
}
type rawConnection struct {
@@ -287,6 +288,15 @@ func (c *rawConnection) ClusterConfig(config ClusterConfigMessage) {
c.send(-1, messageTypeClusterConfig, config, nil)
}
func (c *rawConnection) Closed() bool {
select {
case <-c.closed:
return true
default:
return false
}
}
func (c *rawConnection) ping() bool {
var id int
select {