Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
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
plugin
Commits
4666b86b
Commit
4666b86b
authored
May 21, 2021
by
jiangpeng
Committed by
vipwzw
May 21, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p:fix wait group data race
parent
4f9789cb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
0 deletions
+10
-0
p2p.go
plugin/p2p/gossip/p2p.go
+10
-0
No files found.
plugin/p2p/gossip/p2p.go
View file @
4666b86b
...
...
@@ -81,6 +81,7 @@ type P2p struct {
subCfg
*
subConfig
mgr
*
p2p
.
Manager
subChan
chan
interface
{}
lock
sync
.
Mutex
}
// New produce a p2p object
...
...
@@ -147,6 +148,8 @@ func (network *P2p) isRestart() bool {
//CloseP2P Close network client
func
(
network
*
P2p
)
CloseP2P
()
{
network
.
lock
.
Lock
()
defer
network
.
lock
.
Unlock
()
log
.
Info
(
"p2p network start shutdown"
)
atomic
.
StoreInt32
(
&
network
.
closed
,
1
)
//等待业务协程停止
...
...
@@ -321,6 +324,8 @@ func (network *P2p) genAirDropKeyFromWallet() error {
//ReStart p2p
func
(
network
*
P2p
)
ReStart
()
{
network
.
lock
.
Lock
()
defer
network
.
lock
.
Unlock
()
//避免重复
if
!
atomic
.
CompareAndSwapInt32
(
&
network
.
restart
,
0
,
1
)
{
return
...
...
@@ -400,6 +405,11 @@ func (network *P2p) subP2pMsg() {
func
(
network
*
P2p
)
processEvent
(
msg
*
queue
.
Message
,
taskIdx
int64
,
eventFunc
p2pEventFunc
)
{
network
.
lock
.
Lock
()
defer
network
.
lock
.
Unlock
()
if
network
.
isClose
()
{
return
}
//检测重启标志,停止分发事件,需要等待重启
if
network
.
isRestart
()
{
log
.
Info
(
"wait for p2p restart...."
)
...
...
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