0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-30 00:56:44 +01:00

Merge branch 'master' of /data/gitroot/p/

Conflicts:

	util/sock.h
This commit is contained in:
yellow 2008-02-29 18:09:19 +00:00
commit 64cf047baf
7 changed files with 95 additions and 28 deletions

View File

@ -28,7 +28,7 @@ class CursInspector : public SingleResultObjCursor {
b.append("byLocation_size", byLocation.size());
b.append("clientCursors_size", clientCursors.size());
cout << byLocation.size() << endl;
stringstream ss;
ss << '\n';
@ -113,21 +113,29 @@ void ClientCursor::cleanupByLocation(DiskLoc loc, long long cursorid) {
// found one to remove.
if( prev == 0 ) {
if( cc->nextAtThisLocation )
byLocation[loc] = cc->nextAtThisLocation;
it->second = cc->nextAtThisLocation;
// byLocation[loc] = cc->nextAtThisLocation;
else
byLocation.erase(it);
}
else {
prev->nextAtThisLocation = cc->nextAtThisLocation;
}
break;
cc->nextAtThisLocation = 0;
return;
}
cc = cc->nextAtThisLocation;
}
}
// not found!
cout << "Assertion failure - cleanupByLocation: not found " << cursorid << endl;
}
ClientCursor::~ClientCursor() {
#if defined(_WIN32)
cout << "~clientcursor " << cursorid << endl;
#endif
assert( pos != -2 );
cleanupByLocation(lastLoc, cursorid);
@ -143,11 +151,12 @@ ClientCursor::~ClientCursor() {
// note this doesn't set lastLoc -- caller should.
void ClientCursor::addToByLocation(DiskLoc cl) {
//if( 1 )
//return;
//TEMP!
assert( cursorid );
assert( nextAtThisLocation == 0 );
if( nextAtThisLocation ) {
wassert( nextAtThisLocation == 0 );
return;
}
DiskToCC::iterator j = byLocation.find(cl);
nextAtThisLocation = j == byLocation.end() ? 0 : j->second;
@ -155,6 +164,7 @@ void ClientCursor::addToByLocation(DiskLoc cl) {
}
void ClientCursor::updateLocation() {
assert( cursorid );
DiskLoc cl = c->currLoc();
// cout<< " TEMP: updateLocation last:" << lastLoc.toString() << " cl:" << cl.toString() << '\n';
@ -193,9 +203,12 @@ long long allocCursorId() {
long long x;
while( 1 ) {
x = (((long long)rand()) << 32);
x = x | (int) curTimeMillis() | 0x80000000; // last or to w make sure not zero
x = x | (int) curTimeMillis() | 0x80000000; // OR to make sure not zero
if( clientCursors.count(x) == 0 )
break;
}
#if defined(_WIN32)
cout << "alloccursorid " << x << endl;
#endif
return x;
}

View File

@ -272,7 +272,7 @@ public:
};
void listen(int port) {
cout << "db version: 27feb08.1 latent cursor fixes" << endl;
cout << "db version: leapday.1 getmore fixes" << endl;
pdfileInit();
testTheDb();
cout << curTimeMillis() % 10000 << " waiting for connections...\n" << endl;
@ -311,6 +311,7 @@ void t()
lock lk(dbMutex);
Timer t;
bool log = false;
curOp = m.data->operation;
if( m.data->operation == dbMsg ) {
ss << "msg ";
@ -332,6 +333,9 @@ void t()
}
}
else if( m.data->operation == dbQuery ) {
#if defined(_WIN32)
log = true;
#endif
receivedQuery(dbMsgPort, m, ss);
}
else if( m.data->operation == dbInsert ) {
@ -356,10 +360,12 @@ void t()
catch( AssertionException ) { cout << "Caught Assertion, continuing" << endl; }
}
else if( m.data->operation == dbGetMore ) {
log = true;
ss << "getmore ";
receivedGetMore(dbMsgPort, m);
}
else if( m.data->operation == dbKillCursors ) {
log = true;
ss << "killcursors ";
receivedKillCursors(m);
}
@ -369,7 +375,7 @@ void t()
}
int ms = t.millis();
bool log = ctr++ % 100 == 0;
log = log || ctr++ % 100 == 0;
if( log || ms > 50 ) {
ss << ' ' << t.millis() << "ms";
cout << ss.str().c_str() << endl;

View File

@ -267,9 +267,9 @@ Extent* PhysicalDataFile::newExtent(const char *ns, int approxSize) {
details->lastExtentSize = approxSize;
details->addDeletedRec(emptyLoc.drec(), emptyLoc);
cout << "*** new extent size: 0x" << hex << ExtentSize << " loc: 0x" << hex << offset << dec << endl;
cout << " emptyLoc:" << hex << emptyLoc.getOfs() << dec << endl;
cout << " " << ns << endl;
cout << "new extent size: 0x" << hex << ExtentSize << " loc: 0x" << hex << offset << dec;
cout << " emptyLoc:" << hex << emptyLoc.getOfs() << dec;
cout << ' ' << ns << endl;
return e;
}

View File

@ -548,17 +548,20 @@ assert( debug.getN() < 5000 );
(ntoreturn==0 && b.len()>1*1024*1024) ) {
/* if only 1 requested, no cursor saved for efficiency...we assume it is findOne() */
if( wantMore && ntoreturn != 1 ) {
// more...so save a cursor
ClientCursor *cc = new ClientCursor();
cc->c = c;
cursorid = allocCursorId();
cc->cursorid = cursorid;
cc->matcher = matcher;
cc->ns = ns;
cc->pos = n;
ClientCursor::add(cc);
cc->updateLocation();
cc->filter = filter;
c->advance();
if( c->ok() ) {
// more...so save a cursor
ClientCursor *cc = new ClientCursor();
cc->c = c;
cursorid = allocCursorId();
cc->cursorid = cursorid;
cc->matcher = matcher;
cc->ns = ns;
cc->pos = n;
ClientCursor::add(cc);
cc->updateLocation();
cc->filter = filter;
}
}
break;
}
@ -657,6 +660,7 @@ done:
n++;
if( (ntoreturn>0 && (n >= ntoreturn || b.len() > 16*1024*1024)) ||
(ntoreturn==0 && b.len()>1*1024*1024) ) {
c->advance();
cc->pos += n;
cc->updateLocation();
break;

View File

@ -88,7 +88,12 @@ class Cursor;
class ClientCursor {
friend class CursInspector;
public:
ClientCursor() { cursorid=0; pos=0; nextAtThisLocation=0; }
ClientCursor() {
cursorid=0; pos=0; nextAtThisLocation=0;
#if defined(_WIN32)
cout << "clientcursor() " << cursorid << endl;
#endif
}
~ClientCursor();
long long cursorid;
string ns;

View File

@ -3,6 +3,9 @@
var fail = 0;
var t = connect("test");
db=t;
core.db.db();
var z = 0;
function progress() {}// print(++z); }
@ -103,6 +106,34 @@ function testarrayindexing() {
}
}
function testgetmore() {
print("testgetmore");
drop("gm");
gm=t.gm;
for(i=0;i<50000;i++){
gm.save({a:i, b:"adsffffffffffffffffffffffffffffffffffffffffffffffff\nfffffffffffffffffffffffffffffffffffffffffffffffffffff\nfffffffffffffffffffffffffffffffff"})
}
assert(gm.find().length()==50000);
x = 0;
c=gm.find();
for(i=0;i<5000;i++) { x += c.next().a; }
assert(gm.find().length()==50000); // full iteration with a cursor already live
assert( gm.find()[10000].a == 10000 );
assert( gm.find()[29000].a == 29000 );
assert( gm.find()[9000].a == 9000 );
d=gm.find();
assert( d[20000].a==20000 );
assert( d[10000].a==10000 );
assert( d[40000].a==40000 );
assert(gm.find().length()==50000); // full iteration with a cursor already live
print( connect("intr").cursors.findOne().dump );
print("testgetmore end");
}
function testdups() {
print("testdups");
for( pass=0;pass<2;pass++ ) {
@ -175,6 +206,9 @@ function runcursors() {
function runquick() {
print("runquick");
start = Date();
testgetmore();
t.nullcheck.remove({});
t.nullcheck.save( { a : 3 } );
oneresult( t.nullcheck.find() );
@ -202,6 +236,8 @@ function runquick() {
testarrayindexing();
runcursors();
print("testdups last to go, it takes a little time...");
testdups();
@ -214,3 +250,4 @@ print("testdb.js: try runall()");
print(" runquick()");
print(" bigIndexTest()");
print(" runcursors()");
print(" testgetmore()");

View File

@ -33,15 +33,17 @@ typedef int SOCKET;
inline int getLastError() { return errno; }
inline void disableNagle(int sock) {
int x = 1;
#ifdef SOL_TCP
int level = SOL_TCP;
#else
int level = SOL_SOCKET;
#endif
if( setsockopt(sock, level, TCP_NODELAY, (char *) &x, sizeof(x)) )
if( setsockopt(sock, level, TCP_NODELAY, (char *) &x, sizeof(x)) )
cout << "ERROR: disableNagle failed" << endl;
}
}
inline void prebindOptions( int sock ){
cout << "doing prebind option" << endl;
int x = 1;