From 51bf1778c5ab51720ad642a51bc1c232b7be6ffd Mon Sep 17 00:00:00 2001 From: esrrhs Date: Sat, 26 Oct 2019 21:00:15 +0800 Subject: [PATCH] add --- cmd/main.go | 2 +- framemgr.go | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index c19998f..de2a86c 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -72,7 +72,7 @@ func main() { return } if *tcpmode_maxwin*10 > pingtunnel.FRAME_MAX_ID { - fmt.Println("set tcp win to big max = " + strconv.Itoa(pingtunnel.FRAME_MAX_ID/10)) + fmt.Println("set tcp win to big, max = " + strconv.Itoa(pingtunnel.FRAME_MAX_ID/10)) return } diff --git a/framemgr.go b/framemgr.go index 8ecae8f..8103019 100644 --- a/framemgr.go +++ b/framemgr.go @@ -207,19 +207,22 @@ func (fm *FrameMgr) processRecvList(tmpreq map[int32]int, tmpack map[int32]int, } if len(tmpackto) > 0 { - f := &Frame{Type: (int32)(Frame_ACK), Resend: false, Sendtime: 0, - Id: 0, - Dataid: make([]int32, len(tmpackto))} + tmp := make([]int32, len(tmpackto)) index := 0 for id, rf := range tmpackto { if fm.addToRecvWin(rf) { - f.Dataid[index] = id + tmp[index] = id index++ loggo.Debug("add data to win %d %d", rf.Id, len(rf.Data)) } } - fm.sendlist.PushBack(f) - loggo.Debug("send ack %d %s", f.Id, common.Int32ArrayToString(f.Dataid, ",")) + if index > 0 { + f := &Frame{Type: (int32)(Frame_ACK), Resend: false, Sendtime: 0, + Id: 0, + Dataid: tmp[0:index]} + fm.sendlist.PushBack(f) + loggo.Debug("send ack %d %s", f.Id, common.Int32ArrayToString(f.Dataid, ",")) + } } } @@ -267,13 +270,11 @@ func (fm *FrameMgr) compareId(l int, r int) int { func (fm *FrameMgr) combineWindowToRecvBuffer() { - id := fm.recvid - for { done := false for e := fm.recvwin.Front(); e != nil; e = e.Next() { f := e.Value.(*Frame) - if f.Id == (int32)(id) { + if f.Id == (int32)(fm.recvid) { left := fm.recvb.Capacity() - fm.recvb.Size() if left >= len(f.Data) { if len(f.Data) == 0 { @@ -301,7 +302,7 @@ func (fm *FrameMgr) combineWindowToRecvBuffer() { reqtmp := make(map[int]int) e := fm.recvwin.Front() - id = fm.recvid + id := fm.recvid for len(reqtmp) < fm.windowsize && len(reqtmp)*4 < FRAME_MAX_SIZE/2 && e != nil { f := e.Value.(*Frame) loggo.Debug("start add req id %d %d %d", fm.recvid, f.Id, id)