Skip to content

Commit

Permalink
fix: use defer to subscribe the SDM svc
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 authored Oct 29, 2024
1 parent eb404de commit 175a071
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions internal/sbi/processor/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,21 @@ func (p *Processor) HandlePDUSessionSMContextCreate(
}
}

if !p.Context().Ues.UeExists(smContext.Supi) {
if problemDetails, err := p.Consumer().
Subscribe(ctx, smContext, smPlmnID); problemDetails != nil {
smContext.Log.Errorln("SDM Subscription Failed Problem:", problemDetails)
} else if err != nil {
smContext.Log.Errorln("SDM Subscription Error:", err)
var doSubscribe bool = false
defer func(){
if doSubscribe {

Check failure on line 126 in internal/sbi/processor/pdu_session.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/free5gc) --custom-order (gci)
if !p.Context().Ues.UeExists(smContext.Supi) {
if problemDetails, err := p.Consumer().
Subscribe(ctx, smContext, smPlmnID); problemDetails != nil {
smContext.Log.Errorln("SDM Subscription Failed Problem:", problemDetails)
} else if err != nil {
smContext.Log.Errorln("SDM Subscription Error:", err)
}
} else {
p.Context().Ues.IncrementPduSessionCount(smContext.Supi)
}
}
} else {
p.Context().Ues.IncrementPduSessionCount(smContext.Supi)
}
}()

establishmentRequest := m.PDUSessionEstablishmentRequest
if err := HandlePDUSessionEstablishmentRequest(smContext, establishmentRequest); err != nil {
Expand Down Expand Up @@ -248,6 +253,7 @@ func (p *Processor) HandlePDUSessionSMContextCreate(
smContext.PostRemoveDataPath()
}()

doSubscribe = true
response.JsonData = smContext.BuildCreatedData()
c.Header("Location", smContext.Ref)
c.Render(http.StatusCreated, openapi.MultipartRelatedRender{Data: response})
Expand Down

0 comments on commit 175a071

Please sign in to comment.