forked from mdlayher/vsock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fd_linux_1.10.go
63 lines (49 loc) · 1.75 KB
/
fd_linux_1.10.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//+build go1.10,!go1.11,linux
package vsock
import (
"fmt"
"os"
"runtime"
"syscall"
"time"
"golang.org/x/sys/unix"
)
func (lfd *sysListenFD) accept4(flags int) (int, unix.Sockaddr, error) {
// In Go 1.11, accept on the raw file descriptor directly, because lfd.f
// may be attached to the runtime network poller, forcing this call to block
// even if Close is called.
return unix.Accept4(lfd.fd, flags)
}
func (lfd *sysListenFD) setNonblocking(name string) error {
// Go 1.10 doesn't support non-blocking I/O.
if err := unix.SetNonblock(lfd.fd, false); err != nil {
return err
}
lfd.f = os.NewFile(uintptr(lfd.fd), name)
return nil
}
func (*sysListenFD) setDeadline(_ time.Time) error {
// Listener deadlines won't work as expected in this version of Go, so
// return an early error.
return fmt.Errorf("vsock: listener deadlines not supported on %s", runtime.Version())
}
func (*sysConnFD) shutdown(_ int) error {
// Shutdown functionality is not available in this version on Go.
return fmt.Errorf("vsock: close conn read/write not supported on %s", runtime.Version())
}
func (*sysConnFD) syscallConn() (syscall.RawConn, error) {
// SyscallConn functionality is not available in this version on Go.
return nil, fmt.Errorf("vsock: syscall conn not supported on %s", runtime.Version())
}
func (cfd *sysConnFD) setNonblocking(name string) error {
// Go 1.10 doesn't support non-blocking I/O.
if err := unix.SetNonblock(cfd.fd, false); err != nil {
return err
}
cfd.f = os.NewFile(uintptr(cfd.fd), name)
return nil
}
func (cfd *sysConnFD) setDeadline(t time.Time, typ deadlineType) error {
// Deadline functionality is not available in this version on Go.
return fmt.Errorf("vsock: connection deadlines not supported on %s", runtime.Version())
}