Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
718bbbf2
Commit
718bbbf2
authored
Sep 24, 2021
by
Cristian Maglie
Committed by
Silvano Cerza
Sep 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed send-on-closed channel bug in DiscoveryManager (#1472)
parent
90536095
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
36 deletions
+28
-36
arduino/discovery/discoverymanager/discoverymanager.go
arduino/discovery/discoverymanager/discoverymanager.go
+14
-22
i18n/data/en.po
i18n/data/en.po
+7
-7
i18n/rice-box.go
i18n/rice-box.go
+7
-7
No files found.
arduino/discovery/discoverymanager/discoverymanager.go
View file @
718bbbf2
...
@@ -27,8 +27,7 @@ import (
...
@@ -27,8 +27,7 @@ import (
// DiscoveryManager is required to handle multiple pluggable-discovery that
// DiscoveryManager is required to handle multiple pluggable-discovery that
// may be shared across platforms
// may be shared across platforms
type
DiscoveryManager
struct
{
type
DiscoveryManager
struct
{
discoveries
map
[
string
]
*
discovery
.
PluggableDiscovery
discoveries
map
[
string
]
*
discovery
.
PluggableDiscovery
globalEventCh
chan
*
discovery
.
Event
}
}
var
tr
=
i18n
.
Tr
var
tr
=
i18n
.
Tr
...
@@ -36,8 +35,7 @@ var tr = i18n.Tr
...
@@ -36,8 +35,7 @@ var tr = i18n.Tr
// New creates a new DiscoveryManager
// New creates a new DiscoveryManager
func
New
()
*
DiscoveryManager
{
func
New
()
*
DiscoveryManager
{
return
&
DiscoveryManager
{
return
&
DiscoveryManager
{
discoveries
:
map
[
string
]
*
discovery
.
PluggableDiscovery
{},
discoveries
:
map
[
string
]
*
discovery
.
PluggableDiscovery
{},
globalEventCh
:
nil
,
}
}
}
}
...
@@ -45,10 +43,6 @@ func New() *DiscoveryManager {
...
@@ -45,10 +43,6 @@ func New() *DiscoveryManager {
func
(
dm
*
DiscoveryManager
)
Clear
()
{
func
(
dm
*
DiscoveryManager
)
Clear
()
{
dm
.
QuitAll
()
dm
.
QuitAll
()
dm
.
discoveries
=
map
[
string
]
*
discovery
.
PluggableDiscovery
{}
dm
.
discoveries
=
map
[
string
]
*
discovery
.
PluggableDiscovery
{}
if
dm
.
globalEventCh
!=
nil
{
close
(
dm
.
globalEventCh
)
dm
.
globalEventCh
=
nil
}
}
}
// IDs returns the list of discoveries' ids in this DiscoveryManager
// IDs returns the list of discoveries' ids in this DiscoveryManager
...
@@ -134,9 +128,8 @@ func (dm *DiscoveryManager) StartAll() []error {
...
@@ -134,9 +128,8 @@ func (dm *DiscoveryManager) StartAll() []error {
// StartSyncAll the discoveries for this DiscoveryManager,
// StartSyncAll the discoveries for this DiscoveryManager,
// returns an error for each discovery failing to start syncing
// returns an error for each discovery failing to start syncing
func
(
dm
*
DiscoveryManager
)
StartSyncAll
()
(
<-
chan
*
discovery
.
Event
,
[]
error
)
{
func
(
dm
*
DiscoveryManager
)
StartSyncAll
()
(
<-
chan
*
discovery
.
Event
,
[]
error
)
{
if
dm
.
globalEventCh
==
nil
{
eventSink
:=
make
(
chan
*
discovery
.
Event
,
5
)
dm
.
globalEventCh
=
make
(
chan
*
discovery
.
Event
,
5
)
var
wg
sync
.
WaitGroup
}
errs
:=
dm
.
parallelize
(
func
(
d
*
discovery
.
PluggableDiscovery
)
error
{
errs
:=
dm
.
parallelize
(
func
(
d
*
discovery
.
PluggableDiscovery
)
error
{
state
:=
d
.
State
()
state
:=
d
.
State
()
if
state
!=
discovery
.
Idling
||
state
==
discovery
.
Syncing
{
if
state
!=
discovery
.
Idling
||
state
==
discovery
.
Syncing
{
...
@@ -148,14 +141,22 @@ func (dm *DiscoveryManager) StartSyncAll() (<-chan *discovery.Event, []error) {
...
@@ -148,14 +141,22 @@ func (dm *DiscoveryManager) StartSyncAll() (<-chan *discovery.Event, []error) {
if
err
!=
nil
{
if
err
!=
nil
{
return
fmt
.
Errorf
(
tr
(
"start syncing discovery %[1]s: %[2]w"
),
d
.
GetID
(),
err
)
return
fmt
.
Errorf
(
tr
(
"start syncing discovery %[1]s: %[2]w"
),
d
.
GetID
(),
err
)
}
}
wg
.
Add
(
1
)
go
func
()
{
go
func
()
{
for
ev
:=
range
eventCh
{
for
ev
:=
range
eventCh
{
dm
.
globalEventCh
<-
ev
eventSink
<-
ev
}
}
wg
.
Done
()
}()
}()
return
nil
return
nil
})
})
return
dm
.
globalEventCh
,
errs
go
func
()
{
wg
.
Wait
()
eventSink
<-
&
discovery
.
Event
{
Type
:
"quit"
}
close
(
eventSink
)
}()
return
eventSink
,
errs
}
}
// StopAll the discoveries for this DiscoveryManager,
// StopAll the discoveries for this DiscoveryManager,
...
@@ -189,15 +190,6 @@ func (dm *DiscoveryManager) QuitAll() []error {
...
@@ -189,15 +190,6 @@ func (dm *DiscoveryManager) QuitAll() []error {
}
}
return
nil
return
nil
})
})
// Close the global channel only if there were no errors
// quitting all alive discoveries
if
len
(
errs
)
==
0
&&
dm
.
globalEventCh
!=
nil
{
// Let events consumers that discoveries are quitting no more events
// will be sent on this channel
dm
.
globalEventCh
<-
&
discovery
.
Event
{
Type
:
"quit"
}
close
(
dm
.
globalEventCh
)
dm
.
globalEventCh
=
nil
}
return
errs
return
errs
}
}
...
...
i18n/data/en.po
View file @
718bbbf2
...
@@ -2555,7 +2555,7 @@ msgstr "destination dir %s already exists, cannot install"
...
@@ -2555,7 +2555,7 @@ msgstr "destination dir %s already exists, cannot install"
msgid "directory doesn't exist: %s"
msgid "directory doesn't exist: %s"
msgstr "directory doesn't exist: %s"
msgstr "directory doesn't exist: %s"
#: arduino/discovery/discoverymanager/discoverymanager.go:1
12
#: arduino/discovery/discoverymanager/discoverymanager.go:1
06
msgid "discovery %[1]s process not started: %[2]w"
msgid "discovery %[1]s process not started: %[2]w"
msgstr "discovery %[1]s process not started: %[2]w"
msgstr "discovery %[1]s process not started: %[2]w"
...
@@ -2860,7 +2860,7 @@ msgstr "library not valid"
...
@@ -2860,7 +2860,7 @@ msgstr "library not valid"
msgid "library path does not exist: %s"
msgid "library path does not exist: %s"
msgstr "library path does not exist: %s"
msgstr "library path does not exist: %s"
#: arduino/discovery/discoverymanager/discoverymanager.go:2
25
#: arduino/discovery/discoverymanager/discoverymanager.go:2
17
msgid "listing ports from discovery %[1]s: %[2]w"
msgid "listing ports from discovery %[1]s: %[2]w"
msgstr "listing ports from discovery %[1]s: %[2]w"
msgstr "listing ports from discovery %[1]s: %[2]w"
...
@@ -3053,7 +3053,7 @@ msgstr "platform not installed"
...
@@ -3053,7 +3053,7 @@ msgstr "platform not installed"
msgid "please use --build-property instead."
msgid "please use --build-property instead."
msgstr "please use --build-property instead."
msgstr "please use --build-property instead."
#: arduino/discovery/discoverymanager/discoverymanager.go:6
7
#: arduino/discovery/discoverymanager/discoverymanager.go:6
1
msgid "pluggable discovery already added: %s"
msgid "pluggable discovery already added: %s"
msgstr "pluggable discovery already added: %s"
msgstr "pluggable discovery already added: %s"
...
@@ -3069,7 +3069,7 @@ msgstr "port not found: %[1]s %[2]s"
...
@@ -3069,7 +3069,7 @@ msgstr "port not found: %[1]s %[2]s"
msgid "protocol version not supported: requested 1, got %d"
msgid "protocol version not supported: requested 1, got %d"
msgstr "protocol version not supported: requested 1, got %d"
msgstr "protocol version not supported: requested 1, got %d"
#: arduino/discovery/discoverymanager/discoverymanager.go:18
8
#: arduino/discovery/discoverymanager/discoverymanager.go:18
9
msgid "quitting discovery %[1]s: %[2]w"
msgid "quitting discovery %[1]s: %[2]w"
msgstr "quitting discovery %[1]s: %[2]w"
msgstr "quitting discovery %[1]s: %[2]w"
...
@@ -3206,11 +3206,11 @@ msgstr "skipping loading of boards %s: malformed custom board options"
...
@@ -3206,11 +3206,11 @@ msgstr "skipping loading of boards %s: malformed custom board options"
msgid "source is not a directory"
msgid "source is not a directory"
msgstr "source is not a directory"
msgstr "source is not a directory"
#: arduino/discovery/discoverymanager/discoverymanager.go:14
9
#: arduino/discovery/discoverymanager/discoverymanager.go:14
2
msgid "start syncing discovery %[1]s: %[2]w"
msgid "start syncing discovery %[1]s: %[2]w"
msgstr "start syncing discovery %[1]s: %[2]w"
msgstr "start syncing discovery %[1]s: %[2]w"
#: arduino/discovery/discoverymanager/discoverymanager.go:12
8
#: arduino/discovery/discoverymanager/discoverymanager.go:12
2
msgid "starting discovery %[1]s: %[2]w"
msgid "starting discovery %[1]s: %[2]w"
msgstr "starting discovery %[1]s: %[2]w"
msgstr "starting discovery %[1]s: %[2]w"
...
@@ -3218,7 +3218,7 @@ msgstr "starting discovery %[1]s: %[2]w"
...
@@ -3218,7 +3218,7 @@ msgstr "starting discovery %[1]s: %[2]w"
msgid "stopping discoveries: %s"
msgid "stopping discoveries: %s"
msgstr "stopping discoveries: %s"
msgstr "stopping discoveries: %s"
#: arduino/discovery/discoverymanager/discoverymanager.go:17
2
#: arduino/discovery/discoverymanager/discoverymanager.go:17
3
msgid "stopping discovery %[1]s: %[2]w"
msgid "stopping discovery %[1]s: %[2]w"
msgstr "stopping discovery %[1]s: %[2]w"
msgstr "stopping discovery %[1]s: %[2]w"
...
...
i18n/rice-box.go
View file @
718bbbf2
This source diff could not be displayed because it is too large. You can
view the blob
instead.
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