Fixed file descriptor leak on linux
This commit is contained in:
parent
c5d7efc246
commit
bd6027a4d5
|
@ -313,17 +313,15 @@ func (device *Device) RoutineEncryption() {
|
||||||
elem.packet = append(elem.packet, 0)
|
elem.packet = append(elem.packet, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// encrypt content
|
// encrypt content (append to header)
|
||||||
|
|
||||||
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
|
binary.LittleEndian.PutUint64(nonce[4:], elem.nonce)
|
||||||
elem.packet = elem.keyPair.send.Seal(
|
elem.packet = elem.keyPair.send.Seal(
|
||||||
elem.packet[:0],
|
header,
|
||||||
nonce[:],
|
nonce[:],
|
||||||
elem.packet,
|
elem.packet,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
length := MessageTransportHeaderSize + len(elem.packet)
|
|
||||||
elem.packet = elem.buffer[:length]
|
|
||||||
elem.mutex.Unlock()
|
elem.mutex.Unlock()
|
||||||
|
|
||||||
// refresh key if necessary
|
// refresh key if necessary
|
||||||
|
|
|
@ -37,6 +37,8 @@ func (tun *NativeTun) setMTU(n int) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer syscall.Close(fd)
|
||||||
|
|
||||||
// do ioctl call
|
// do ioctl call
|
||||||
|
|
||||||
var ifr [64]byte
|
var ifr [64]byte
|
||||||
|
@ -70,6 +72,8 @@ func (tun *NativeTun) MTU() (int, error) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defer syscall.Close(fd)
|
||||||
|
|
||||||
// do ioctl call
|
// do ioctl call
|
||||||
|
|
||||||
var ifr [64]byte
|
var ifr [64]byte
|
||||||
|
|
Loading…
Reference in a new issue