Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit893c43b

Browse files
authored
Merge pull requestdigitalocean#74 from digitalocean/geoff/dont-panic
Fix a panic caused by writing to a closed channel, silence a warning
2 parents290a4e9 +1c122ff commit893c43b

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

‎internal/lvgen/lvlexer.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func (l *Lexer) Error(s string) {
137137
// the items channel, and sets the state to nil, which stops the lexer's state
138138
// machine.
139139
func (l*Lexer)errorf(formatstring,args...interface{})stateFn {
140-
l.items<-item{ERROR,fmt.Sprintf(format,args),l.line,l.column}
140+
l.items<-item{ERROR,fmt.Sprintf(format,args...),l.line,l.column}
141141
returnnil
142142
}
143143

‎rpc.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ func (l *Libvirt) callback(id uint32, res response) {
177177
c,ok:=l.callbacks[id]
178178
l.cm.Unlock()
179179
ifok {
180-
// we close channel in deregister() so that we don't block here forever without receiver
180+
// we close the channel in deregister() so that we don't block here
181+
// forever without a receiver. If that happens, this write will panic.
181182
deferfunc() {
182183
recover()
183184
}()
@@ -219,7 +220,13 @@ func (l *Libvirt) stream(buf []byte) {
219220
l.em.Lock()
220221
c,ok:=l.events[e.CallbackID]
221222
l.em.Unlock()
223+
222224
ifok {
225+
// we close the channel in deregister() so that we don't block here
226+
// forever without a receiver. If that happens, this write will panic.
227+
deferfunc() {
228+
recover()
229+
}()
223230
c<-e
224231
}
225232
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp