Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
2
22a7f0099
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Summer2022
22a7f0099
Commits
b1821d3f
Commit
b1821d3f
authored
5 years ago
by
Ming Deng
Browse files
Options
Downloads
Patches
Plain Diff
Fix BUG: The RegistryConfigurationListener will be closed twice sometimes
parent
1b444d62
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
filter/impl/tps/impl/tps_limiter_method_service_test.go
+1
-1
1 addition, 1 deletion
filter/impl/tps/impl/tps_limiter_method_service_test.go
registry/zookeeper/listener.go
+9
-10
9 additions, 10 deletions
registry/zookeeper/listener.go
with
10 additions
and
11 deletions
filter/impl/tps/impl/tps_limiter_method_service_test.go
+
1
−
1
View file @
b1821d3f
...
...
@@ -50,7 +50,7 @@ func TestMethodServiceTpsLimiterImpl_IsAllowable_Only_Service_Level(t *testing.T
mockStrategyImpl
.
EXPECT
()
.
IsAllowable
()
.
Return
(
true
)
.
Times
(
1
)
extension
.
SetTpsLimitStrategy
(
constant
.
DEFAULT_KEY
,
&
mockStrategyCreator
{
rate
:
4
0
,
rate
:
2
0
,
interval
:
60000
,
t
:
t
,
strategy
:
mockStrategyImpl
,
...
...
This diff is collapsed.
Click to expand it.
registry/zookeeper/listener.go
+
9
−
10
View file @
b1821d3f
...
...
@@ -20,6 +20,7 @@ package zookeeper
import
(
"context"
"strings"
"sync"
)
import
(
...
...
@@ -71,10 +72,11 @@ func (l *RegistryDataListener) DataChange(eventType remoting.Event) bool {
}
type
RegistryConfigurationListener
struct
{
client
*
zk
.
ZookeeperClient
registry
*
zkRegistry
events
chan
*
config_center
.
ConfigChangeEvent
isClosed
bool
client
*
zk
.
ZookeeperClient
registry
*
zkRegistry
events
chan
*
config_center
.
ConfigChangeEvent
isClosed
bool
closeOnce
sync
.
Once
}
func
NewRegistryConfigurationListener
(
client
*
zk
.
ZookeeperClient
,
reg
*
zkRegistry
)
*
RegistryConfigurationListener
{
...
...
@@ -110,14 +112,11 @@ func (l *RegistryConfigurationListener) Next() (*registry.ServiceEvent, error) {
}
}
func
(
l
*
RegistryConfigurationListener
)
Close
()
{
if
l
.
registry
.
IsAvailable
()
{
/**
* if the registry is not available, it means that the registry has been destroy
* so we don't need to call Done(), or it will cause the negative count panic for registry.wg
*/
// ensure that the listener will be closed at most once.
l
.
closeOnce
.
Do
(
func
()
{
l
.
isClosed
=
true
l
.
registry
.
wg
.
Done
()
}
}
)
}
func
(
l
*
RegistryConfigurationListener
)
valid
()
bool
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment