Skip to content
This repository has been archived by the owner on Feb 18, 2021. It is now read-only.

Commit

Permalink
fix panics while publishing (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
azylman authored and thuningxu committed May 5, 2017
1 parent 3f513f9 commit d659679
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion tools/common/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -1274,17 +1274,21 @@ func Publish(c *cli.Context, cClient ccli.Client) {
break
}

// Increment the WaitGroup before the publish to make sure that
// we'll never call Done on the WaitGroup before we've called Add.
receiptWg.Add(1)
id, err = publisher.PublishAsync(&ccli.PublisherMessage{
Data: line,
}, receiptCh)

if err != nil {
// If the publish errored, we never actually sent a receipt down the channel.
receiptWg.Done()
fmt.Fprintf(os.Stderr, "%v\n", err)
break
}

fmt.Fprintf(os.Stdout, "Local publish ID: %s\n", id)
receiptWg.Add(1)
}

if !common.AwaitWaitGroup(&receiptWg, time.Minute) {
Expand Down

0 comments on commit d659679

Please sign in to comment.