Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
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
张蕾
Geth-Modification
Commits
eef65b20
Commit
eef65b20
authored
Aug 06, 2018
by
Felföldi Zsolt
Committed by
Péter Szilágyi
Aug 06, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p: use safe atomic operations when changing connFlags (#17325)
parent
c4df6746
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
server.go
p2p/server.go
+11
-6
No files found.
p2p/server.go
View file @
eef65b20
...
@@ -258,13 +258,18 @@ func (c *conn) is(f connFlag) bool {
...
@@ -258,13 +258,18 @@ func (c *conn) is(f connFlag) bool {
}
}
func
(
c
*
conn
)
set
(
f
connFlag
,
val
bool
)
{
func
(
c
*
conn
)
set
(
f
connFlag
,
val
bool
)
{
flags
:=
connFlag
(
atomic
.
LoadInt32
((
*
int32
)(
&
c
.
flags
)))
for
{
if
val
{
oldFlags
:=
connFlag
(
atomic
.
LoadInt32
((
*
int32
)(
&
c
.
flags
)))
flags
|=
f
flags
:=
oldFlags
}
else
{
if
val
{
flags
&=
^
f
flags
|=
f
}
else
{
flags
&=
^
f
}
if
atomic
.
CompareAndSwapInt32
((
*
int32
)(
&
c
.
flags
),
int32
(
oldFlags
),
int32
(
flags
))
{
return
}
}
}
atomic
.
StoreInt32
((
*
int32
)(
&
c
.
flags
),
int32
(
flags
))
}
}
// Peers returns all connected peers.
// Peers returns all connected peers.
...
...
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