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
14d668d6
Commit
14d668d6
authored
4 years ago
by
watermelon
Browse files
Options
Downloads
Patches
Plain Diff
Fix: issue #951 etcd exit panic
parent
8e2aa4a8
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
registry/etcdv3/listener.go
+8
-3
8 additions, 3 deletions
registry/etcdv3/listener.go
registry/etcdv3/registry.go
+5
-14
5 additions, 14 deletions
registry/etcdv3/registry.go
remoting/etcdv3/listener.go
+3
-3
3 additions, 3 deletions
remoting/etcdv3/listener.go
with
16 additions
and
20 deletions
registry/etcdv3/listener.go
+
8
−
3
View file @
14d668d6
...
...
@@ -19,6 +19,7 @@ package etcdv3
import
(
"strings"
"sync"
)
import
(
...
...
@@ -79,8 +80,9 @@ func (l *dataListener) DataChange(eventType remoting.Event) bool {
}
type
configurationListener
struct
{
registry
*
etcdV3Registry
events
chan
*
config_center
.
ConfigChangeEvent
registry
*
etcdV3Registry
events
chan
*
config_center
.
ConfigChangeEvent
closeOnce
sync
.
Once
}
// NewConfigurationListener for listening the event of etcdv3.
...
...
@@ -119,6 +121,9 @@ func (l *configurationListener) Next() (*registry.ServiceEvent, error) {
}
// Close etcd registry center
// BugFix why no real close
func
(
l
*
configurationListener
)
Close
()
{
l
.
registry
.
WaitGroup
()
.
Done
()
l
.
closeOnce
.
Do
(
func
()
{
l
.
registry
.
WaitGroup
()
.
Done
()
})
}
This diff is collapsed.
Click to expand it.
registry/etcdv3/registry.go
+
5
−
14
View file @
14d668d6
...
...
@@ -51,7 +51,7 @@ type etcdV3Registry struct {
registry
.
BaseRegistry
cltLock
sync
.
Mutex
client
*
etcdv3
.
Client
listenerLock
sync
.
Mutex
listenerLock
sync
.
RW
Mutex
listener
*
etcdv3
.
EventListener
dataListener
*
dataListener
configListener
*
configurationListener
...
...
@@ -150,14 +150,9 @@ func (r *etcdV3Registry) CreatePath(k string) error {
// DoSubscribe actually subscribe the provider URL
func
(
r
*
etcdV3Registry
)
DoSubscribe
(
svc
*
common
.
URL
)
(
registry
.
Listener
,
error
)
{
var
(
configListener
*
configurationListener
)
r
.
listenerLock
.
Lock
()
configListener
=
r
.
configListener
r
.
listenerLock
.
Unlock
()
r
.
listenerLock
.
RLock
()
configListener
:=
r
.
configListener
r
.
listenerLock
.
RUnlock
()
if
r
.
listener
==
nil
{
r
.
cltLock
.
Lock
()
client
:=
r
.
client
...
...
@@ -165,12 +160,8 @@ func (r *etcdV3Registry) DoSubscribe(svc *common.URL) (registry.Listener, error)
if
client
==
nil
{
return
nil
,
perrors
.
New
(
"etcd client broken"
)
}
// new client & listener
listener
:=
etcdv3
.
NewEventListener
(
r
.
client
)
r
.
listenerLock
.
Lock
()
r
.
listener
=
listener
r
.
listener
=
etcdv3
.
NewEventListener
(
r
.
client
)
// new client &
listener
r
.
listenerLock
.
Unlock
()
}
...
...
This diff is collapsed.
Click to expand it.
remoting/etcdv3/listener.go
+
3
−
3
View file @
14d668d6
...
...
@@ -36,7 +36,7 @@ import (
// nolint
type
EventListener
struct
{
client
*
Client
keyMapLock
sync
.
Mutex
keyMapLock
sync
.
RW
Mutex
keyMap
map
[
string
]
struct
{}
wg
sync
.
WaitGroup
}
...
...
@@ -181,9 +181,9 @@ func timeSecondDuration(sec int) time.Duration {
// --------> listenServiceNodeEvent
func
(
l
*
EventListener
)
ListenServiceEvent
(
key
string
,
listener
remoting
.
DataListener
)
{
l
.
keyMapLock
.
Lock
()
l
.
keyMapLock
.
R
Lock
()
_
,
ok
:=
l
.
keyMap
[
key
]
l
.
keyMapLock
.
Unlock
()
l
.
keyMapLock
.
R
Unlock
()
if
ok
{
logger
.
Warnf
(
"etcdv3 key %s has already been listened."
,
key
)
return
...
...
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