Skip to content

Commit

Permalink
Set read deadline to handle abandoned allocation requests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao committed Feb 27, 2022
1 parent dfe04cb commit e4f8c66
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Atsushi Watanabe <[email protected]>
backkem <[email protected]>
cnderrauber <[email protected]>
David Colburn <[email protected]>
David Zhao <[email protected]>
Herman Banken <[email protected]>
Hugo Arregui <[email protected]>
Igor German <[email protected]>
Expand Down
5 changes: 5 additions & 0 deletions internal/allocation/allocation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import (
"github.com/pion/turn/v2/internal/proto"
)

const (
allocationDeadline = 30 * time.Second
)

type allocationResponse struct {
transactionID [stun.TransactionIDSize]byte
responseAttrs []stun.Setter
Expand Down Expand Up @@ -245,6 +249,7 @@ func (a *Allocation) packetHandler(m *Manager) {
buffer := make([]byte, rtpMTU)

for {
_ = a.RelaySocket.SetReadDeadline(time.Now().Add(allocationDeadline))
n, srcAddr, err := a.RelaySocket.ReadFrom(buffer)
if err != nil {
m.DeleteAllocation(a.fiveTuple)
Expand Down

0 comments on commit e4f8c66

Please sign in to comment.