Skip to content

Commit c3fb848

Browse files
tulirdevlikepro
authored andcommitted
message: automatically stop history sync loop
(cherry picked from commit ad53517)
1 parent e671d5b commit c3fb848

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

message.go

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -674,12 +674,17 @@ func (cli *Client) handleHistorySyncNotificationLoop() {
674674
}
675675
}()
676676
ctx := cli.BackgroundEventCtx
677-
for notif := range cli.historySyncNotifications {
678-
blob, err := cli.DownloadHistorySync(ctx, notif, false)
679-
if err != nil {
680-
cli.Log.Errorf("Failed to download history sync: %v", err)
681-
} else {
682-
cli.dispatchEvent(&events.HistorySync{Data: blob})
677+
for {
678+
select {
679+
case notif := <-cli.historySyncNotifications:
680+
blob, err := cli.DownloadHistorySync(ctx, notif, false)
681+
if err != nil {
682+
cli.Log.Errorf("Failed to download history sync: %v", err)
683+
} else {
684+
cli.dispatchEvent(&events.HistorySync{Data: blob})
685+
}
686+
case <-time.After(1 * time.Minute):
687+
return
683688
}
684689
}
685690
}

0 commit comments

Comments
 (0)