Skip to content

Commit

Permalink
add reselectcleanup logic into begin
Browse files Browse the repository at this point in the history
Signed-off-by: Danil Uzlov <[email protected]>
  • Loading branch information
d-uzlov committed Jun 20, 2023
1 parent cf89e72 commit 9b2284c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/networkservice/common/begin/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,16 @@ func (b *beginServer) Request(ctx context.Context, request *networkservice.Netwo
}

withEventFactoryCtx := withEventFactory(ctx, eventFactoryServer)

if request.GetConnection().GetState() == networkservice.State_RESELECT_REQUESTED {
if eventFactoryServer.request != nil && eventFactoryServer.request.Connection != nil {
log.FromContext(ctx).Info("Closing connection due to RESELECT_REQUESTED state")
_, closeErr := next.Server(ctx).Close(ctx, eventFactoryServer.request.Connection)
if closeErr != nil {
log.FromContext(ctx).Errorf("Can't close old connection: %v", closeErr)
}
}
}
conn, err = next.Server(withEventFactoryCtx).Request(withEventFactoryCtx, request)
if err != nil {
if eventFactoryServer.state != established {
Expand All @@ -72,6 +82,7 @@ func (b *beginServer) Request(ctx context.Context, request *networkservice.Netwo
}
return
}
conn.State = networkservice.State_UP
eventFactoryServer.request = request.Clone()
eventFactoryServer.request.Connection = conn.Clone()
eventFactoryServer.state = established
Expand Down

0 comments on commit 9b2284c

Please sign in to comment.