Skip to content

Commit

Permalink
Merge branch 'develop' into release/v0.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
dancannon committed Apr 14, 2015
2 parents 480e704 + 88f8611 commit d968f8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
8 changes: 5 additions & 3 deletions cursor.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,27 +143,28 @@ func (c *Cursor) Next(dest interface{}) bool {
return false
}

if !hasMore {
c.Close()
}

return hasMore
}

func (c *Cursor) loadNext(dest interface{}) (bool, error) {
for c.lastErr == nil {
// Check if response is closed/finished
if c.buffer.Len() == 0 && c.responses.Len() == 0 && c.closed {

return false, errCursorClosed
}

if c.buffer.Len() == 0 && c.responses.Len() == 0 && !c.finished {

err := c.fetchMore()
if err != nil {
return false, err
}
}

if c.buffer.Len() == 0 && c.responses.Len() == 0 && c.finished {

return false, nil
}

Expand Down Expand Up @@ -263,6 +264,7 @@ func (c *Cursor) All(result interface{}) error {
// `One` zeroes the value before scanning in the result.
func (c *Cursor) One(result interface{}) error {
if c.IsNil() {
c.Close()
return ErrEmptyResult
}

Expand Down
3 changes: 3 additions & 0 deletions pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ func (p *Pool) putConn(pc *poolConn, err error) {
// If a connRequest was fulfilled or the *poolConn was placed in the
// freeConn list, then true is returned, otherwise false is returned.
func (p *Pool) putConnPoolLocked(pc *poolConn, err error) bool {
if p.maxOpen > 0 && p.numOpen > p.maxOpen {
return false
}
if c := len(p.connRequests); c > 0 {
req := p.connRequests[0]
// This copy is O(n) but in practice faster than a linked list.
Expand Down

0 comments on commit d968f8b

Please sign in to comment.