mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5527bff671 | ||
|
|
4850b1b332 | ||
|
|
1ff74f7173 |
@@ -8,7 +8,6 @@ import (
|
||||
_ "net/http/pprof"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/fosrl/newt/bind"
|
||||
@@ -576,7 +575,7 @@ func (o *Olm) Close() {
|
||||
// If we never created a device from the FD, close it explicitly
|
||||
// This can happen if tunnel is stopped during registration before handleConnect
|
||||
logger.Debug("Closing unused TUN file descriptor %d", o.tunnelConfig.FileDescriptorTun)
|
||||
if err := syscall.Close(int(o.tunnelConfig.FileDescriptorTun)); err != nil {
|
||||
if err := closeFD(o.tunnelConfig.FileDescriptorTun); err != nil {
|
||||
logger.Error("Failed to close TUN file descriptor: %v", err)
|
||||
} else {
|
||||
logger.Info("Closed unused TUN file descriptor")
|
||||
|
||||
10
olm/olm_unix.go
Normal file
10
olm/olm_unix.go
Normal file
@@ -0,0 +1,10 @@
|
||||
//go:build !windows
|
||||
|
||||
package olm
|
||||
|
||||
import "syscall"
|
||||
|
||||
// closeFD closes a file descriptor in a platform-specific way
|
||||
func closeFD(fd uint32) error {
|
||||
return syscall.Close(int(fd))
|
||||
}
|
||||
10
olm/olm_windows.go
Normal file
10
olm/olm_windows.go
Normal file
@@ -0,0 +1,10 @@
|
||||
//go:build windows
|
||||
|
||||
package olm
|
||||
|
||||
import "syscall"
|
||||
|
||||
// closeFD closes a file descriptor in a platform-specific way
|
||||
func closeFD(fd uint32) error {
|
||||
return syscall.Close(syscall.Handle(fd))
|
||||
}
|
||||
Reference in New Issue
Block a user