Skip to content
This repository was archived by the owner on Nov 5, 2024. It is now read-only.

Commit 81fbe2d

Browse files
committed
[proxy]防止后端服务器当前请求数小于0
1 parent 0cbeafb commit 81fbe2d

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

teaconfigs/backend.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ func (this *BackendConfig) DecreaseConn() int32 {
223223
if this.nextBackend != nil {
224224
return this.nextBackend.DecreaseConn()
225225
}
226+
if this.CurrentConns == 0 {
227+
return 0
228+
}
226229
return atomic.AddInt32(&this.CurrentConns, -1)
227230
}
228231

@@ -447,7 +450,7 @@ func (this *BackendConfig) CloneState(oldBackend *BackendConfig) {
447450
this.IsDown = oldBackend.IsDown
448451
this.DownTime = oldBackend.DownTime
449452
this.CurrentFails = oldBackend.CurrentFails
450-
this.CurrentConns = oldBackend.CurrentConns
453+
atomic.StoreInt32(&this.CurrentConns, oldBackend.CurrentConns)
451454
}
452455

453456
// 获取唯一ID

0 commit comments

Comments
 (0)