Skip to content

Commit

Permalink
tidb: try to fix the panic #57
Browse files Browse the repository at this point in the history
  • Loading branch information
siddontang committed Sep 9, 2015
1 parent a54c896 commit 7e50456
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ type driverRows struct {
rs rset.Recordset
done chan int
rows chan interface{}
wg sync.WaitGroup
}

func newEmptyDriverRows() *driverRows {
Expand All @@ -363,7 +364,9 @@ func newdriverRows(rs rset.Recordset) *driverRows {
done: make(chan int),
rows: make(chan interface{}, 500),
}
r.wg.Add(1)
go func() {
defer r.wg.Done()
err := io.EOF
if e := r.rs.Do(func(data []interface{}) (bool, error) {
vv, cloneErr := types.Clone(data)
Expand Down Expand Up @@ -406,6 +409,7 @@ func (r *driverRows) Columns() []string {
// Close closes the rows iterator.
func (r *driverRows) Close() error {
close(r.done)
r.wg.Wait()
return nil
}

Expand Down

0 comments on commit 7e50456

Please sign in to comment.