Skip to content

Commit

Permalink
add postpone ctx to loopback (#552)
Browse files Browse the repository at this point in the history
Signed-off-by: Nikita Skrynnik <nikita.skrynnik@xored.com>
  • Loading branch information
NikitaSkrynnik authored Apr 8, 2022
1 parent 7b33fe4 commit 5cb7919
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/networkservice/loopback/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/networkservicemesh/api/pkg/api/networkservice"
"github.com/networkservicemesh/sdk/pkg/networkservice/core/next"
"github.com/networkservicemesh/sdk/pkg/networkservice/utils/metadata"
"github.com/networkservicemesh/sdk/pkg/tools/postpone"
)

type loopbackClient struct {
Expand Down Expand Up @@ -55,9 +56,12 @@ func (l *loopbackClient) Request(ctx context.Context, request *networkservice.Ne
if err := createLoopback(ctx, l.vppConn, networkService, l.loopbacks, metadata.IsClient(l)); err != nil {
return nil, err
}
postponeCtxFunc := postpone.Context(ctx)
conn, err := next.Client(ctx).Request(ctx, request, opts...)
if err != nil {
del(ctx, l.vppConn, networkService, l.loopbacks, metadata.IsClient(l))
closeCtx, cancelClose := postponeCtxFunc()
defer cancelClose()
del(closeCtx, l.vppConn, networkService, l.loopbacks, metadata.IsClient(l))
}
return conn, err
}
Expand Down

0 comments on commit 5cb7919

Please sign in to comment.