Skip to content

Set read deadline to handle abandoned allocation requests #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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