Skip to content

Commit

Permalink
Merge pull request #269 from capnproto/bugfix/question-release-panic
Browse files Browse the repository at this point in the history
Defend against nil-pointer panics in question.release
  • Loading branch information
zenhack committed Jul 29, 2022
2 parents 13980e3 + 94705f5 commit 4e56003
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 1 addition & 0 deletions rpc/question.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func (c *Conn) newQuestion(method capnp.Method) *question {
q := &question{
c: c,
id: questionID(c.questionID.next()),
release: func() {},
finishMsgSend: make(chan struct{}),
}
q.p = capnp.NewPromise(method, q) // TODO(someday): customize error message for bootstrap
Expand Down
3 changes: 0 additions & 3 deletions rpc/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,6 @@ func (c *Conn) handleReturn(ctx context.Context, ret rpccp.Return, release capnp
go func() {
switch {
case q.bootstrapPromise != nil && pr.err == nil:
q.release = func() {}
syncutil.Without(&c.mu, func() {
q.p.Fulfill(pr.result)
q.bootstrapPromise.Fulfill(q.p.Answer().Client())
Expand All @@ -958,7 +957,6 @@ func (c *Conn) handleReturn(ctx context.Context, ret rpccp.Return, release capnp
case q.bootstrapPromise != nil && pr.err != nil:
// TODO(someday): send unimplemented message back to remote if
// pr.unimplemented == true.
q.release = func() {}
syncutil.Without(&c.mu, func() {
q.p.Reject(pr.err)
q.bootstrapPromise.Fulfill(q.p.Answer().Client())
Expand All @@ -968,7 +966,6 @@ func (c *Conn) handleReturn(ctx context.Context, ret rpccp.Return, release capnp
case q.bootstrapPromise == nil && pr.err != nil:
// TODO(someday): send unimplemented message back to remote if
// pr.unimplemented == true.
q.release = func() {}
syncutil.Without(&c.mu, func() {
q.p.Reject(pr.err)
release()
Expand Down

0 comments on commit 4e56003

Please sign in to comment.