Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sidecar
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
sidecar
Commits
e7971c4e
Commit
e7971c4e
authored
Dec 06, 2021
by
harrylee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix a bug for Rlock
parent
6b813583
Pipeline
#8339
canceled with stages
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
map.go
internal/port/map.go
+9
-9
No files found.
internal/port/map.go
View file @
e7971c4e
...
@@ -58,7 +58,7 @@ func (p *PortMap) add(pt Port) {
...
@@ -58,7 +58,7 @@ func (p *PortMap) add(pt Port) {
}
}
func
(
p
*
PortMap
)
GetHub
()
(
Port
,
bool
)
{
func
(
p
*
PortMap
)
GetHub
()
(
Port
,
bool
)
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
if
p
.
hubPort
==
nil
{
if
p
.
hubPort
==
nil
{
return
nil
,
false
return
nil
,
false
...
@@ -67,7 +67,7 @@ func (p *PortMap) GetHub() (Port, bool) {
...
@@ -67,7 +67,7 @@ func (p *PortMap) GetHub() (Port, bool) {
}
}
func
(
p
*
PortMap
)
GetLocal
()
(
Port
,
bool
)
{
func
(
p
*
PortMap
)
GetLocal
()
(
Port
,
bool
)
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
if
p
.
local
==
nil
{
if
p
.
local
==
nil
{
return
nil
,
false
return
nil
,
false
...
@@ -76,13 +76,13 @@ func (p *PortMap) GetLocal() (Port, bool) {
...
@@ -76,13 +76,13 @@ func (p *PortMap) GetLocal() (Port, bool) {
}
}
func
(
p
*
PortMap
)
Port
(
id
string
)
(
Port
,
bool
)
{
func
(
p
*
PortMap
)
Port
(
id
string
)
(
Port
,
bool
)
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
if
p
.
hubPort
.
ID
()
==
id
{
if
p
.
hubPort
!=
nil
&&
p
.
hubPort
.
ID
()
==
id
{
return
p
.
hubPort
,
true
return
p
.
hubPort
,
true
}
}
if
p
.
local
.
ID
()
==
id
{
if
p
.
local
!=
nil
&&
p
.
local
.
ID
()
==
id
{
return
p
.
local
,
true
return
p
.
local
,
true
}
}
...
@@ -96,7 +96,7 @@ func (p *PortMap) Port(id string) (Port, bool) {
...
@@ -96,7 +96,7 @@ func (p *PortMap) Port(id string) (Port, bool) {
}
}
func
(
p
*
PortMap
)
RouterPortByID
(
ids
[]
string
)
[]
Port
{
func
(
p
*
PortMap
)
RouterPortByID
(
ids
[]
string
)
[]
Port
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
var
ports
[]
Port
var
ports
[]
Port
for
_
,
id
:=
range
ids
{
for
_
,
id
:=
range
ids
{
...
@@ -108,7 +108,7 @@ func (p *PortMap) RouterPortByID(ids []string) []Port {
...
@@ -108,7 +108,7 @@ func (p *PortMap) RouterPortByID(ids []string) []Port {
}
}
func
(
p
*
PortMap
)
RouterPortByTag
(
tag
string
)
[]
Port
{
func
(
p
*
PortMap
)
RouterPortByTag
(
tag
string
)
[]
Port
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
var
ports
[]
Port
var
ports
[]
Port
for
_
,
pt
:=
range
p
.
peerPort
{
for
_
,
pt
:=
range
p
.
peerPort
{
...
@@ -120,7 +120,7 @@ func (p *PortMap) RouterPortByTag(tag string) []Port {
...
@@ -120,7 +120,7 @@ func (p *PortMap) RouterPortByTag(tag string) []Port {
}
}
func
(
p
*
PortMap
)
AllRouterPort
()
[]
Port
{
func
(
p
*
PortMap
)
AllRouterPort
()
[]
Port
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
var
ports
[]
Port
var
ports
[]
Port
for
_
,
pt
:=
range
p
.
peerPort
{
for
_
,
pt
:=
range
p
.
peerPort
{
...
@@ -130,7 +130,7 @@ func (p *PortMap) AllRouterPort() []Port {
...
@@ -130,7 +130,7 @@ func (p *PortMap) AllRouterPort() []Port {
}
}
func
(
p
*
PortMap
)
RandRouterPort
()
Port
{
func
(
p
*
PortMap
)
RandRouterPort
()
Port
{
p
.
rw
.
RLock
er
()
p
.
rw
.
RLock
()
defer
p
.
rw
.
RUnlock
()
defer
p
.
rw
.
RUnlock
()
var
randPort
Port
var
randPort
Port
l
:=
len
(
p
.
peerPort
)
l
:=
len
(
p
.
peerPort
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment