Skip to content

Commit

Permalink
vsock: Remove deadline support in Go 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
monstermunchkin committed Nov 7, 2019
1 parent 1f7f4e4 commit b389f01
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
12 changes: 1 addition & 11 deletions fd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,17 +162,7 @@ func (cfd *sysConnFD) Shutdown(how int) error {
}

func (cfd *sysConnFD) SetDeadline(t time.Time, typ deadlineType) error {
switch typ {
case deadline:
return cfd.f.SetDeadline(t)
case readDeadline:
return cfd.f.SetReadDeadline(t)
case writeDeadline:
return cfd.f.SetWriteDeadline(t)
default:
panicf("vsock: sysConnFD.SetDeadline method invoked with invalid deadline type constant: %d", typ)
return nil
}
return cfd.setDeadline(t, typ)
}

func (cfd *sysConnFD) SyscallConn() (syscall.RawConn, error) { return cfd.syscallConn() }
Expand Down
5 changes: 5 additions & 0 deletions fd_linux_1.10.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,8 @@ func (cfd *sysConnFD) setNonblocking(name string) error {

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())
}
14 changes: 14 additions & 0 deletions fd_linux_1.11.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,17 @@ func (cfd *sysConnFD) setNonblocking(name string) error {

return nil
}

func (cfd *sysConnFD) setDeadline(t time.Time, typ deadlineType) error {
switch typ {
case deadline:
return cfd.f.SetDeadline(t)
case readDeadline:
return cfd.f.SetReadDeadline(t)
case writeDeadline:
return cfd.f.SetWriteDeadline(t)
}

panicf("vsock: sysConnFD.SetDeadline method invoked with invalid deadline type constant: %d", typ)
return nil
}
14 changes: 14 additions & 0 deletions fd_linux_gteq_1.12.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,17 @@ func (cfd *sysConnFD) setNonblocking(name string) error {

return nil
}

func (cfd *sysConnFD) setDeadline(t time.Time, typ deadlineType) error {
switch typ {
case deadline:
return cfd.f.SetDeadline(t)
case readDeadline:
return cfd.f.SetReadDeadline(t)
case writeDeadline:
return cfd.f.SetWriteDeadline(t)
}

panicf("vsock: sysConnFD.SetDeadline method invoked with invalid deadline type constant: %d", typ)
return nil
}

0 comments on commit b389f01

Please sign in to comment.