mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-02 15:36:41 -05:00
Properly close inbound when no payload
This commit is contained in:
parent
8a83a0b30e
commit
d9b59133cc
@ -191,14 +191,13 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
|
|||||||
session.EncodeResponseHeader(response, writer)
|
session.EncodeResponseHeader(response, writer)
|
||||||
|
|
||||||
bodyWriter := session.EncodeResponseBody(writer)
|
bodyWriter := session.EncodeResponseBody(writer)
|
||||||
|
|
||||||
// Optimize for small response packet
|
|
||||||
if data, err := output.Read(); err == nil {
|
|
||||||
var v2writer v2io.Writer = v2io.NewAdaptiveWriter(bodyWriter)
|
var v2writer v2io.Writer = v2io.NewAdaptiveWriter(bodyWriter)
|
||||||
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
||||||
v2writer = vmessio.NewAuthChunkWriter(v2writer)
|
v2writer = vmessio.NewAuthChunkWriter(v2writer)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimize for small response packet
|
||||||
|
if data, err := output.Read(); err == nil {
|
||||||
if err := v2writer.Write(data); err != nil {
|
if err := v2writer.Write(data); err != nil {
|
||||||
connection.SetReusable(false)
|
connection.SetReusable(false)
|
||||||
}
|
}
|
||||||
@ -210,6 +209,7 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
|
|||||||
connection.SetReusable(false)
|
connection.SetReusable(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
output.Release()
|
output.Release()
|
||||||
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
if request.Option.Has(protocol.RequestOptionChunkStream) {
|
||||||
if err := v2writer.Write(alloc.NewSmallBuffer().Clear()); err != nil {
|
if err := v2writer.Write(alloc.NewSmallBuffer().Clear()); err != nil {
|
||||||
@ -217,7 +217,6 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
v2writer.Release()
|
v2writer.Release()
|
||||||
}
|
|
||||||
|
|
||||||
readFinish.Lock()
|
readFinish.Lock()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user