mirror of
https://github.com/yggdrasil-network/water.git
synced 2025-05-19 16:35:10 +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)
|
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{
|
return &Interface{
|
||||||
isTAP: false,
|
isTAP: false,
|
||||||
name: string(ifName.name[:ifNameSize-1 /* -1 is for \0 */]),
|
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 {
|
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()
|
return t.f.Close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue