Skip to content

Commit

Permalink
core/capabilities/remote/target: server.Receive - cancel Context; use…
Browse files Browse the repository at this point in the history
… WaitGroup (#13482)
  • Loading branch information
jmank88 authored Jun 10, 2024
1 parent 866b8c0 commit f2680ad
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/capabilities/remote/target/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ func (r *server) expireRequests() {
func (r *server) Receive(msg *types.MessageBody) {
r.receiveLock.Lock()
defer r.receiveLock.Unlock()
ctx, _ := r.stopCh.NewCtx()

if msg.Method != types.MethodExecute {
r.lggr.Errorw("received request for unsupported method type", "method", msg.Method)
Expand All @@ -137,7 +136,11 @@ func (r *server) Receive(msg *types.MessageBody) {

req := r.requestIDToRequest[requestID]

r.wg.Add(1)
go func() {
defer r.wg.Done()
ctx, cancel := r.stopCh.NewCtx()
defer cancel()
err := req.OnMessage(ctx, msg)
if err != nil {
r.lggr.Errorw("request failed to OnMessage new message", "request", req, "err", err)
Expand Down

0 comments on commit f2680ad

Please sign in to comment.