Skip to content

Commit c79463d

Browse files
committed
Added SCTPTransport.BufferedAmount
It simplifies tracking amount of unsent data for all data channels, including ones in closing state. Especially useful for IoT apps which use multiple data channels and have to monitor memory usage.
1 parent 3e43ae9 commit c79463d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

sctptransport.go

+11
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,14 @@ func (r *SCTPTransport) association() *sctp.Association {
430430

431431
return association
432432
}
433+
434+
// BufferedAmount returns total amount (in bytes) of currently buffered user data.
435+
func (r *SCTPTransport) BufferedAmount() int {
436+
r.lock.Lock()
437+
defer r.lock.Unlock()
438+
if r.sctpAssociation == nil {
439+
return 0
440+
}
441+
442+
return r.sctpAssociation.BufferedAmount()
443+
}

0 commit comments

Comments
 (0)