Skip to content

Commit

Permalink
p2
Browse files Browse the repository at this point in the history
  • Loading branch information
edaniels committed Aug 2, 2024
1 parent 3269ac2 commit 2d3a4fa
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions datachannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ type DataChannel struct {
bufferedAmountLowThreshold uint64
detachCalled bool
readLoopActive chan struct{}
isUserClosed bool
isGracefulClosed bool

// The binaryType represents attribute MUST, on getting, return the value to
// which it was last set. On setting, if the new value is either the string
Expand Down Expand Up @@ -227,7 +227,7 @@ func (d *DataChannel) OnOpen(f func()) {
func (d *DataChannel) onOpen() {
d.mu.RLock()
handler := d.onOpenHandler
if d.isUserClosed {
if d.isGracefulClosed {
d.mu.RUnlock()
return
}
Expand Down Expand Up @@ -258,7 +258,7 @@ func (d *DataChannel) OnDial(f func()) {
func (d *DataChannel) onDial() {
d.mu.RLock()
handler := d.onDialHandler
if d.isUserClosed {
if d.isGracefulClosed {
d.mu.RUnlock()
return
}
Expand Down Expand Up @@ -306,7 +306,7 @@ func (d *DataChannel) OnMessage(f func(msg DataChannelMessage)) {
func (d *DataChannel) onMessage(msg DataChannelMessage) {
d.mu.RLock()
handler := d.onMessageHandler
if d.isUserClosed {
if d.isGracefulClosed {
d.mu.RUnlock()
return
}
Expand All @@ -320,7 +320,7 @@ func (d *DataChannel) onMessage(msg DataChannelMessage) {

func (d *DataChannel) handleOpen(dc *datachannel.DataChannel, isRemote, isAlreadyNegotiated bool) {
d.mu.Lock()
if d.isUserClosed {
if d.isGracefulClosed {
d.mu.Unlock()
return
}
Expand Down Expand Up @@ -348,7 +348,7 @@ func (d *DataChannel) handleOpen(dc *datachannel.DataChannel, isRemote, isAlread
d.mu.Lock()
defer d.mu.Unlock()

if d.isUserClosed {
if d.isGracefulClosed {
return
}

Expand All @@ -369,7 +369,7 @@ func (d *DataChannel) OnError(f func(err error)) {
func (d *DataChannel) onError(err error) {
d.mu.RLock()
handler := d.onErrorHandler
if d.isUserClosed {
if d.isGracefulClosed {
d.mu.RUnlock()
return
}
Expand Down Expand Up @@ -505,7 +505,7 @@ func (d *DataChannel) GracefulClose() error {
// right before closing the DataChannel, you'd need never see a reset stream.
func (d *DataChannel) close(graceful bool) error {
d.mu.Lock()
d.isUserClosed = true
d.isGracefulClosed = true
readLoopActive := d.readLoopActive
if graceful && readLoopActive != nil {
defer func() {
Expand Down

0 comments on commit 2d3a4fa

Please sign in to comment.