mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 08:25:09 +03:00
use non-blocking on darwin so file is pollable
This commit is contained in:
parent
5d0ec8c62b
commit
686e3943e7
1 changed files with 4 additions and 6 deletions
|
@ -113,6 +113,10 @@ func newTUN(config Config) (ifce *Interface, err error) {
|
|||
return nil, fmt.Errorf("error in syscall.Syscall6(syscall.SYS_GETSOCKOPT, ...): %v", err)
|
||||
}
|
||||
|
||||
if err = syscall.SetNonblock(fd, true); err != nil {
|
||||
return nil, fmt.Errorf("setting non-blocking error")
|
||||
}
|
||||
|
||||
return &Interface{
|
||||
isTAP: false,
|
||||
name: string(ifName.name[:ifNameSize-1 /* -1 is for \0 */]),
|
||||
|
@ -185,11 +189,5 @@ func (t *tunReadCloser) Write(from []byte) (int, error) {
|
|||
}
|
||||
|
||||
func (t *tunReadCloser) Close() error {
|
||||
// lock to make sure no read/write is in process.
|
||||
t.rMu.Lock()
|
||||
defer t.rMu.Unlock()
|
||||
t.wMu.Lock()
|
||||
defer t.wMu.Unlock()
|
||||
|
||||
return t.f.Close()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue