Properly disconnect clients
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
DataHoarder 2022-03-02 20:26:48 +01:00
parent bf54e459b6
commit b1a290e7d0
2 changed files with 6 additions and 3 deletions

View file

@ -220,7 +220,6 @@ func (m *StreamMount) Process(group *sync.WaitGroup) {
}
if l.Write(packet) != nil {
toRemove = append(toRemove, i)
l.Close()
}
}
@ -228,7 +227,9 @@ func (m *StreamMount) Process(group *sync.WaitGroup) {
m.listenersLock.Lock()
//TODO: remove more than one per iteration
for _, i := range toRemove {
l := m.listeners[i]
m.listeners = append(m.listeners[:i], m.listeners[i+1:]...)
l.Close()
break
}
m.listenersLock.Unlock()

View file

@ -8,6 +8,7 @@ import (
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/opus"
"git.gammaspectra.live/S.O.N.G/Kirika/audio/format/tta"
"git.gammaspectra.live/S.O.N.G/Kirika/audio/packetizer"
"io"
"log"
"net/http"
"os"
@ -230,12 +231,13 @@ type httpWriter struct {
func (h *httpWriter) Write(p []byte) (n int, err error) {
if h.writer != nil {
_, err = h.writer.Write(p)
n, err = h.writer.Write(p)
if err != nil {
h.writer = nil
}
return
}
return len(p), nil
return 0, io.EOF
}
func (h *httpWriter) Close() (err error) {