Skip to content

Commit

Permalink
[xorm] close leak session for Parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
evalphobia committed Feb 4, 2016
1 parent 0e251b6 commit 81588fd
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions orm/xorm/xorm_parallel.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (xpr *XormParallel) FindParallelByCondition(listPtr interface{}, cond FindC
for _, s := range sessions {
list := reflect.New(elem)
go func(s Session, list reflect.Value) {
s.Close()
err := s.Find(list.Interface())
if err != nil {
errList = append(errList, err)
Expand Down Expand Up @@ -76,6 +77,7 @@ func (xpr *XormParallel) CountParallelByCondition(objPtr interface{}, cond FindC
results := make(chan int64, length)
for _, s := range sessions {
go func(s Session) {
s.Close()
count, err := s.Count(objPtr)
if err != nil {
errList = append(errList, err)
Expand Down Expand Up @@ -146,6 +148,7 @@ func (xpr *XormParallel) UpdateParallelByCondition(objPtr interface{}, cond Upda
results := make(chan int64, length)
for _, s := range sessions {
go func(s Session, obj interface{}) {
s.Close()
count, err := s.Update(obj)
if err != nil {
errList = append(errList, err)
Expand Down

0 comments on commit 81588fd

Please sign in to comment.