1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-01 08:16:00 -04:00

remove PingNecessary()

This commit is contained in:
Darien Raymond 2016-08-25 12:00:31 +02:00
parent e49fb2f50d
commit 3fd66ad795
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
3 changed files with 1 additions and 39 deletions

View File

@ -512,7 +512,7 @@ func (this *Connection) flush() {
this.receivingWorker.Flush(current) this.receivingWorker.Flush(current)
this.sendingWorker.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 := NewCmdOnlySegment()
seg.Conv = this.conv seg.Conv = this.conv
seg.Command = CommandPing seg.Command = CommandPing
@ -524,8 +524,6 @@ func (this *Connection) flush() {
} }
this.output.Write(seg) this.output.Write(seg)
this.lastPingTime = current this.lastPingTime = current
this.sendingWorker.MarkPingNecessary(false)
this.receivingWorker.MarkPingNecessary(false)
seg.Release() seg.Release()
} }

View File

@ -117,7 +117,6 @@ type ReceivingWorker struct {
leftOver *alloc.Buffer leftOver *alloc.Buffer
window *ReceivingWindow window *ReceivingWindow
acklist *AckList acklist *AckList
updated bool
nextNumber uint32 nextNumber uint32
windowSize uint32 windowSize uint32
} }
@ -154,7 +153,6 @@ func (this *ReceivingWorker) ProcessSegment(seg *DataSegment) {
if !this.window.Set(idx, seg) { if !this.window.Set(idx, seg) {
seg.Release() seg.Release()
} }
this.updated = true
} }
func (this *ReceivingWorker) Read(b []byte) int { func (this *ReceivingWorker) Read(b []byte) int {
@ -180,7 +178,6 @@ func (this *ReceivingWorker) Read(b []byte) int {
} }
this.window.Advance() this.window.Advance()
this.nextNumber++ this.nextNumber++
this.updated = true
nBytes := copy(b[total:], seg.Data.Value) nBytes := copy(b[total:], seg.Data.Value)
total += nBytes total += nBytes
@ -212,20 +209,7 @@ func (this *ReceivingWorker) Write(seg Segment) {
ackSeg.Option = SegmentOptionClose ackSeg.Option = SegmentOptionClose
} }
this.conn.output.Write(ackSeg) this.conn.output.Write(ackSeg)
this.updated = false
} }
func (this *ReceivingWorker) CloseRead() { 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
}

View File

@ -178,7 +178,6 @@ type SendingWorker struct {
remoteNextNumber uint32 remoteNextNumber uint32
controlWindow uint32 controlWindow uint32
fastResend uint32 fastResend uint32
updated bool
} }
func NewSendingWorker(kcp *Connection) *SendingWorker { func NewSendingWorker(kcp *Connection) *SendingWorker {
@ -206,15 +205,11 @@ func (this *SendingWorker) ProcessReceivingNextWithoutLock(nextNumber uint32) {
// Private: Visible for testing. // Private: Visible for testing.
func (this *SendingWorker) FindFirstUnacknowledged() { func (this *SendingWorker) FindFirstUnacknowledged() {
prevUna := this.firstUnacknowledged
if !this.window.IsEmpty() { if !this.window.IsEmpty() {
this.firstUnacknowledged = this.window.First().Number this.firstUnacknowledged = this.window.First().Number
} else { } else {
this.firstUnacknowledged = this.nextNumber this.firstUnacknowledged = this.nextNumber
} }
if this.firstUnacknowledged != prevUna {
this.updated = true
}
} }
// Private: Visible for testing. // Private: Visible for testing.
@ -293,21 +288,6 @@ func (this *SendingWorker) Write(seg Segment) {
} }
this.conn.output.Write(dataSeg) 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) { func (this *SendingWorker) OnPacketLoss(lossRate uint32) {