Properly close inbound when no payload

pull/170/head
v2ray 9 years ago
parent 8a83a0b30e
commit d9b59133cc

@ -191,14 +191,13 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
session.EncodeResponseHeader(response, writer)
bodyWriter := session.EncodeResponseBody(writer)
var v2writer v2io.Writer = v2io.NewAdaptiveWriter(bodyWriter)
if request.Option.Has(protocol.RequestOptionChunkStream) {
v2writer = vmessio.NewAuthChunkWriter(v2writer)
}
// Optimize for small response packet
if data, err := output.Read(); err == nil {
var v2writer v2io.Writer = v2io.NewAdaptiveWriter(bodyWriter)
if request.Option.Has(protocol.RequestOptionChunkStream) {
v2writer = vmessio.NewAuthChunkWriter(v2writer)
}
if err := v2writer.Write(data); err != nil {
connection.SetReusable(false)
}
@ -210,14 +209,14 @@ func (this *VMessInboundHandler) HandleConnection(connection *hub.Connection) {
connection.SetReusable(false)
}
output.Release()
if request.Option.Has(protocol.RequestOptionChunkStream) {
if err := v2writer.Write(alloc.NewSmallBuffer().Clear()); err != nil {
connection.SetReusable(false)
}
}
output.Release()
if request.Option.Has(protocol.RequestOptionChunkStream) {
if err := v2writer.Write(alloc.NewSmallBuffer().Clear()); err != nil {
connection.SetReusable(false)
}
v2writer.Release()
}
v2writer.Release()
readFinish.Lock()
}

Loading…
Cancel
Save