mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-12-22 01:57:12 -05:00
remove PingNecessary()
This commit is contained in:
parent
e49fb2f50d
commit
3fd66ad795
@ -512,7 +512,7 @@ func (this *Connection) flush() {
|
||||
this.receivingWorker.Flush(current)
|
||||
this.sendingWorker.Flush(current)
|
||||
|
||||
if this.sendingWorker.PingNecessary() || this.receivingWorker.PingNecessary() || current-atomic.LoadUint32(&this.lastPingTime) >= 3000 {
|
||||
if current-atomic.LoadUint32(&this.lastPingTime) >= 3000 {
|
||||
seg := NewCmdOnlySegment()
|
||||
seg.Conv = this.conv
|
||||
seg.Command = CommandPing
|
||||
@ -524,8 +524,6 @@ func (this *Connection) flush() {
|
||||
}
|
||||
this.output.Write(seg)
|
||||
this.lastPingTime = current
|
||||
this.sendingWorker.MarkPingNecessary(false)
|
||||
this.receivingWorker.MarkPingNecessary(false)
|
||||
seg.Release()
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,6 @@ type ReceivingWorker struct {
|
||||
leftOver *alloc.Buffer
|
||||
window *ReceivingWindow
|
||||
acklist *AckList
|
||||
updated bool
|
||||
nextNumber uint32
|
||||
windowSize uint32
|
||||
}
|
||||
@ -154,7 +153,6 @@ func (this *ReceivingWorker) ProcessSegment(seg *DataSegment) {
|
||||
if !this.window.Set(idx, seg) {
|
||||
seg.Release()
|
||||
}
|
||||
this.updated = true
|
||||
}
|
||||
|
||||
func (this *ReceivingWorker) Read(b []byte) int {
|
||||
@ -180,7 +178,6 @@ func (this *ReceivingWorker) Read(b []byte) int {
|
||||
}
|
||||
this.window.Advance()
|
||||
this.nextNumber++
|
||||
this.updated = true
|
||||
|
||||
nBytes := copy(b[total:], seg.Data.Value)
|
||||
total += nBytes
|
||||
@ -212,20 +209,7 @@ func (this *ReceivingWorker) Write(seg Segment) {
|
||||
ackSeg.Option = SegmentOptionClose
|
||||
}
|
||||
this.conn.output.Write(ackSeg)
|
||||
this.updated = false
|
||||
}
|
||||
|
||||
func (this *ReceivingWorker) CloseRead() {
|
||||
}
|
||||
|
||||
func (this *ReceivingWorker) PingNecessary() bool {
|
||||
this.RLock()
|
||||
defer this.RUnlock()
|
||||
return this.updated
|
||||
}
|
||||
|
||||
func (this *ReceivingWorker) MarkPingNecessary(b bool) {
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
this.updated = b
|
||||
}
|
||||
|
@ -178,7 +178,6 @@ type SendingWorker struct {
|
||||
remoteNextNumber uint32
|
||||
controlWindow uint32
|
||||
fastResend uint32
|
||||
updated bool
|
||||
}
|
||||
|
||||
func NewSendingWorker(kcp *Connection) *SendingWorker {
|
||||
@ -206,15 +205,11 @@ func (this *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32) {
|
||||
|
||||
// Private: Visible for testing.
|
||||
func (this *SendingWorker) FindFirstUnacknowledged() {
|
||||
prevUna := this.firstUnacknowledged
|
||||
if !this.window.IsEmpty() {
|
||||
this.firstUnacknowledged = this.window.First().Number
|
||||
} else {
|
||||
this.firstUnacknowledged = this.nextNumber
|
||||
}
|
||||
if this.firstUnacknowledged != prevUna {
|
||||
this.updated = true
|
||||
}
|
||||
}
|
||||
|
||||
// Private: Visible for testing.
|
||||
@ -293,21 +288,6 @@ func (this *SendingWorker) Write(seg Segment) {
|
||||
}
|
||||
|
||||
this.conn.output.Write(dataSeg)
|
||||
this.updated = false
|
||||
}
|
||||
|
||||
func (this *SendingWorker) PingNecessary() bool {
|
||||
this.RLock()
|
||||
defer this.RUnlock()
|
||||
|
||||
return this.updated
|
||||
}
|
||||
|
||||
func (this *SendingWorker) MarkPingNecessary(b bool) {
|
||||
this.Lock()
|
||||
defer this.Unlock()
|
||||
|
||||
this.updated = b
|
||||
}
|
||||
|
||||
func (this *SendingWorker) OnPacketLoss(lossRate uint32) {
|
||||
|
Loading…
Reference in New Issue
Block a user