]> Cypherpunks repositories - gostls13.git/commit
net: implement asynchonous cancelable I/O on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Fri, 11 Nov 2016 19:49:11 +0000 (20:49 +0100)
committerBrad Fitzpatrick <bradfitz@golang.org>
Sat, 12 Nov 2016 05:44:36 +0000 (05:44 +0000)
commitadb384ad2cfbd742fb106b7ec2a65d4ad844c35e
tree4e0f7ff6c497cafae18822a2079fdb384b8b6996
parent456f2f5cb8c2e06e7faba6ba298ffb65c7a19397
net: implement asynchonous cancelable I/O on Plan 9

This change is an experimental implementation of asynchronous
cancelable I/O operations on Plan 9, which are required to
implement deadlines.

There are no asynchronous syscalls on Plan 9. I/O operations
are performed with blocking pread and pwrite syscalls.

Implementing deadlines in Go requires a way to interrupt
I/O operations.

It is possible to interrupt reads and writes on a TCP connection
by forcing the closure of the TCP connection. This approach
has been used successfully in CL 31390.

However, we can't implement deadlines with this method, since
we require to be able to reuse the connection after the timeout.

On Plan 9, I/O operations are interrupted when the process
receives a note. We can rely on this behavior to implement
a more generic approach.

When doing an I/O operation (read or write), we start the I/O in
its own process, then wait for the result asynchronously. The
process is able to handle the "hangup" note. When receiving the
"hangup" note, the currently running I/O operation is canceled
and the process returns.

This way, deadlines can be implemented by sending an "hangup"
note to the process running the blocking I/O operation, after
the expiration of a timer.

Fixes #11932.
Fixes #17498.

Change-Id: I414f72c7a9a4f9b8f9c09ed3b6c269f899d9b430
Reviewed-on: https://go-review.googlesource.com/31521
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/net/fd_io_plan9.go [new file with mode: 0644]
src/net/fd_plan9.go
src/net/tcpsock_test.go
src/runtime/net_plan9.go [new file with mode: 0644]
src/runtime/os3_plan9.go
src/runtime/os_plan9.go