Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reject pipelined calls when PlaceArgs returns an error. #303

Merged
merged 1 commit into from
Sep 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion rpc/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ func (ic *importClient) Send(ctx context.Context, s capnp.Send) (*capnp.Answer,
q := ic.c.newQuestion(s.Method)

// Send call message.
var err error
syncutil.Without(&ic.c.mu, func() {
ic.c.sendMessage(ctx, func(m rpccp.Message) error {
err = ic.c.sendMessage(ctx, func(m rpccp.Message) error {
return ic.c.newImportCallMessage(m, ic.id, q.id, s)
}, func(err error) {
ic.c.mu.Lock()
Expand All @@ -120,6 +121,10 @@ func (ic *importClient) Send(ctx context.Context, s capnp.Send) (*capnp.Answer,
})
})

if err != nil {
return capnp.ErrorAnswer(s.Method, err), func() {}
}

ans := q.p.Answer()
return ans, func() {
<-ans.Done()
Expand Down
8 changes: 6 additions & 2 deletions rpc/question.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,10 @@ func (q *question) PipelineSend(ctx context.Context, transform []capnp.PipelineO
q.mark(transform)
q2 := q.c.newQuestion(s.Method)

var err error
syncutil.Without(&q.c.mu, func() {
// Send call message.
q.c.sendMessage(ctx, func(m rpccp.Message) error {
err = q.c.sendMessage(ctx, func(m rpccp.Message) error {
return q.c.newPipelineCallMessage(m, q.id, transform, q2.id, s)
}, func(err error) {
if err != nil {
Expand All @@ -171,9 +172,12 @@ func (q *question) PipelineSend(ctx context.Context, transform []capnp.PipelineO
q2.handleCancel(ctx)
}()
})

})

if err != nil {
return capnp.ErrorAnswer(s.Method, err), func() {}
}

ans := q2.p.Answer()
return ans, func() {
<-ans.Done()
Expand Down