Skip to content

Commit

Permalink
Fix blocking of PFCP reception due to EventChannel error
Browse files Browse the repository at this point in the history
  • Loading branch information
Laura Henning committed Oct 31, 2023
1 parent 5c722b6 commit 9b80494
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pfcpUdp/udp.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"net"
"sync"
"time"

"github.com/free5gc/pfcp"
"github.com/free5gc/pfcp/logger"
Expand Down Expand Up @@ -96,12 +97,16 @@ func (pfcpServer *PfcpServer) ReadFrom() (*Message, error) {
}
if tx != nil {
// tx != nil => Already Replied => Resend Request
tx.EventChannel <- pfcp.ReceiveEvent{
select {
case tx.EventChannel <- pfcp.ReceiveEvent{
Type: pfcp.ReceiveEventTypeResendRequest,
RemoteAddr: addr,
RcvMsg: pfcpMsg,
}:
return msg, ErrReceivedResentRequest
case <-time.After(2 * time.Second):
return msg, fmt.Errorf("send to EventChannel timeout for tx %d", tx.SequenceNumber)
}
return msg, ErrReceivedResentRequest
} else {
// tx == nil => New Request
return msg, nil
Expand All @@ -111,11 +116,14 @@ func (pfcpServer *PfcpServer) ReadFrom() (*Message, error) {
if err != nil {
return msg, err
}

tx.EventChannel <- pfcp.ReceiveEvent{
select {
case tx.EventChannel <- pfcp.ReceiveEvent{
Type: pfcp.ReceiveEventTypeValidResponse,
RemoteAddr: addr,
RcvMsg: pfcpMsg,
}:
case <-time.After(2 * time.Second):
return msg, fmt.Errorf("send to EventChannel timeout for tx %d", tx.SequenceNumber)
}
}

Expand Down

0 comments on commit 9b80494

Please sign in to comment.