diff options
author | Felix Lange <fjl@twurst.com> | 2016-07-12 23:47:15 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-07-23 05:21:27 +0800 |
commit | 91b769042857f542b2792b23ec407e1c9bd4fe8d (patch) | |
tree | f6730b3e85a7ac5ca98f9a716505349958fcacd3 /rpc/ipc_windows.go | |
parent | bb01bea4e276dad359815c682a2dee730737f4dc (diff) | |
download | dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.gz dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.bz2 dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.lz dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.xz dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.tar.zst dexon-91b769042857f542b2792b23ec407e1c9bd4fe8d.zip |
rpc: add new client, use it everywhere
The new client implementation supports concurrent requests,
subscriptions and replaces the various ad hoc RPC clients
throughout go-ethereum.
Diffstat (limited to 'rpc/ipc_windows.go')
-rw-r--r-- | rpc/ipc_windows.go | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/rpc/ipc_windows.go b/rpc/ipc_windows.go index 8342d04d5..68234d215 100644 --- a/rpc/ipc_windows.go +++ b/rpc/ipc_windows.go @@ -22,16 +22,27 @@ import ( "net" "time" + "golang.org/x/net/context" "gopkg.in/natefinch/npipe.v2" ) +// This is used if the dialing context has no deadline. It is much smaller than the +// defaultDialTimeout because named pipes are local and there is no need to wait so long. +const defaultPipeDialTimeout = 2 * time.Second + // ipcListen will create a named pipe on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { return npipe.Listen(endpoint) } // newIPCConnection will connect to a named pipe with the given endpoint as name. -func newIPCConnection(endpoint string) (net.Conn, error) { - timeout := 5 * time.Second +func newIPCConnection(ctx context.Context, endpoint string) (net.Conn, error) { + timeout := defaultPipeDialTimeout + if deadline, ok := ctx.Deadline(); ok { + timeout = deadline.Sub(time.Now()) + if timeout < 0 { + timeout = 0 + } + } return npipe.DialTimeout(endpoint, timeout) } |