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