1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-21 17:46:58 -05:00

remove use of KeepAlive

This commit is contained in:
Darien Raymond 2017-11-07 22:31:47 +01:00
parent 7cd2d62d06
commit cab5c10fc2
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
10 changed files with 4 additions and 34 deletions

View File

@ -1,8 +1,7 @@
package mux package mux
import ( import (
"runtime" "v2ray.com/core/common"
"v2ray.com/core/common/buf" "v2ray.com/core/common/buf"
"v2ray.com/core/common/net" "v2ray.com/core/common/net"
"v2ray.com/core/common/protocol" "v2ray.com/core/common/protocol"
@ -54,10 +53,9 @@ func (w *Writer) getNextFrameMeta() FrameMetadata {
func (w *Writer) writeMetaOnly() error { func (w *Writer) writeMetaOnly() error {
meta := w.getNextFrameMeta() meta := w.getNextFrameMeta()
b := buf.New() b := buf.New()
if err := b.AppendSupplier(meta.AsSupplier()); err != nil { if err := b.Reset(meta.AsSupplier()); err != nil {
return err return err
} }
runtime.KeepAlive(meta)
return w.writer.Write(buf.NewMultiBufferValue(b)) return w.writer.Write(buf.NewMultiBufferValue(b))
} }
@ -66,10 +64,9 @@ func (w *Writer) writeData(mb buf.MultiBuffer) error {
meta.Option.Set(OptionData) meta.Option.Set(OptionData)
frame := buf.New() frame := buf.New()
if err := frame.AppendSupplier(meta.AsSupplier()); err != nil { if err := frame.Reset(meta.AsSupplier()); err != nil {
return err return err
} }
runtime.KeepAlive(meta)
if err := frame.AppendSupplier(serial.WriteUint16(uint16(mb.Len()))); err != nil { if err := frame.AppendSupplier(serial.WriteUint16(uint16(mb.Len()))); err != nil {
return err return err
} }
@ -110,8 +107,7 @@ func (w *Writer) Close() {
} }
frame := buf.New() frame := buf.New()
frame.AppendSupplier(meta.AsSupplier()) common.Must(frame.Reset(meta.AsSupplier()))
runtime.KeepAlive(meta)
w.writer.Write(buf.NewMultiBufferValue(frame)) w.writer.Write(buf.NewMultiBufferValue(frame))
} }

View File

@ -4,7 +4,6 @@ package dokodemo
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/app" "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) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -4,7 +4,6 @@ package freedom
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/app" "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) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -6,7 +6,6 @@ import (
"encoding/base64" "encoding/base64"
"io" "io"
"net/http" "net/http"
"runtime"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -185,8 +184,6 @@ func (s *Server) handleConnect(ctx context.Context, request *http.Request, reade
return newError("connection ends").Base(err) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -2,7 +2,6 @@ package shadowsocks
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/app/log" "v2ray.com/core/app/log"
@ -168,8 +167,6 @@ func (v *Client) Process(ctx context.Context, outboundRay ray.OutboundRay, diale
return nil return nil
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -2,7 +2,6 @@ package shadowsocks
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/app" "v2ray.com/core/app"
@ -197,8 +196,6 @@ func (s *Server) handleConnection(ctx context.Context, conn internet.Connection,
return newError("connection ends").Base(err) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -2,7 +2,6 @@ package socks
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/common" "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) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -3,7 +3,6 @@ package socks
import ( import (
"context" "context"
"io" "io"
"runtime"
"time" "time"
"v2ray.com/core/app" "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) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -5,7 +5,6 @@ package inbound
import ( import (
"context" "context"
"io" "io"
"runtime"
"sync" "sync"
"time" "time"
@ -236,8 +235,6 @@ func (v *Handler) Process(ctx context.Context, network net.Network, connection i
return newError("connection ends").Base(err) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }

View File

@ -4,7 +4,6 @@ package outbound
import ( import (
"context" "context"
"runtime"
"time" "time"
"v2ray.com/core/app" "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 { if err := signal.ErrorOrFinish2(ctx, requestDone, responseDone); err != nil {
return newError("connection ends").Base(err) return newError("connection ends").Base(err)
} }
runtime.KeepAlive(timer)
return nil return nil
} }