mirror of
https://github.com/kubenetworks/kubevpn.git
synced 2025-09-26 19:31:17 +08:00
hotfix: fix use too much memory (#710)
This commit is contained in:
@@ -36,6 +36,7 @@ func (h *gvisorLocalHandler) Run(ctx context.Context) {
|
||||
// for support ipv6 skip checksum
|
||||
// vendor/gvisor.dev/gvisor/pkg/tcpip/stack/nic.go:763
|
||||
endpoint.LinkEPCapabilities = stack.CapabilityRXChecksumOffload
|
||||
defer endpoint.Close()
|
||||
go func() {
|
||||
defer util.HandleCrash()
|
||||
readFromGvisorInboundWriteToEndpoint(ctx, h.gvisorInbound, endpoint)
|
||||
|
@@ -43,8 +43,11 @@ type ClientDevice struct {
|
||||
func (d *ClientDevice) handlePacket(ctx context.Context, forward *Forwarder) {
|
||||
for ctx.Err() == nil {
|
||||
func() {
|
||||
subCtx, cancelFunc := context.WithCancel(ctx)
|
||||
defer cancelFunc()
|
||||
|
||||
defer time.Sleep(time.Second * 2)
|
||||
conn, err := forwardConn(ctx, forward)
|
||||
conn, err := forwardConn(subCtx, forward)
|
||||
if err != nil {
|
||||
plog.G(ctx).Errorf("Failed to get remote conn from %s -> %s: %s", d.tun.LocalAddr(), forward.node.Remote, err)
|
||||
return
|
||||
@@ -52,8 +55,8 @@ func (d *ClientDevice) handlePacket(ctx context.Context, forward *Forwarder) {
|
||||
defer conn.Close()
|
||||
|
||||
errChan := make(chan error, 2)
|
||||
go readFromConn(ctx, conn, d.tunInbound, d.tunOutbound, errChan)
|
||||
go writeToConn(ctx, conn, d.tunInbound, errChan)
|
||||
go readFromConn(subCtx, conn, d.tunInbound, d.tunOutbound, errChan)
|
||||
go writeToConn(subCtx, conn, d.tunInbound, errChan)
|
||||
|
||||
select {
|
||||
case err = <-errChan:
|
||||
|
Reference in New Issue
Block a user