Add a empty slice notify to kick dead clients idling on dead streams.
This commit is contained in:
@@ -56,6 +56,7 @@ type UpstreamContext struct {
|
||||
|
||||
var upstreamContexts = make(map[string]*UpstreamContext)
|
||||
var upstreamContextLock = &sync.Mutex{}
|
||||
var emptySlice []byte
|
||||
|
||||
func GetUpstreamContext(name string) *UpstreamContext {
|
||||
upstreamContextLock.Lock()
|
||||
@@ -127,6 +128,8 @@ func upstreamFiber(name string) {
|
||||
fmt.Printf("Connecting to upstream for stream %s ...\n", name)
|
||||
r := (func() *http.Response {
|
||||
for {
|
||||
// Notify with an empty slice, so the client fiber could kick dead clients.
|
||||
ctx.upstreamChan <- emptySlice
|
||||
r, err := client.Do(req)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Unable to request %s for stream %s: %v\n", upstreams[name], name, err)
|
||||
|
||||
Reference in New Issue
Block a user