mirror of
https://git.zx2c4.com/wireguard-go
synced 2024-11-15 09:15:14 +01:00
device: always name *Queue*Element variables elem
They're called elem in most places. Rename a few local variables to make it consistent. This makes it easier to grep the code for things like elem.Drop. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
This commit is contained in:
parent
2832e96339
commit
c8faa34cde
@ -64,12 +64,12 @@ func (device *Device) GetInboundElement() *QueueInboundElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (device *Device) PutInboundElement(msg *QueueInboundElement) {
|
func (device *Device) PutInboundElement(elem *QueueInboundElement) {
|
||||||
msg.clearPointers()
|
elem.clearPointers()
|
||||||
if PreallocatedBuffersPerPool == 0 {
|
if PreallocatedBuffersPerPool == 0 {
|
||||||
device.pool.inboundElementPool.Put(msg)
|
device.pool.inboundElementPool.Put(elem)
|
||||||
} else {
|
} else {
|
||||||
device.pool.inboundElementReuseChan <- msg
|
device.pool.inboundElementReuseChan <- elem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,11 +81,11 @@ func (device *Device) GetOutboundElement() *QueueOutboundElement {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (device *Device) PutOutboundElement(msg *QueueOutboundElement) {
|
func (device *Device) PutOutboundElement(elem *QueueOutboundElement) {
|
||||||
msg.clearPointers()
|
elem.clearPointers()
|
||||||
if PreallocatedBuffersPerPool == 0 {
|
if PreallocatedBuffersPerPool == 0 {
|
||||||
device.pool.outboundElementPool.Put(msg)
|
device.pool.outboundElementPool.Put(elem)
|
||||||
} else {
|
} else {
|
||||||
device.pool.outboundElementReuseChan <- msg
|
device.pool.outboundElementReuseChan <- elem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,26 +56,26 @@ func (elem *QueueInboundElement) IsDropped() bool {
|
|||||||
return atomic.LoadInt32(&elem.dropped) == AtomicTrue
|
return atomic.LoadInt32(&elem.dropped) == AtomicTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
func (device *Device) addToInboundAndDecryptionQueues(inboundQueue chan *QueueInboundElement, decryptionQueue chan *QueueInboundElement, element *QueueInboundElement) bool {
|
func (device *Device) addToInboundAndDecryptionQueues(inboundQueue chan *QueueInboundElement, decryptionQueue chan *QueueInboundElement, elem *QueueInboundElement) bool {
|
||||||
select {
|
select {
|
||||||
case inboundQueue <- element:
|
case inboundQueue <- elem:
|
||||||
select {
|
select {
|
||||||
case decryptionQueue <- element:
|
case decryptionQueue <- elem:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
element.Drop()
|
elem.Drop()
|
||||||
element.Unlock()
|
elem.Unlock()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
device.PutInboundElement(element)
|
device.PutInboundElement(elem)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (device *Device) addToHandshakeQueue(queue chan QueueHandshakeElement, element QueueHandshakeElement) bool {
|
func (device *Device) addToHandshakeQueue(queue chan QueueHandshakeElement, elem QueueHandshakeElement) bool {
|
||||||
select {
|
select {
|
||||||
case queue <- element:
|
case queue <- elem:
|
||||||
return true
|
return true
|
||||||
default:
|
default:
|
||||||
return false
|
return false
|
||||||
|
@ -81,10 +81,10 @@ func (elem *QueueOutboundElement) IsDropped() bool {
|
|||||||
return atomic.LoadInt32(&elem.dropped) == AtomicTrue
|
return atomic.LoadInt32(&elem.dropped) == AtomicTrue
|
||||||
}
|
}
|
||||||
|
|
||||||
func addToNonceQueue(queue chan *QueueOutboundElement, element *QueueOutboundElement, device *Device) {
|
func addToNonceQueue(queue chan *QueueOutboundElement, elem *QueueOutboundElement, device *Device) {
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case queue <- element:
|
case queue <- elem:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
select {
|
select {
|
||||||
@ -97,20 +97,20 @@ func addToNonceQueue(queue chan *QueueOutboundElement, element *QueueOutboundEle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement, encryptionQueue chan *QueueOutboundElement, element *QueueOutboundElement) {
|
func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement, encryptionQueue chan *QueueOutboundElement, elem *QueueOutboundElement) {
|
||||||
select {
|
select {
|
||||||
case outboundQueue <- element:
|
case outboundQueue <- elem:
|
||||||
select {
|
select {
|
||||||
case encryptionQueue <- element:
|
case encryptionQueue <- elem:
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
element.Drop()
|
elem.Drop()
|
||||||
element.peer.device.PutMessageBuffer(element.buffer)
|
elem.peer.device.PutMessageBuffer(elem.buffer)
|
||||||
element.Unlock()
|
elem.Unlock()
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
element.peer.device.PutMessageBuffer(element.buffer)
|
elem.peer.device.PutMessageBuffer(elem.buffer)
|
||||||
element.peer.device.PutOutboundElement(element)
|
elem.peer.device.PutOutboundElement(elem)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user