diff options
author | Ian Lance Taylor <iant@golang.org> | 2018-09-24 21:46:21 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2018-09-24 21:46:21 +0000 |
commit | dd931d9b48647e898dc80927c532ae93cc09e192 (patch) | |
tree | 71be2295cd79b8a182f6130611658db8628772d5 /libgo/go/net/rpc | |
parent | 779d8a5ad09b01428726ea5a0e6c87bd9ac3c0e4 (diff) | |
download | gcc-dd931d9b48647e898dc80927c532ae93cc09e192.zip gcc-dd931d9b48647e898dc80927c532ae93cc09e192.tar.gz gcc-dd931d9b48647e898dc80927c532ae93cc09e192.tar.bz2 |
libgo: update to Go 1.11
Reviewed-on: https://go-review.googlesource.com/136435
gotools/:
* Makefile.am (mostlyclean-local): Run chmod on check-go-dir to
make sure it is writable.
(check-go-tools): Likewise.
(check-vet): Copy internal/objabi to check-vet-dir.
* Makefile.in: Rebuild.
From-SVN: r264546
Diffstat (limited to 'libgo/go/net/rpc')
-rw-r--r-- | libgo/go/net/rpc/client.go | 9 | ||||
-rw-r--r-- | libgo/go/net/rpc/server.go | 5 |
2 files changed, 11 insertions, 3 deletions
diff --git a/libgo/go/net/rpc/client.go b/libgo/go/net/rpc/client.go index fce6a48..cad2d45 100644 --- a/libgo/go/net/rpc/client.go +++ b/libgo/go/net/rpc/client.go @@ -59,8 +59,8 @@ type Client struct { // connection. ReadResponseBody may be called with a nil // argument to force the body of the response to be read and then // discarded. +// See NewClient's comment for information about concurrent access. type ClientCodec interface { - // WriteRequest must be safe for concurrent use by multiple goroutines. WriteRequest(*Request, interface{}) error ReadResponseHeader(*Response) error ReadResponseBody(interface{}) error @@ -75,8 +75,8 @@ func (client *Client) send(call *Call) { // Register this call. client.mutex.Lock() if client.shutdown || client.closing { - call.Error = ErrShutdown client.mutex.Unlock() + call.Error = ErrShutdown call.done() return } @@ -185,6 +185,11 @@ func (call *Call) done() { // set of services at the other end of the connection. // It adds a buffer to the write side of the connection so // the header and payload are sent as a unit. +// +// The read and write halves of the connection are serialized independently, +// so no interlocking is required. However each half may be accessed +// concurrently so the implementation of conn should protect against +// concurrent reads or concurrent writes. func NewClient(conn io.ReadWriteCloser) *Client { encBuf := bufio.NewWriter(conn) client := &gobClientCodec{conn, gob.NewDecoder(conn), gob.NewEncoder(encBuf), encBuf} diff --git a/libgo/go/net/rpc/server.go b/libgo/go/net/rpc/server.go index 96e6973..7bb6476 100644 --- a/libgo/go/net/rpc/server.go +++ b/libgo/go/net/rpc/server.go @@ -444,6 +444,7 @@ func (c *gobServerCodec) Close() error { // The caller typically invokes ServeConn in a go statement. // ServeConn uses the gob wire format (see package gob) on the // connection. To use an alternate codec, use ServeCodec. +// See NewClient's comment for information about concurrent access. func (server *Server) ServeConn(conn io.ReadWriteCloser) { buf := bufio.NewWriter(conn) srv := &gobServerCodec{ @@ -653,12 +654,13 @@ func RegisterName(name string, rcvr interface{}) error { // write a response back. The server calls Close when finished with the // connection. ReadRequestBody may be called with a nil // argument to force the body of the request to be read and discarded. +// See NewClient's comment for information about concurrent access. type ServerCodec interface { ReadRequestHeader(*Request) error ReadRequestBody(interface{}) error - // WriteResponse must be safe for concurrent use by multiple goroutines. WriteResponse(*Response, interface{}) error + // Close can be called multiple times and must be idempotent. Close() error } @@ -667,6 +669,7 @@ type ServerCodec interface { // The caller typically invokes ServeConn in a go statement. // ServeConn uses the gob wire format (see package gob) on the // connection. To use an alternate codec, use ServeCodec. +// See NewClient's comment for information about concurrent access. func ServeConn(conn io.ReadWriteCloser) { DefaultServer.ServeConn(conn) } |