Skip to content

Commit

Permalink
Don't send calls with 0 ttl even for low TTLs
Browse files Browse the repository at this point in the history
  • Loading branch information
prashantv committed Aug 16, 2016
1 parent 99f494d commit 0e62532
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion messages.go
Expand Up @@ -212,7 +212,7 @@ func (m *callReq) read(r *typed.ReadBuffer) error {
}

func (m *callReq) write(w *typed.WriteBuffer) error {
w.WriteUint32(uint32(m.TimeToLive.Seconds() * 1000))
w.WriteUint32(uint32(m.TimeToLive / time.Millisecond))
m.Tracing.write(w)
w.WriteLen8String(m.Service)
m.Headers.write(w)
Expand Down
5 changes: 4 additions & 1 deletion outbound.go
Expand Up @@ -55,8 +55,11 @@ func (c *Connection) beginCall(ctx context.Context, serviceName, methodName stri
// never get here.
return nil, ErrTimeoutRequired
}

// If the timeToLive is less than a millisecond, it will be encoded as 0 on
// the wire, hence we return a timeout immediately.
timeToLive := deadline.Sub(now)
if timeToLive <= 0 {
if timeToLive < time.Millisecond {
return nil, ErrTimeout
}

Expand Down

0 comments on commit 0e62532

Please sign in to comment.