Skip to content

Commit

Permalink
pass gin.Context instead of channel
Browse files Browse the repository at this point in the history
  • Loading branch information
ianchen0119 committed Aug 10, 2023
1 parent a077a7a commit 57dc6fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
3 changes: 1 addition & 2 deletions internal/sbi/pdusession/api_sm_contexts_collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ func HTTPPostSmContexts(c *gin.Context) {
}

req := httpwrapper.NewRequest(c.Request, request)
isDone := c.Done()
HTTPResponse := producer.HandlePDUSessionSMContextCreate(isDone,
HTTPResponse := producer.HandlePDUSessionSMContextCreate(c,
req.Body.(models.PostSmContextsRequest))
// Http Response to AMF
for key, val := range HTTPResponse.Header {
Expand Down
8 changes: 5 additions & 3 deletions internal/sbi/producer/datapath.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/free5gc/smf/internal/logger"
"github.com/free5gc/smf/internal/pfcp/handler"
pfcp_message "github.com/free5gc/smf/internal/pfcp/message"
"github.com/gin-gonic/gin"
)

type PFCPState struct {
Expand Down Expand Up @@ -199,13 +200,14 @@ func waitAllPfcpRsp(
}
}

func EstHandler(isDone <-chan struct{},
func EstHandler(c *gin.Context,
smContext *smf_context.SMContext, success bool,
) {
// Waiting for Create SMContext Request completed
if isDone != nil {
<-isDone
if c != nil {
<-c.Done()
}

if success {
sendPDUSessionEstablishmentAccept(smContext)
} else {
Expand Down
5 changes: 3 additions & 2 deletions internal/sbi/producer/pdu_session.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"net/http"

"github.com/antihax/optional"
"github.com/gin-gonic/gin"

"github.com/free5gc/nas"
"github.com/free5gc/nas/nasMessage"
Expand All @@ -24,7 +25,7 @@ import (
"github.com/free5gc/util/httpwrapper"
)

func HandlePDUSessionSMContextCreate(isDone <-chan struct{},
func HandlePDUSessionSMContextCreate(c *gin.Context,
request models.PostSmContextsRequest,
) *httpwrapper.Response {
// GSM State
Expand Down Expand Up @@ -212,7 +213,7 @@ func HandlePDUSessionSMContextCreate(isDone <-chan struct{},
smContext.SendUpPathChgNotification("EARLY", SendUpPathChgEventExposureNotification)

handler := func(smContext *smf_context.SMContext, success bool) {
EstHandler(isDone, smContext, success)
EstHandler(c, smContext, success)
}

ActivateUPFSession(smContext, handler)
Expand Down

0 comments on commit 57dc6fa

Please sign in to comment.