fix: h2 close panic
This commit is contained in:
parent
f100ce6a04
commit
47df97322d
1 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
||||||
package vmess
|
package vmess
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
"io"
|
"io"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
@ -84,10 +85,16 @@ func (hc *h2Conn) Write(b []byte) (int, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hc *h2Conn) Close() error {
|
func (hc *h2Conn) Close() error {
|
||||||
|
if hc.pwriter != nil {
|
||||||
if err := hc.pwriter.Close(); err != nil {
|
if err := hc.pwriter.Close(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := hc.ClientConn.Shutdown(hc.res.Request.Context()); err != nil {
|
}
|
||||||
|
ctx := context.Background()
|
||||||
|
if hc.res != nil {
|
||||||
|
ctx = hc.res.Request.Context()
|
||||||
|
}
|
||||||
|
if err := hc.ClientConn.Shutdown(ctx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return hc.Conn.Close()
|
return hc.Conn.Close()
|
||||||
|
|
Loading…
Reference in a new issue