summaryrefslogtreecommitdiff
path: root/recording
diff options
context:
space:
mode:
authorKeuin <[email protected]>2022-09-12 03:36:53 +0800
committerKeuin <[email protected]>2022-09-12 03:36:53 +0800
commitdd34e58db1ea07e5bb3598eb57ae064e852957bf (patch)
tree36b3861eda872ab042d8b22e5f941264237e9221 /recording
parentdc044914ac17040c8d7c2398d1a0a80b915891b0 (diff)
Bugfix: recorder won't retry if the connection was reset.
Diffstat (limited to 'recording')
-rw-r--r--recording/runner.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/recording/runner.go b/recording/runner.go
index c44a06c..3aa7d46 100644
--- a/recording/runner.go
+++ b/recording/runner.go
@@ -109,23 +109,17 @@ func tryRunTask(t *RunningTask) error {
// restart recorder if interrupted by I/O errors
for !cancelled {
cancelled, err2 = record(recorderCtx, bi, t)
- // live is closed normally, do not restart in current function
- // the watcher will wait for the next start
- if errors.Is(err2, bilibili.ErrRoomIsClosed) {
- t.logger.Info("Live is ended. Stop recording.")
- return bilibili.ErrRoomIsClosed
- }
- if errors.Is(err2, io.EOF) {
- t.logger.Warning("Live is stopped because of an EOF while reading. " +
- "This may be caused by a broken connection or a closing live. Retrying...")
+ if errors.Is(err2, io.ErrUnexpectedEOF) {
+ t.logger.Warning("Reading is interrupted because of an unexpected EOF. Retrying...")
cancelled = false
}
- if err2 != nil {
- // some other unrecoverable error
- t.logger.Error("Cannot recover from error: %v", err2)
- return err2
- }
}
+ t.logger.Error("Error when copying live stream: %v", err)
+ if err2 == nil || errors.Is(err2, bilibili.ErrRoomIsClosed) || errors.Is(err2, io.EOF) {
+ t.logger.Info("Live is ended. Stop recording.")
+ return bilibili.ErrRoomIsClosed
+ }
+ t.logger.Error("Cannot recover from unexpected error: %v", err2)
t.logger.Info("Task is cancelled. Stop recording.")
case WatcherLiveStop:
// once the live is ended, the watcher will no longer receive live start event