mirror of
https://github.com/KusakabeShi/EtherGuard-VPN.git
synced 2025-08-19 05:05:54 +02:00
Extend structs rather than embed, when possible
This commit is contained in:
14
send.go
14
send.go
@@ -43,7 +43,7 @@ import (
|
||||
|
||||
type QueueOutboundElement struct {
|
||||
dropped int32
|
||||
mutex sync.Mutex
|
||||
sync.Mutex
|
||||
buffer *[MaxMessageSize]byte // slice holding the packet data
|
||||
packet []byte // slice of "buffer" (always!)
|
||||
nonce uint64 // nonce for encryption
|
||||
@@ -55,7 +55,7 @@ func (device *Device) NewOutboundElement() *QueueOutboundElement {
|
||||
elem := device.GetOutboundElement()
|
||||
elem.dropped = AtomicFalse
|
||||
elem.buffer = device.GetMessageBuffer()
|
||||
elem.mutex = sync.Mutex{}
|
||||
elem.Mutex = sync.Mutex{}
|
||||
elem.nonce = 0
|
||||
elem.keypair = nil
|
||||
elem.peer = nil
|
||||
@@ -95,7 +95,7 @@ func addToOutboundAndEncryptionQueues(outboundQueue chan *QueueOutboundElement,
|
||||
default:
|
||||
element.Drop()
|
||||
element.peer.device.PutMessageBuffer(element.buffer)
|
||||
element.mutex.Unlock()
|
||||
element.Unlock()
|
||||
}
|
||||
default:
|
||||
element.peer.device.PutMessageBuffer(element.buffer)
|
||||
@@ -442,7 +442,7 @@ func (peer *Peer) RoutineNonce() {
|
||||
|
||||
elem.keypair = keypair
|
||||
elem.dropped = AtomicFalse
|
||||
elem.mutex.Lock()
|
||||
elem.Lock()
|
||||
|
||||
// add to parallel and sequential queue
|
||||
addToOutboundAndEncryptionQueues(peer.queue.outbound, device.queue.encryption, elem)
|
||||
@@ -468,7 +468,7 @@ func (device *Device) RoutineEncryption() {
|
||||
if ok && !elem.IsDropped() {
|
||||
elem.Drop()
|
||||
device.PutMessageBuffer(elem.buffer)
|
||||
elem.mutex.Unlock()
|
||||
elem.Unlock()
|
||||
}
|
||||
default:
|
||||
goto out
|
||||
@@ -535,7 +535,7 @@ func (device *Device) RoutineEncryption() {
|
||||
elem.packet,
|
||||
nil,
|
||||
)
|
||||
elem.mutex.Unlock()
|
||||
elem.Unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -588,7 +588,7 @@ func (peer *Peer) RoutineSequentialSender() {
|
||||
return
|
||||
}
|
||||
|
||||
elem.mutex.Lock()
|
||||
elem.Lock()
|
||||
if elem.IsDropped() {
|
||||
device.PutOutboundElement(elem)
|
||||
continue
|
||||
|
Reference in New Issue
Block a user