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
7a1fba1a
Unverified
Commit
7a1fba1a
authored
Jul 24, 2023
by
ucwong
Committed by
GitHub
Jul 24, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmd/geth: atomic types used (#27756)
parent
88f3d614
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
attach_test.go
cmd/geth/attach_test.go
+3
-3
chaincmd.go
cmd/geth/chaincmd.go
+7
-7
les_test.go
cmd/geth/les_test.go
+2
-2
No files found.
cmd/geth/attach_test.go
View file @
7a1fba1a
...
@@ -61,7 +61,7 @@ func TestRemoteDbWithHeaders(t *testing.T) {
...
@@ -61,7 +61,7 @@ func TestRemoteDbWithHeaders(t *testing.T) {
}
}
func
testReceiveHeaders
(
t
*
testing
.
T
,
ln
net
.
Listener
,
gethArgs
...
string
)
{
func
testReceiveHeaders
(
t
*
testing
.
T
,
ln
net
.
Listener
,
gethArgs
...
string
)
{
var
ok
u
int32
var
ok
atomic
.
U
int32
server
:=
&
http
.
Server
{
server
:=
&
http
.
Server
{
Addr
:
"localhost:0"
,
Addr
:
"localhost:0"
,
Handler
:
&
testHandler
{
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
Handler
:
&
testHandler
{
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
...
@@ -72,12 +72,12 @@ func testReceiveHeaders(t *testing.T, ln net.Listener, gethArgs ...string) {
...
@@ -72,12 +72,12 @@ func testReceiveHeaders(t *testing.T, ln net.Listener, gethArgs ...string) {
if
have
,
want
:=
r
.
Header
.
Get
(
"second"
),
"two"
;
have
!=
want
{
if
have
,
want
:=
r
.
Header
.
Get
(
"second"
),
"two"
;
have
!=
want
{
t
.
Fatalf
(
"missing header, have %v want %v"
,
have
,
want
)
t
.
Fatalf
(
"missing header, have %v want %v"
,
have
,
want
)
}
}
atomic
.
StoreUint32
(
&
ok
,
1
)
ok
.
Store
(
1
)
}}}
}}}
go
server
.
Serve
(
ln
)
go
server
.
Serve
(
ln
)
defer
server
.
Close
()
defer
server
.
Close
()
runGeth
(
t
,
gethArgs
...
)
.
WaitExit
()
runGeth
(
t
,
gethArgs
...
)
.
WaitExit
()
if
atomic
.
LoadUint32
(
&
ok
)
!=
1
{
if
ok
.
Load
(
)
!=
1
{
t
.
Fatal
(
"Test fail, expected invocation to succeed"
)
t
.
Fatal
(
"Test fail, expected invocation to succeed"
)
}
}
}
}
cmd/geth/chaincmd.go
View file @
7a1fba1a
...
@@ -261,16 +261,16 @@ func importChain(ctx *cli.Context) error {
...
@@ -261,16 +261,16 @@ func importChain(ctx *cli.Context) error {
defer
db
.
Close
()
defer
db
.
Close
()
// Start periodically gathering memory profiles
// Start periodically gathering memory profiles
var
peakMemAlloc
,
peakMemSys
u
int64
var
peakMemAlloc
,
peakMemSys
atomic
.
U
int64
go
func
()
{
go
func
()
{
stats
:=
new
(
runtime
.
MemStats
)
stats
:=
new
(
runtime
.
MemStats
)
for
{
for
{
runtime
.
ReadMemStats
(
stats
)
runtime
.
ReadMemStats
(
stats
)
if
atomic
.
LoadUint64
(
&
peakMemAlloc
)
<
stats
.
Alloc
{
if
peakMemAlloc
.
Load
(
)
<
stats
.
Alloc
{
atomic
.
StoreUint64
(
&
peakMemAlloc
,
stats
.
Alloc
)
peakMemAlloc
.
Store
(
stats
.
Alloc
)
}
}
if
atomic
.
LoadUint64
(
&
peakMemSys
)
<
stats
.
Sys
{
if
peakMemSys
.
Load
(
)
<
stats
.
Sys
{
atomic
.
StoreUint64
(
&
peakMemSys
,
stats
.
Sys
)
peakMemSys
.
Store
(
stats
.
Sys
)
}
}
time
.
Sleep
(
5
*
time
.
Second
)
time
.
Sleep
(
5
*
time
.
Second
)
}
}
...
@@ -303,8 +303,8 @@ func importChain(ctx *cli.Context) error {
...
@@ -303,8 +303,8 @@ func importChain(ctx *cli.Context) error {
mem
:=
new
(
runtime
.
MemStats
)
mem
:=
new
(
runtime
.
MemStats
)
runtime
.
ReadMemStats
(
mem
)
runtime
.
ReadMemStats
(
mem
)
fmt
.
Printf
(
"Object memory: %.3f MB current, %.3f MB peak
\n
"
,
float64
(
mem
.
Alloc
)
/
1024
/
1024
,
float64
(
atomic
.
LoadUint64
(
&
peakMemAlloc
))
/
1024
/
1024
)
fmt
.
Printf
(
"Object memory: %.3f MB current, %.3f MB peak
\n
"
,
float64
(
mem
.
Alloc
)
/
1024
/
1024
,
float64
(
peakMemAlloc
.
Load
(
))
/
1024
/
1024
)
fmt
.
Printf
(
"System memory: %.3f MB current, %.3f MB peak
\n
"
,
float64
(
mem
.
Sys
)
/
1024
/
1024
,
float64
(
atomic
.
LoadUint64
(
&
peakMemSys
))
/
1024
/
1024
)
fmt
.
Printf
(
"System memory: %.3f MB current, %.3f MB peak
\n
"
,
float64
(
mem
.
Sys
)
/
1024
/
1024
,
float64
(
peakMemSys
.
Load
(
))
/
1024
/
1024
)
fmt
.
Printf
(
"Allocations: %.3f million
\n
"
,
float64
(
mem
.
Mallocs
)
/
1000000
)
fmt
.
Printf
(
"Allocations: %.3f million
\n
"
,
float64
(
mem
.
Mallocs
)
/
1000000
)
fmt
.
Printf
(
"GC pause: %v
\n\n
"
,
time
.
Duration
(
mem
.
PauseTotalNs
))
fmt
.
Printf
(
"GC pause: %v
\n\n
"
,
time
.
Duration
(
mem
.
PauseTotalNs
))
...
...
cmd/geth/les_test.go
View file @
7a1fba1a
...
@@ -107,10 +107,10 @@ func ipcEndpoint(ipcPath, datadir string) string {
...
@@ -107,10 +107,10 @@ func ipcEndpoint(ipcPath, datadir string) string {
// but windows require pipes to sit in "\\.\pipe\". Therefore, to run several
// but windows require pipes to sit in "\\.\pipe\". Therefore, to run several
// nodes simultaneously, we need to distinguish between them, which we do by
// nodes simultaneously, we need to distinguish between them, which we do by
// the pipe filename instead of folder.
// the pipe filename instead of folder.
var
nextIPC
=
uint32
(
0
)
var
nextIPC
atomic
.
Uint32
func
startGethWithIpc
(
t
*
testing
.
T
,
name
string
,
args
...
string
)
*
gethrpc
{
func
startGethWithIpc
(
t
*
testing
.
T
,
name
string
,
args
...
string
)
*
gethrpc
{
ipcName
:=
fmt
.
Sprintf
(
"geth-%d.ipc"
,
atomic
.
AddUint32
(
&
nextIPC
,
1
))
ipcName
:=
fmt
.
Sprintf
(
"geth-%d.ipc"
,
nextIPC
.
Add
(
1
))
args
=
append
([]
string
{
"--networkid=42"
,
"--port=0"
,
"--authrpc.port"
,
"0"
,
"--ipcpath"
,
ipcName
},
args
...
)
args
=
append
([]
string
{
"--networkid=42"
,
"--port=0"
,
"--authrpc.port"
,
"0"
,
"--ipcpath"
,
ipcName
},
args
...
)
t
.
Logf
(
"Starting %v with rpc: %v"
,
name
,
args
)
t
.
Logf
(
"Starting %v with rpc: %v"
,
name
,
args
)
...
...
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