Merge "wsprd: used time.Deadline rather than int64 to pass deadlines from wspr to js."
diff --git a/services/wsprd/app/app.go b/services/wsprd/app/app.go
index ad05bb6..323303d 100644
--- a/services/wsprd/app/app.go
+++ b/services/wsprd/app/app.go
@@ -477,10 +477,10 @@
// TODO(mattr): To be consistent with go, we should not ignore 0 timeouts.
// However as a rollout strategy we must, otherwise there is a circular
// dependency between the WSPR change and the JS change that will follow.
- if msg.Timeout == lib.JSIPCNoTimeout || msg.Timeout == 0 {
+ if msg.Deadline.IsZero() {
cctx, cancel = context.WithCancel(ctx)
} else {
- cctx, cancel = context.WithTimeout(ctx, lib.JSToGoDuration(msg.Timeout))
+ cctx, cancel = context.WithDeadline(ctx, msg.Deadline.Time)
}
// If this message is for an internal service, do a short-circuit dispatch here.
diff --git a/services/wsprd/app/app.vdl b/services/wsprd/app/app.vdl
index 7fb239f..455768c 100644
--- a/services/wsprd/app/app.vdl
+++ b/services/wsprd/app/app.vdl
@@ -4,6 +4,7 @@
import (
"v.io/v23/vtrace"
+ "time"
)
type VeyronRPCRequest struct {
@@ -13,7 +14,7 @@
NumOutArgs int32
IsStreaming bool
// TODO(bjornick): Change Timeout to use time.WireDeadline instead.
- Timeout int64
+ Deadline time.WireDeadline
TraceRequest vtrace.Request
}
diff --git a/services/wsprd/app/app.vdl.go b/services/wsprd/app/app.vdl.go
index a8b1d03..488c189 100644
--- a/services/wsprd/app/app.vdl.go
+++ b/services/wsprd/app/app.vdl.go
@@ -10,6 +10,7 @@
"v.io/v23/vdl"
// VDL user imports
+ "v.io/v23/vdlroot/time"
"v.io/v23/vtrace"
)
@@ -20,7 +21,7 @@
NumOutArgs int32
IsStreaming bool
// TODO(bjornick): Change Timeout to use time.WireDeadline instead.
- Timeout int64
+ Deadline time.Deadline
TraceRequest vtrace.Request
}
diff --git a/services/wsprd/app/app_test.go b/services/wsprd/app/app_test.go
index ed4c115..cd70a0a 100644
--- a/services/wsprd/app/app_test.go
+++ b/services/wsprd/app/app_test.go
@@ -16,6 +16,7 @@
"v.io/v23/security"
"v.io/v23/vdl"
"v.io/v23/vdlroot/signature"
+ vdltime "v.io/v23/vdlroot/time"
"v.io/v23/verror"
"v.io/v23/vom"
"v.io/v23/vtrace"
@@ -356,7 +357,7 @@
Method: "Serve",
NumInArgs: 2,
NumOutArgs: 1,
- Timeout: 20000000000,
+ Deadline: vdltime.Deadline{},
}, "adder", 0)
controller.HandleVeyronRequest(ctx, 0, req, writer)
diff --git a/services/wsprd/browspr/browspr_test.go b/services/wsprd/browspr/browspr_test.go
index eada60d..55f278b 100644
--- a/services/wsprd/browspr/browspr_test.go
+++ b/services/wsprd/browspr/browspr_test.go
@@ -14,6 +14,7 @@
"v.io/v23/naming"
"v.io/v23/options"
"v.io/v23/vdl"
+ vdltime "v.io/v23/vdlroot/time"
"v.io/v23/vom"
"v.io/x/ref/lib/testutil"
@@ -173,7 +174,7 @@
NumInArgs: 1,
NumOutArgs: 1,
IsStreaming: false,
- Timeout: (1 << 31) - 1,
+ Deadline: vdltime.Deadline{},
}
var buf bytes.Buffer
diff --git a/services/wsprd/ipc/server/server.go b/services/wsprd/ipc/server/server.go
index 5194870..200a2ae 100644
--- a/services/wsprd/ipc/server/server.go
+++ b/services/wsprd/ipc/server/server.go
@@ -18,6 +18,7 @@
"v.io/v23/security"
"v.io/v23/vdl"
"v.io/v23/vdlroot/signature"
+ vdltime "v.io/v23/vdlroot/time"
"v.io/v23/verror"
"v.io/x/lib/vlog"
)
@@ -38,7 +39,7 @@
type ServerRPCRequestContext struct {
SecurityContext SecurityContext
- Timeout int64 // The time period (in ns) between now and the deadline.
+ Deadline vdltime.Deadline
}
type FlowHandler interface {
@@ -137,9 +138,9 @@
s.outstandingServerRequests[flow.ID] = replyChan
s.outstandingRequestLock.Unlock()
- timeout := lib.JSIPCNoTimeout
+ var timeout vdltime.Deadline
if deadline, ok := call.Context().Deadline(); ok {
- timeout = lib.GoToJSDuration(deadline.Sub(time.Now()))
+ timeout.Time = deadline
}
errHandler := func(err error) <-chan *lib.ServerRPCReply {
@@ -154,7 +155,7 @@
context := ServerRPCRequestContext{
SecurityContext: securityContext,
- Timeout: timeout,
+ Deadline: timeout,
}
// Send a invocation request to JavaScript
@@ -240,9 +241,9 @@
s.outstandingServerRequests[flow.ID] = replyChan
s.outstandingRequestLock.Unlock()
- timeout := lib.JSIPCNoTimeout
+ var timeout vdltime.Deadline
if deadline, ok := call.Context().Deadline(); ok {
- timeout = lib.GoToJSDuration(deadline.Sub(time.Now()))
+ timeout.Time = deadline
}
errHandler := func(err error) (<-chan naming.VDLGlobReply, error) {
@@ -254,7 +255,7 @@
context := ServerRPCRequestContext{
SecurityContext: securityContext,
- Timeout: timeout,
+ Deadline: timeout,
}
// Send a invocation request to JavaScript