Skip to content

Commit

Permalink
Added HV Socket known IDs, Dial, bug fixes (#239)
Browse files Browse the repository at this point in the history
* Added HV Socket known IDs, Dial, bug fixes

Added:
* Well-know Hyper-V VMIDs for parents, children, and loopback.
* VSock interop service GUID.
* `Dial()` and `DialContext()` to dial a specific Hyper-V socket at a
  known address (along with a corresponding `HvsockDialer` struct.

Bug fixes:
* Dial (and Listen) now properly initialize and set properties of their
  sockets after ConnectEx (and AcceptEx).
* The `socketError` used by `bind` was incorrect, it should be `int32(-1)`,
  not `uintptr(^0)`
* Return errors for `(*HvsockConn) SetDeadline`

Created a `sockets` package, currently only with syscalls to `Bind`,
`ConnectEx` and `GetSockName`, bypassing `syscall/windows` restrictions
on the types that can do so.

Signed-off-by: Hamza El-Saawy <[email protected]>

* PR: error handling bug, rebase, unexport, naming

* comments and todos statements
* spelling
* removed dead code
* changed names to be more conventional
* unexported socket code
* made `(*HvsockDialer) Dial` take `Context`, removed `DialContext`
* added default `Dial` function
* rebased onto main
* cleaned up `Dial(` retry loop

Signed-off-by: Hamza El-Saawy <[email protected]>

* PR: RawSockaddr validation, `.As(` style

Signed-off-by: Hamza El-Saawy <[email protected]>
  • Loading branch information
helsaawy authored Jul 21, 2022
1 parent c62166d commit d68e55c
Show file tree
Hide file tree
Showing 6 changed files with 534 additions and 40 deletions.
3 changes: 3 additions & 0 deletions file.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ func ioCompletionProcessor(h syscall.Handle) {
}
}

// todo: helsaawy - create an asyncIO version that takes a context

// asyncIo processes the return value from ReadFile or WriteFile, blocking until
// the operation has actually completed.
func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, err error) (int, error) {
Expand Down Expand Up @@ -221,6 +223,7 @@ func (f *win32File) asyncIo(c *ioOperation, d *deadlineHandler, bytes uint32, er
// runtime.KeepAlive is needed, as c is passed via native
// code to ioCompletionProcessor, c must remain alive
// until the channel read is complete.
// todo: (de)allocate *ioOperation via win32 heap functions, instead of needing to KeepAlive?
runtime.KeepAlive(c)
return int(r.bytes), err
}
Expand Down
Loading

0 comments on commit d68e55c

Please sign in to comment.