From cab5c10fc2d510296fa1c88d336067b3ca7d15bb Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 7 Nov 2017 22:31:47 +0100 Subject: [PATCH] remove use of KeepAlive --- app/proxyman/mux/writer.go | 12 ++++-------- proxy/dokodemo/dokodemo.go | 3 --- proxy/freedom/freedom.go | 3 --- proxy/http/server.go | 3 --- proxy/shadowsocks/client.go | 3 --- proxy/shadowsocks/server.go | 3 --- proxy/socks/client.go | 3 --- proxy/socks/server.go | 3 --- proxy/vmess/inbound/inbound.go | 3 --- proxy/vmess/outbound/outbound.go | 2 -- 10 files changed, 4 insertions(+), 34 deletions(-) diff --git a/app/proxyman/mux/writer.go b/app/proxyman/mux/writer.go index 095898d29..cee325e81 100644 --- a/app/proxyman/mux/writer.go +++ b/app/proxyman/mux/writer.go @@ -1,8 +1,7 @@ package mux import ( - "runtime" - + "v2ray.com/core/common" "v2ray.com/core/common/buf" "v2ray.com/core/common/net" "v2ray.com/core/common/protocol" @@ -54,10 +53,9 @@ func (w *Writer) getNextFrameMeta() FrameMetadata { func (w *Writer) writeMetaOnly() error { meta := w.getNextFrameMeta() b := buf.New() - if err := b.AppendSupplier(meta.AsSupplier()); err != nil { + if err := b.Reset(meta.AsSupplier()); err != nil { return err } - runtime.KeepAlive(meta) return w.writer.Write(buf.NewMultiBufferValue(b)) } @@ -66,10 +64,9 @@ func (w *Writer) writeData(mb buf.MultiBuffer) error { meta.Option.Set(OptionData) frame := buf.New() - if err := frame.AppendSupplier(meta.AsSupplier()); err != nil { + if err := frame.Reset(meta.AsSupplier()); err != nil { return err } - runtime.KeepAlive(meta) if err := frame.AppendSupplier(serial.WriteUint16(uint16(mb.Len()))); err != nil { return err } @@ -110,8 +107,7 @@ func (w *Writer) Close() { } frame := buf.New() - frame.AppendSupplier(meta.AsSupplier()) - runtime.KeepAlive(meta) + common.Must(frame.Reset(meta.AsSupplier())) w.writer.Write(buf.NewMultiBufferValue(frame)) } diff --git a/proxy/dokodemo/dokodemo.go b/proxy/dokodemo/dokodemo.go index 0c4136d3b..62a313959 100644 --- a/proxy/dokodemo/dokodemo.go +++ b/proxy/dokodemo/dokodemo.go @@ -4,7 +4,6 @@ package dokodemo import ( "context" - "runtime" "time" "v2ray.com/core/app" @@ -117,8 +116,6 @@ func (d *DokodemoDoor) Process(ctx context.Context, network net.Network, conn in return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/freedom/freedom.go b/proxy/freedom/freedom.go index 7df958b7d..bc5644c77 100644 --- a/proxy/freedom/freedom.go +++ b/proxy/freedom/freedom.go @@ -4,7 +4,6 @@ package freedom import ( "context" - "runtime" "time" "v2ray.com/core/app" @@ -139,8 +138,6 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/http/server.go b/proxy/http/server.go index 746ef204c..9c3f06af3 100644 --- a/proxy/http/server.go +++ b/proxy/http/server.go @@ -6,7 +6,6 @@ import ( "encoding/base64" "io" "net/http" - "runtime" "strconv" "strings" "time" @@ -185,8 +184,6 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/shadowsocks/client.go b/proxy/shadowsocks/client.go index 8177fa08d..0470b646b 100644 --- a/proxy/shadowsocks/client.go +++ b/proxy/shadowsocks/client.go @@ -2,7 +2,6 @@ package shadowsocks import ( "context" - "runtime" "time" "v2ray.com/core/app/log" @@ -168,8 +167,6 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale return nil } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/shadowsocks/server.go b/proxy/shadowsocks/server.go index 509291dc3..be28b5dd3 100644 --- a/proxy/shadowsocks/server.go +++ b/proxy/shadowsocks/server.go @@ -2,7 +2,6 @@ package shadowsocks import ( "context" - "runtime" "time" "v2ray.com/core/app" @@ -197,8 +196,6 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection, return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/socks/client.go b/proxy/socks/client.go index e227e3b28..49226273a 100644 --- a/proxy/socks/client.go +++ b/proxy/socks/client.go @@ -2,7 +2,6 @@ package socks import ( "context" - "runtime" "time" "v2ray.com/core/common" @@ -118,8 +117,6 @@ func (c *Client) Process(ctx context.Context, ray ray.OutboundRay, dialer proxy. return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/socks/server.go b/proxy/socks/server.go index 8bb2eeda9..defa77916 100644 --- a/proxy/socks/server.go +++ b/proxy/socks/server.go @@ -3,7 +3,6 @@ package socks import ( "context" "io" - "runtime" "time" "v2ray.com/core/app" @@ -143,8 +142,6 @@ func (v *Server) transport(ctx context.Context, reader io.Reader, writer io.Writ return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/vmess/inbound/inbound.go b/proxy/vmess/inbound/inbound.go index 9cc3c2753..877e51ea2 100644 --- a/proxy/vmess/inbound/inbound.go +++ b/proxy/vmess/inbound/inbound.go @@ -5,7 +5,6 @@ package inbound import ( "context" "io" - "runtime" "sync" "time" @@ -236,8 +235,6 @@ func (v *Handler) Process(ctx context.Context, network net.Network, connection i return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) - return nil } diff --git a/proxy/vmess/outbound/outbound.go b/proxy/vmess/outbound/outbound.go index 62e33149b..3e395254d 100644 --- a/proxy/vmess/outbound/outbound.go +++ b/proxy/vmess/outbound/outbound.go @@ -4,7 +4,6 @@ package outbound import ( "context" - "runtime" "time" "v2ray.com/core/app" @@ -162,7 +161,6 @@ func (v *Handler) Process(ctx context.Context, outboundRay ray.OutboundRay, dial if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil { return newError("connection ends").Base(err) } - runtime.KeepAlive(timer) return nil }