Skip to content

Commit

Permalink
Fix zombie callback handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexballas committed Feb 20, 2021
1 parent e5c7cc8 commit d72510c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion httphandlers/httphandlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ func (p *TVPayload) callbackHandler(w http.ResponseWriter, req *http.Request) {
// Apparently we should ignore the first message
// On some media renderers we receive a STOPPED message
// even before we start streaming.
if soapcalls.GetSequence(uuid) == 0 {
seq, err := soapcalls.GetSequence(uuid)
if err != nil {
http.Error(w, "", 404)
return
}

if seq == 0 {
soapcalls.IncreaseSequence(uuid)
fmt.Fprintf(w, "OK\n")
return
Expand Down
8 changes: 6 additions & 2 deletions soapcalls/soapcallers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package soapcalls

import (
"bytes"
"errors"
"fmt"
"net/http"
"net/url"
Expand Down Expand Up @@ -301,6 +302,9 @@ func IncreaseSequence(uuid string) {
}

// GetSequence .
func GetSequence(uuid string) int {
return mediaRenderersStates[uuid].sequence
func GetSequence(uuid string) (int, error) {
if initialMediaRenderersStates[uuid] == true {
return mediaRenderersStates[uuid].sequence, nil
}
return -1, errors.New("Zombie callbacks, we should ignore those")
}

0 comments on commit d72510c

Please sign in to comment.