lib/connections: Trigger dialer when connection gets closed (#7753)
This commit is contained in:
@@ -224,7 +224,7 @@ func (e encryptedConnection) Close(err error) {
|
||||
e.conn.Close(err)
|
||||
}
|
||||
|
||||
func (e encryptedConnection) Closed() bool {
|
||||
func (e encryptedConnection) Closed() <-chan struct{} {
|
||||
return e.conn.Closed()
|
||||
}
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@ type Connection struct {
|
||||
closeArgsForCall []struct {
|
||||
arg1 error
|
||||
}
|
||||
ClosedStub func() bool
|
||||
ClosedStub func() <-chan struct{}
|
||||
closedMutex sync.RWMutex
|
||||
closedArgsForCall []struct {
|
||||
}
|
||||
closedReturns struct {
|
||||
result1 bool
|
||||
result1 <-chan struct{}
|
||||
}
|
||||
closedReturnsOnCall map[int]struct {
|
||||
result1 bool
|
||||
result1 <-chan struct{}
|
||||
}
|
||||
ClusterConfigStub func(protocol.ClusterConfig)
|
||||
clusterConfigMutex sync.RWMutex
|
||||
@@ -220,7 +220,7 @@ func (fake *Connection) CloseArgsForCall(i int) error {
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *Connection) Closed() bool {
|
||||
func (fake *Connection) Closed() <-chan struct{} {
|
||||
fake.closedMutex.Lock()
|
||||
ret, specificReturn := fake.closedReturnsOnCall[len(fake.closedArgsForCall)]
|
||||
fake.closedArgsForCall = append(fake.closedArgsForCall, struct {
|
||||
@@ -244,32 +244,32 @@ func (fake *Connection) ClosedCallCount() int {
|
||||
return len(fake.closedArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Connection) ClosedCalls(stub func() bool) {
|
||||
func (fake *Connection) ClosedCalls(stub func() <-chan struct{}) {
|
||||
fake.closedMutex.Lock()
|
||||
defer fake.closedMutex.Unlock()
|
||||
fake.ClosedStub = stub
|
||||
}
|
||||
|
||||
func (fake *Connection) ClosedReturns(result1 bool) {
|
||||
func (fake *Connection) ClosedReturns(result1 <-chan struct{}) {
|
||||
fake.closedMutex.Lock()
|
||||
defer fake.closedMutex.Unlock()
|
||||
fake.ClosedStub = nil
|
||||
fake.closedReturns = struct {
|
||||
result1 bool
|
||||
result1 <-chan struct{}
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Connection) ClosedReturnsOnCall(i int, result1 bool) {
|
||||
func (fake *Connection) ClosedReturnsOnCall(i int, result1 <-chan struct{}) {
|
||||
fake.closedMutex.Lock()
|
||||
defer fake.closedMutex.Unlock()
|
||||
fake.ClosedStub = nil
|
||||
if fake.closedReturnsOnCall == nil {
|
||||
fake.closedReturnsOnCall = make(map[int]struct {
|
||||
result1 bool
|
||||
result1 <-chan struct{}
|
||||
})
|
||||
}
|
||||
fake.closedReturnsOnCall[i] = struct {
|
||||
result1 bool
|
||||
result1 <-chan struct{}
|
||||
}{result1}
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ type Connection interface {
|
||||
ClusterConfig(config ClusterConfig)
|
||||
DownloadProgress(ctx context.Context, folder string, updates []FileDownloadProgressUpdate)
|
||||
Statistics() Statistics
|
||||
Closed() bool
|
||||
Closed() <-chan struct{}
|
||||
ConnectionInfo
|
||||
}
|
||||
|
||||
@@ -380,13 +380,8 @@ func (c *rawConnection) ClusterConfig(config ClusterConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *rawConnection) Closed() bool {
|
||||
select {
|
||||
case <-c.closed:
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
func (c *rawConnection) Closed() <-chan struct{} {
|
||||
return c.closed
|
||||
}
|
||||
|
||||
// DownloadProgress sends the progress updates for the files that are currently being downloaded.
|
||||
|
||||
Reference in New Issue
Block a user