Try to cleanup clients even if the stream is dead.
Hope Gemini 3.5 Pro is not lying to me :P
This commit is contained in:
@@ -221,6 +221,11 @@ func clientHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
ch := NewClientChannel(name)
|
ch := NewClientChannel(name)
|
||||||
defer ch.Close()
|
defer ch.Close()
|
||||||
for {
|
for {
|
||||||
|
select {
|
||||||
|
case <-r.Context().Done():
|
||||||
|
fmt.Printf("Connection to client %s closed. Cleanup the channel.\n", remote)
|
||||||
|
default:
|
||||||
|
}
|
||||||
chunk := <-ch.Data
|
chunk := <-ch.Data
|
||||||
_, err := w.Write(chunk)
|
_, err := w.Write(chunk)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user