release all readers and writers

pull/120/head
v2ray 9 years ago
parent 70f803173a
commit 42b8dbe871

@ -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 {

@ -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 {

Loading…
Cancel
Save