Synchronous perform-join as long as possible

This commit is contained in:
Neil Alexander 2020-09-22 09:56:58 +01:00
parent a3e401e5dd
commit b5d5907d69
No known key found for this signature in database
GPG key ID: A02A2019A2BB0944

View file

@ -186,8 +186,15 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
} }
r.statistics.ForServer(serverName).Success() r.statistics.ForServer(serverName).Success()
// Process the join response in a goroutine. The idea here is
// that we'll try and wait for as long as possible for the work
// to complete, but if the client does give up waiting, we'll
// still continue to process the join anyway so that we don't
// waste the effort.
var cancel context.CancelFunc
ctx, cancel = context.WithCancel(context.Background())
go func() { go func() {
ctx = context.Background() defer cancel()
// Check that the send_join response was valid. // Check that the send_join response was valid.
joinCtx := perform.JoinContext(r.federation, r.keyRing) joinCtx := perform.JoinContext(r.federation, r.keyRing)
@ -219,6 +226,7 @@ func (r *FederationSenderInternalAPI) performJoinUsingServer(
} }
}() }()
<-ctx.Done()
return nil return nil
} }