From 2fac3be01011a80a846a2f88753751956e1bd55e Mon Sep 17 00:00:00 2001 From: Son Roy Almerol Date: Tue, 19 Mar 2024 20:37:49 -0400 Subject: [PATCH] mp4: set to 10 second timeout and remove loop --- mp4_handler.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/mp4_handler.go b/mp4_handler.go index 9a845a5f..f88615f8 100644 --- a/mp4_handler.go +++ b/mp4_handler.go @@ -150,7 +150,7 @@ func mp4Handler(w http.ResponseWriter, r *http.Request, db *database.Instance) { log.Printf("Sent MP4 stream to %s\n", r.RemoteAddr) // Set initial timer duration - timerDuration := 5 * time.Second + timerDuration := 10 * time.Second timer := time.NewTimer(timerDuration) // Function to reset the timer @@ -202,15 +202,13 @@ func mp4Handler(w http.ResponseWriter, r *http.Request, db *database.Instance) { quit := make(chan bool) go func() { - for { - select { - case <-quit: - return - case <-timer.C: - log.Println("Timeout reached, closing connection.") - cancel() - return - } + select { + case <-quit: + return + case <-timer.C: + log.Println("Timeout reached, closing connection.") + cancel() + return } }()