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
30c2b1b0
Unverified
Commit
30c2b1b0
authored
Jun 05, 2019
by
Péter Szilágyi
Committed by
GitHub
Jun 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #19671 from holiman/usbfix
account/usbwallet: abort usb enumeration after failures
parents
b8ca3cb7
2fae1bde
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
1 deletion
+11
-1
hub.go
accounts/usbwallet/hub.go
+11
-1
No files found.
accounts/usbwallet/hub.go
View file @
30c2b1b0
...
...
@@ -20,6 +20,7 @@ import (
"errors"
"runtime"
"sync"
"sync/atomic"
"time"
"github.com/ethereum/go-ethereum/accounts"
...
...
@@ -64,6 +65,7 @@ type Hub struct {
// TODO(karalabe): remove if hotplug lands on Windows
commsPend
int
// Number of operations blocking enumeration
commsLock
sync
.
Mutex
// Lock protecting the pending counter and enumeration
enumFails
uint32
// Number of times enumeration has failed
}
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
...
...
@@ -138,6 +140,10 @@ func (hub *Hub) refreshWallets() {
if
elapsed
<
refreshThrottling
{
return
}
// If USB enumeration is continually failing, don't keep trying indefinitely
if
atomic
.
LoadUint32
(
&
hub
.
enumFails
)
>
2
{
return
}
// Retrieve the current list of USB wallet devices
var
devices
[]
usb
.
DeviceInfo
...
...
@@ -156,13 +162,17 @@ func (hub *Hub) refreshWallets() {
}
infos
,
err
:=
usb
.
Enumerate
(
hub
.
vendorID
,
0
)
if
err
!=
nil
{
failcount
:=
atomic
.
AddUint32
(
&
hub
.
enumFails
,
1
)
if
runtime
.
GOOS
==
"linux"
{
// See rationale before the enumeration why this is needed and only on Linux.
hub
.
commsLock
.
Unlock
()
}
log
.
Error
(
"error enumerating USB enumeration: "
,
"code"
,
err
)
log
.
Error
(
"Failed to enumerate USB devices"
,
"hub"
,
hub
.
scheme
,
"vendor"
,
hub
.
vendorID
,
"failcount"
,
failcount
,
"err"
,
err
)
return
}
atomic
.
StoreUint32
(
&
hub
.
enumFails
,
0
)
for
_
,
info
:=
range
infos
{
for
_
,
id
:=
range
hub
.
productIDs
{
// Windows and Macos use UsageID matching, Linux uses Interface matching
...
...
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