Revert "Revert "client: unblock connect without network""
This reverts commit ea4626107c.
Adds waiting support for initial connection established to avoid locking
up gotd. This isn't extremely pretty but should do the job for now.
This commit is contained in:
@@ -218,6 +218,19 @@ func parseRandomID(txnID networkid.RawTransactionID) int64 {
|
||||
}
|
||||
|
||||
func (t *TelegramClient) HandleMatrixMessage(ctx context.Context, msg *bridgev2.MatrixMessage) (resp *bridgev2.MatrixMessageResponse, err error) {
|
||||
// Handle Matrix events only after initial connection has been established to avoid deadlocking gotd
|
||||
select {
|
||||
case <-t.initialized:
|
||||
default:
|
||||
zerolog.Ctx(ctx).Warn().Msg("Got Matrix event before connected, blocking until done")
|
||||
|
||||
select {
|
||||
case <-t.initialized:
|
||||
case <-ctx.Done():
|
||||
return nil, ctx.Err()
|
||||
}
|
||||
}
|
||||
|
||||
peer, err := t.inputPeerForPortalID(ctx, msg.Portal.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user