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
2fae1bde
Unverified
Commit
2fae1bde
authored
Jun 05, 2019
by
Martin Holst Swende
Committed by
Péter Szilágyi
Jun 05, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
account/usbwallet: abort usb enumeration after failures
parent
645756cd
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 @
2fae1bde
...
@@ -20,6 +20,7 @@ import (
...
@@ -20,6 +20,7 @@ import (
"errors"
"errors"
"runtime"
"runtime"
"sync"
"sync"
"sync/atomic"
"time"
"time"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts"
...
@@ -64,6 +65,7 @@ type Hub struct {
...
@@ -64,6 +65,7 @@ type Hub struct {
// TODO(karalabe): remove if hotplug lands on Windows
// TODO(karalabe): remove if hotplug lands on Windows
commsPend
int
// Number of operations blocking enumeration
commsPend
int
// Number of operations blocking enumeration
commsLock
sync
.
Mutex
// Lock protecting the pending counter and 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.
// NewLedgerHub creates a new hardware wallet manager for Ledger devices.
...
@@ -138,6 +140,10 @@ func (hub *Hub) refreshWallets() {
...
@@ -138,6 +140,10 @@ func (hub *Hub) refreshWallets() {
if
elapsed
<
refreshThrottling
{
if
elapsed
<
refreshThrottling
{
return
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
// Retrieve the current list of USB wallet devices
var
devices
[]
usb
.
DeviceInfo
var
devices
[]
usb
.
DeviceInfo
...
@@ -156,13 +162,17 @@ func (hub *Hub) refreshWallets() {
...
@@ -156,13 +162,17 @@ func (hub *Hub) refreshWallets() {
}
}
infos
,
err
:=
usb
.
Enumerate
(
hub
.
vendorID
,
0
)
infos
,
err
:=
usb
.
Enumerate
(
hub
.
vendorID
,
0
)
if
err
!=
nil
{
if
err
!=
nil
{
failcount
:=
atomic
.
AddUint32
(
&
hub
.
enumFails
,
1
)
if
runtime
.
GOOS
==
"linux"
{
if
runtime
.
GOOS
==
"linux"
{
// See rationale before the enumeration why this is needed and only on Linux.
// See rationale before the enumeration why this is needed and only on Linux.
hub
.
commsLock
.
Unlock
()
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
return
}
}
atomic
.
StoreUint32
(
&
hub
.
enumFails
,
0
)
for
_
,
info
:=
range
infos
{
for
_
,
info
:=
range
infos
{
for
_
,
id
:=
range
hub
.
productIDs
{
for
_
,
id
:=
range
hub
.
productIDs
{
// Windows and Macos use UsageID matching, Linux uses Interface matching
// 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