Skip to content

Commit

Permalink
remove deadlock checker
Browse files Browse the repository at this point in the history
  • Loading branch information
mh0lt committed Jul 1, 2024
1 parent 67deab1 commit 0812b77
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 90 deletions.
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ require (
github.com/frankban/quicktest v1.14.6
github.com/fsnotify/fsnotify v1.5.4
github.com/go-llsqlite/adapter v0.0.0-20230927005056-7f5ce7f0c916
github.com/go-stack/stack v1.8.0
github.com/google/btree v1.1.2
github.com/google/go-cmp v0.5.9
github.com/gorilla/websocket v1.5.0
Expand All @@ -43,7 +42,6 @@ require (
github.com/pion/webrtc/v3 v3.1.42
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/sasha-s/go-deadlock v0.3.1
github.com/stretchr/testify v1.8.4
github.com/tidwall/btree v1.6.0
go.etcd.io/bbolt v1.3.6
Expand Down Expand Up @@ -79,7 +77,6 @@ require (
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 // indirect
github.com/pion/dtls/v2 v2.2.4 // indirect
github.com/pion/ice/v2 v2.2.6 // indirect
github.com/pion/interceptor v0.1.11 // indirect
Expand Down
5 changes: 0 additions & 5 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0=
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
github.com/go-stack/stack v1.8.0 h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
Expand Down Expand Up @@ -365,8 +364,6 @@ github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7J
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5 h1:q2e307iGHPdTGp0hoxKjt1H5pDo6utceo3dQVK3I5XQ=
github.com/petermattis/goid v0.0.0-20180202154549-b0b1615b78e5/go.mod h1:jvVRKCrJTQWu0XVbaOlby/2lO20uSCHEMzzplHXte1o=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pion/datachannel v1.5.2 h1:piB93s8LGmbECrpO84DnkIVWasRMk3IimbcXkTQLE6E=
Expand Down Expand Up @@ -466,8 +463,6 @@ github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417 h1:Lt9DzQALzHoDwMBGJ6v
github.com/rs/dnscache v0.0.0-20211102005908-e0241e321417/go.mod h1:qe5TWALJ8/a1Lqznoc5BDHpYX/8HU60Hm2AwRmqzxqA=
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46 h1:GHRpF1pTW19a8tTFrMLUcfWwyC0pnifVo2ClaLq+hP8=
github.com/ryszard/goskiplist v0.0.0-20150312221310-2dfbae5fcf46/go.mod h1:uAQ5PCi+MFsC7HjREoAz1BU+Mq60+05gifQSsHSDG/8=
github.com/sasha-s/go-deadlock v0.3.1 h1:sqv7fDNShgjcaxkO0JNcOAlr8B9+cV5Ey/OB71efZx0=
github.com/sasha-s/go-deadlock v0.3.1/go.mod h1:F73l+cr82YSh10GxyRI6qZiCgK64VaZjwesgfQ1/iLM=
github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
Expand Down
82 changes: 0 additions & 82 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
"github.com/anacrolix/multiless"
"github.com/anacrolix/sync"
"github.com/pion/datachannel"
"github.com/sasha-s/go-deadlock"
"golang.org/x/sync/errgroup"
"golang.org/x/time/rate"

Expand All @@ -50,91 +49,10 @@ import (
typedRoaring "github.com/anacrolix/torrent/typed-roaring"
"github.com/anacrolix/torrent/webseed"
"github.com/anacrolix/torrent/webtorrent"
stack2 "github.com/go-stack/stack"
)

var bufPool = storage.NewBufferPool()

func stack(skip int) string {
return stack2.Trace().TrimBelow(stack2.Caller(skip)).String()
}

func init() {
deadlock.Opts.DeadlockTimeout = 3 * time.Minute
}

type mu struct {
deadlock.RWMutex
rlc atomic.Int32
lc atomic.Int32
rlmu sync.Mutex
rlocker [20]string
rlocktime time.Time
locker string
nextlocker string
locktime time.Time
}

func (m *mu) RLock() {
m.RWMutex.RLock()
m.rlmu.Lock()
rlc := m.rlc.Load()
if int(rlc) < len(m.rlocker) {
m.rlocker[rlc] = string(stack(2))
}
if rlc == 0 {
m.rlocktime = time.Now()
}
m.rlc.Add(1)
m.rlmu.Unlock()
//fmt.Println("R", m.rlc, string(dbg.Stack())[:40])

}

func (m *mu) RUnlock() {
m.rlmu.Lock()
m.rlc.Add(-1)
rlc := m.rlc.Load()
if rlc < 0 {
panic("lock underflow")
}
if rlc == 0 {
m.rlocktime = time.Time{}
}
if int(rlc) < len(m.rlocker) {
m.rlocker[m.rlc.Load()] = ""
}
m.rlmu.Unlock()
m.RWMutex.RUnlock()
//fmt.Println("RUN", m.rlc) //, string(dbg.Stack()))
}

func (m *mu) Lock() {
m.rlmu.Lock()
if m.nextlocker == "" {
m.nextlocker = string(stack(2))
}
m.rlmu.Unlock()
m.RWMutex.Lock()
m.lc.Add(1)
m.rlmu.Lock()
m.locker = m.nextlocker
m.locktime = time.Now()
m.nextlocker = ""
m.rlmu.Unlock()
}

func (m *mu) Unlock() {
m.lc.Add(-1)
if m.lc.Load() < 0 {
panic("lock underflow")
}
m.locker = ""
m.locktime = time.Time{}
m.RWMutex.Unlock()
//fmt.Println("LUN", m.lc) //, string(dbg.Stack()))
}

// Maintains state of torrent within a Client. Many methods should not be called before the info is
// available, see .Info and .GotInfo.
type Torrent struct {
Expand Down

0 comments on commit 0812b77

Please sign in to comment.