From 42b8dbe8716430104273fc275fc586ddcf5183b8 Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 12 Apr 2016 21:56:36 +0200 Subject: [PATCH] release all readers and writers --- proxy/socks/socks.go | 2 ++ proxy/vmess/outbound/outbound.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/proxy/socks/socks.go b/proxy/socks/socks.go index 40c97e2ad..933cb1bc5 100644 --- a/proxy/socks/socks.go +++ b/proxy/socks/socks.go @@ -95,8 +95,10 @@ func (this *SocksServer) handleConnection(connection *hub.TCPConn) { timedReader := v2net.NewTimeOutReader(120, connection) reader := v2io.NewBufferedReader(timedReader) + defer reader.Release() writer := v2io.NewBufferedWriter(connection) + defer writer.Release() auth, auth4, err := protocol.ReadAuthentication(reader) if err != nil && err != protocol.Socks4Downgrade { diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index c9f6abc03..c0e92b442 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -90,6 +90,7 @@ func (this *VMessOutboundHandler) handleRequest(session *raw.ClientSession, conn defer finish.Unlock() writer := v2io.NewBufferedWriter(conn) + defer writer.Release() session.EncodeRequestHeader(request, writer) // Send first packet of payload together with request, in favor of small requests. @@ -131,6 +132,7 @@ func (this *VMessOutboundHandler) handleResponse(session *raw.ClientSession, con defer close(output) reader := v2io.NewBufferedReader(conn) + defer reader.Release() header, err := session.DecodeResponseHeader(reader) if err != nil {