mirror of
https://github.com/XTLS/Xray-core.git
synced 2024-11-22 20:59:19 +02:00
Add recover() to H2 server's flushWriter.Write()
Fixes https://github.com/XTLS/Xray-core/issues/1748
This commit is contained in:
parent
4a0b45d1ff
commit
836e84b851
|
@ -204,7 +204,7 @@ type WaitReadCloser struct {
|
||||||
func (w *WaitReadCloser) Set(rc io.ReadCloser) {
|
func (w *WaitReadCloser) Set(rc io.ReadCloser) {
|
||||||
w.ReadCloser = rc
|
w.ReadCloser = rc
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if recover() != nil {
|
||||||
rc.Close()
|
rc.Close()
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
@ -225,11 +225,9 @@ func (w *WaitReadCloser) Close() error {
|
||||||
return w.ReadCloser.Close()
|
return w.ReadCloser.Close()
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := recover(); err != nil {
|
if recover() != nil && w.ReadCloser != nil {
|
||||||
if w.ReadCloser != nil {
|
|
||||||
w.ReadCloser.Close()
|
w.ReadCloser.Close()
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}()
|
}()
|
||||||
close(w.Wait)
|
close(w.Wait)
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -51,6 +51,13 @@ func (fw flushWriter) Write(p []byte) (n int, err error) {
|
||||||
return 0, io.ErrClosedPipe
|
return 0, io.ErrClosedPipe
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if recover() != nil {
|
||||||
|
fw.d.Close()
|
||||||
|
err = io.ErrClosedPipe
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
n, err = fw.w.Write(p)
|
n, err = fw.w.Write(p)
|
||||||
if f, ok := fw.w.(http.Flusher); ok && err == nil {
|
if f, ok := fw.w.(http.Flusher); ok && err == nil {
|
||||||
f.Flush()
|
f.Flush()
|
||||||
|
|
Loading…
Reference in New Issue