Skip to content

Commit 7b1d637

Browse files
authored
Merge pull request #16245 from gluk256/311-close-channel
whisper: close the `done` channel in one location
2 parents 66cd41a + 95cca85 commit 7b1d637

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

cmd/wnode/main.go

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -439,18 +439,18 @@ func run() {
439439
} else {
440440
sendLoop()
441441
}
442+
443+
close(done)
442444
}
443445

444446
func sendLoop() {
445447
for {
446448
s := scanLine("")
447449
if s == quitCommand {
448450
fmt.Println("Quit command received")
449-
close(done)
450-
break
451+
return
451452
}
452453
sendMsg([]byte(s))
453-
454454
if *asymmetricMode {
455455
// print your own message for convenience,
456456
// because in asymmetric mode it is impossible to decrypt it
@@ -466,13 +466,11 @@ func sendFilesLoop() {
466466
s := scanLine("")
467467
if s == quitCommand {
468468
fmt.Println("Quit command received")
469-
close(done)
470-
break
469+
return
471470
}
472471
b, err := ioutil.ReadFile(s)
473472
if err != nil {
474473
fmt.Printf(">>> Error: %s \n", err)
475-
continue
476474
} else {
477475
h := sendMsg(b)
478476
if (h == common.Hash{}) {
@@ -491,15 +489,13 @@ func fileReaderLoop() {
491489
watcher2 := shh.GetFilter(asymFilterID)
492490
if watcher1 == nil && watcher2 == nil {
493491
fmt.Println("Error: neither symmetric nor asymmetric filter is installed")
494-
close(done)
495492
return
496493
}
497494

498495
for {
499496
s := scanLine("")
500497
if s == quitCommand {
501498
fmt.Println("Quit command received")
502-
close(done)
503499
return
504500
}
505501
raw, err := ioutil.ReadFile(s)

0 commit comments

Comments
 (0)