mirror of
https://github.com/caddyserver/caddy.git
synced 2026-06-07 06:25:24 -04:00
proxy: websocket proxy exits immediately if backend is shutdown (#1869)
Signed-off-by: Tw <tw19881113@gmail.com>
This commit is contained in:
@@ -320,8 +320,13 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
|
||||
}
|
||||
defer backendConn.Close()
|
||||
|
||||
proxyDone := make(chan struct{}, 2)
|
||||
|
||||
// Proxy backend -> frontend.
|
||||
go pooledIoCopy(conn, backendConn)
|
||||
go func() {
|
||||
pooledIoCopy(conn, backendConn)
|
||||
proxyDone <- struct{}{}
|
||||
}()
|
||||
|
||||
// Proxy frontend -> backend.
|
||||
//
|
||||
@@ -336,7 +341,13 @@ func (rp *ReverseProxy) ServeHTTP(rw http.ResponseWriter, outreq *http.Request,
|
||||
backendConn.Write(rbuf)
|
||||
}
|
||||
}
|
||||
pooledIoCopy(backendConn, conn)
|
||||
go func() {
|
||||
pooledIoCopy(backendConn, conn)
|
||||
proxyDone <- struct{}{}
|
||||
}()
|
||||
|
||||
// If one side is done, we are done.
|
||||
<-proxyDone
|
||||
} else {
|
||||
// NOTE:
|
||||
// Closing the Body involves acquiring a mutex, which is a
|
||||
|
||||
Reference in New Issue
Block a user