mdlayher / vsock

Package vsock provides access to Linux VM sockets (AF_VSOCK) for communication between a hypervisor and its virtual machines. MIT Licensed.
MIT License
336 stars 65 forks source link

vsock: initial Go 1.12 runtime network poller support #26

Closed mdlayher closed 5 years ago

mdlayher commented 5 years ago

A draft that should make all the runtime network poller magic work properly. I need to overhaul the tests now too.

  • net.Listener that can accept and wait indefinitely without EAGAIN, but also be closed while blocking
matt@servnerr-3:~$ ./vscp -r -p 1024 -t 5s
2019/03/14 22:28:39 receive: listening: host(2):1024
2019/03/14 22:28:44 vscp: receive: failed to accept: use of closed file
  • net.Conn that can have timeouts set and be closed concurrently (already done?)
matt@servnerr-3:~$ ./vscp -r -p 1024 -t 5s
2019/03/14 22:28:54 receive: listening: host(2):1024
abc
2019/03/14 22:29:01 vscp: receive: failed to receive data: read vsock host(2):1024: i/o timeout

Fixes #25.

mdlayher commented 5 years ago

/cc @aybabtme @mxpv @pmorjan

mdlayher commented 5 years ago

Welp, I'm gonna need some sleep to work out the concurrency thing. It makes sense, but it makes things trickier.

mdlayher commented 5 years ago

Okay. I think this is ready for review. I've hit it with the race detector a few times and am not finding any more problems, so I suspect the runtime network poller and/or *os.File are doing some synchronization on our behalf for when we Accept/Close concurrently, and etc.

mdlayher commented 5 years ago

As far as I can tell, this works as expected. I'm going to merge it!