Skip to content

Commit 7ece67b

Browse files
committed
bwlimit: fix non-separate limit behavior
1 parent 43d6390 commit 7ece67b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

forward/bwlimit.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ const copyChunkSize = 128 * 1024
1717

1818
type cacheItem struct {
1919
mux sync.RWMutex
20-
ul rate.Limiter
21-
dl rate.Limiter
20+
ul *rate.Limiter
21+
dl *rate.Limiter
2222
}
2323

2424
func (i *cacheItem) rLock() {
@@ -133,8 +133,8 @@ func (l *BWLimit) getRatelimiters(username string) (res *cacheItem) {
133133
dl = rate.NewLimiter(rate.Limit(l.bps), max(copyChunkSize, l.burst))
134134
}
135135
res = &cacheItem{
136-
ul: *ul,
137-
dl: *dl,
136+
ul: ul,
137+
dl: dl,
138138
}
139139
res.rLock()
140140
l.cache.SetLocked(m, username, res)
@@ -153,8 +153,8 @@ func (l *BWLimit) PairConnections(ctx context.Context, username string, incoming
153153
o2iErr := make(chan error, 1)
154154
ctxErr := ctx.Done()
155155

156-
go l.futureCopyAndCloseWrite(ctx, i2oErr, &ci.ul, outgoing, incoming)
157-
go l.futureCopyAndCloseWrite(ctx, o2iErr, &ci.dl, incoming, outgoing)
156+
go l.futureCopyAndCloseWrite(ctx, i2oErr, ci.ul, outgoing, incoming)
157+
go l.futureCopyAndCloseWrite(ctx, o2iErr, ci.dl, incoming, outgoing)
158158

159159
// do while we're listening to children channels
160160
for i2oErr != nil || o2iErr != nil {

0 commit comments

Comments
 (0)