mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 01:21:03 +01:00
cleaning
This commit is contained in:
parent
ee902a53ef
commit
6f12a64f54
@ -76,29 +76,28 @@ namespace mongo {
|
||||
had a bug, it could (or perhaps some sort of attack situation).
|
||||
*/
|
||||
class Pointer : boost::noncopyable {
|
||||
public:
|
||||
ClientCursor *_c;
|
||||
public:
|
||||
ClientCursor * c() { return _c; }
|
||||
void release() {
|
||||
if( _c ) {
|
||||
assert( _c->_pinValue >= 100 );
|
||||
_c->_pinValue -= 100;
|
||||
_c = 0;
|
||||
}
|
||||
_c = 0;
|
||||
}
|
||||
~Pointer() { release(); }
|
||||
Pointer(long long cursorid) {
|
||||
recursive_scoped_lock lock(ccmutex);
|
||||
_c = ClientCursor::find_inlock(cursorid, true);
|
||||
if( _c ) {
|
||||
if( _c->_pinValue >= 100 ) {
|
||||
_c = 0;
|
||||
uassert(12051, "clientcursor already in use? driver problem?", false);
|
||||
uasserted(12051, "clientcursor already in use? driver problem?");
|
||||
}
|
||||
_c->_pinValue += 100;
|
||||
}
|
||||
}
|
||||
~Pointer() {
|
||||
release();
|
||||
}
|
||||
};
|
||||
|
||||
// This object assures safe and reliable cleanup of the ClientCursor.
|
||||
@ -108,15 +107,12 @@ namespace mongo {
|
||||
public:
|
||||
CleanupPointer() : _c( 0 ), _id( -1 ) {}
|
||||
void reset( ClientCursor *c = 0 ) {
|
||||
if ( c == _c ) {
|
||||
if ( c == _c )
|
||||
return;
|
||||
}
|
||||
|
||||
if ( _c ) {
|
||||
// be careful in case cursor was deleted by someone else
|
||||
ClientCursor::erase( _id );
|
||||
}
|
||||
|
||||
}
|
||||
if ( c ) {
|
||||
_c = c;
|
||||
_id = c->cursorid;
|
||||
@ -160,11 +156,10 @@ namespace mongo {
|
||||
cursorid = allocCursorId_inlock();
|
||||
clientCursorsById.insert( make_pair(cursorid, this) );
|
||||
}
|
||||
|
||||
~ClientCursor();
|
||||
|
||||
DiskLoc lastLoc() const {
|
||||
return _lastLoc;
|
||||
}
|
||||
DiskLoc lastLoc() const { return _lastLoc; }
|
||||
|
||||
shared_ptr< ParsedQuery > pq;
|
||||
shared_ptr< FieldMatcher > fields; // which fields query wants returned
|
||||
@ -214,41 +209,27 @@ namespace mongo {
|
||||
relock();
|
||||
}
|
||||
}
|
||||
|
||||
bool stillOk(){
|
||||
if ( ! _canYield )
|
||||
return true;
|
||||
|
||||
relock();
|
||||
|
||||
return ClientCursor::recoverFromYield( _data );
|
||||
}
|
||||
|
||||
void relock(){
|
||||
_unlock.reset();
|
||||
}
|
||||
|
||||
private:
|
||||
bool _canYield;
|
||||
YieldData _data;
|
||||
|
||||
const bool _canYield;
|
||||
YieldData _data;
|
||||
scoped_ptr<dbtempreleasecond> _unlock;
|
||||
|
||||
};
|
||||
|
||||
// --- some pass through helpers for Cursor ---
|
||||
|
||||
BSONObj indexKeyPattern() {
|
||||
return c->indexKeyPattern();
|
||||
}
|
||||
|
||||
bool ok(){
|
||||
return c->ok();
|
||||
}
|
||||
|
||||
bool advance(){
|
||||
return c->advance();
|
||||
}
|
||||
BSONObj indexKeyPattern() { return c->indexKeyPattern(); }
|
||||
bool ok() { return c->ok(); }
|
||||
bool advance(){ return c->advance(); }
|
||||
BSONObj current() { return c->current(); }
|
||||
|
||||
bool currentMatches(){
|
||||
if ( ! c->matcher() )
|
||||
@ -256,10 +237,6 @@ namespace mongo {
|
||||
return c->matcher()->matchesCurrent( c.get() );
|
||||
}
|
||||
|
||||
BSONObj current(){
|
||||
return c->current();
|
||||
}
|
||||
|
||||
private:
|
||||
void setLastLoc_inlock(DiskLoc);
|
||||
|
||||
|
@ -10,7 +10,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{2B262D59
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
..\tools\bridge.cpp = ..\tools\bridge.cpp
|
||||
..\tools\bsondump.cpp = ..\tools\bsondump.cpp
|
||||
..\tools\dump.cpp = ..\tools\dump.cpp
|
||||
..\tools\export.cpp = ..\tools\export.cpp
|
||||
..\tools\import.cpp = ..\tools\import.cpp
|
||||
..\tools\restore.cpp = ..\tools\restore.cpp
|
||||
|
@ -285,7 +285,7 @@ namespace mongo {
|
||||
// log() << "TEMP GETMORE " << ns << ' ' << cursorid << ' ' << pass << endl;
|
||||
exhaust = false;
|
||||
ClientCursor::Pointer p(cursorid);
|
||||
ClientCursor *cc = p._c;
|
||||
ClientCursor *cc = p.c();
|
||||
|
||||
int bufSize = 512;
|
||||
if ( cc ){
|
||||
|
Loading…
Reference in New Issue
Block a user