Skip to content

Commit

Permalink
mp4: set to 10 second timeout and remove loop
Browse files Browse the repository at this point in the history
  • Loading branch information
sonroyaalmerol committed Mar 20, 2024
1 parent e5ab2f0 commit 2fac3be
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions mp4_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}()

Expand Down

0 comments on commit 2fac3be

Please sign in to comment.