Godeps/_workspace/src/gopkg.in/mgo.v2/session.go
func (iter *Iter) Close() error {
	iter.m.Lock()
	cursorId := iter.op.cursorId
	iter.op.cursorId = 0
	err := iter.err
	iter.m.Unlock()
	if cursorId == 0 {
		if err == ErrNotFound {
			return nil
		}
		return err
	}
	socket, err := iter.acquireSocket()
	if err == nil {
		// TODO Batch kills.
		err = socket.Query(&killCursorsOp{[]int64{cursorId}})
		socket.Release()
	}

	iter.m.Lock()
	if err != nil && (iter.err == nil || iter.err == ErrNotFound) {
		iter.err = err
	} else if iter.err != ErrNotFound {
		err = iter.err
	}
	iter.m.Unlock()
	return err
}
func (iter *Iter) Close() error {
	iter.m.Lock()
	cursorId := iter.op.cursorId
	iter.op.cursorId = 0
	err := iter.err
	iter.m.Unlock()
	if cursorId == 0 {
		if err == ErrNotFound {
			return nil
		}
		return err
	}
	socket, err := iter.acquireSocket()
	if err == nil {
		// TODO Batch kills.
		err = socket.Query(&killCursorsOp{[]int64{cursorId}})
		socket.Release()
	}

	iter.m.Lock()
	if err != nil && (iter.err == nil || iter.err == ErrNotFound) {
		iter.err = err
	} else if iter.err != ErrNotFound {
		err = iter.err
	}
	iter.m.Unlock()
	return err
}
func ( iter * Iter ) Close ( ) error { iter . m . Lock ( ) cursorId := iter . op . cursorId iter . op . cursorId = 0 err := iter . err iter . m . Unlock ( ) if cursorId == 0 { if err == ErrNotFound { return nil } return err } socket , err := iter . acquireSocket ( ) if err == nil { // TODO Batch kills. err = socket . Query ( & killCursorsOp { [ ] int64 { cursorId } } ) socket . Release ( ) } iter . m . Lock ( ) if err != nil && ( iter . err == nil || iter . err == ErrNotFound ) { iter . err = err } else if iter . err != ErrNotFound { err = iter . err } iter . m . Unlock ( ) return err }
// Close kills the server cursor used by the iterator, if any, and returns
// nil if no errors happened during iteration, or the actual error otherwise.
//
// Server cursors are automatically closed at the end of an iteration, which
// means close will do nothing unless the iteration was interrupted before
// the server finished sending results to the driver. If Close is not called
// in such a situation, the cursor will remain available at the server until
// the default cursor timeout period is reached. No further problems arise.
//
// Close is idempotent. That means it can be called repeatedly and will
// return the same result every time.
//
// In case a resulting document included a field named $err or errmsg, which are
// standard ways for MongoDB to report an improper query, the returned value has
// a *QueryError type.
Close kills the server cursor used by the iterator if any and returns nil if no errors happened during iteration or the actual error otherwise . Server cursors are automatically closed at the end of an iteration which means close will do nothing unless the iteration was interrupted before the server finished sending results to the driver . If Close is not called in such a situation the cursor will remain available at the server until the default cursor timeout period is reached . No further problems arise . Close is idempotent . That means it can be called repeatedly and will return the same result every time . In case a resulting document included a field named $err or errmsg which are standard ways for MongoDB to report an improper query the returned value has a * QueryError type .