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

cursor cleanup

This commit is contained in:
Dwight 2008-02-13 00:26:39 -05:00
parent 4f4c54fcbb
commit b59d9b5f65
4 changed files with 31 additions and 1 deletions

View File

@ -127,6 +127,15 @@ struct EmptyObject {
} emptyObject;
#pragma pack(pop)
void killCursors(int n, long long *ids);
void receivedKillCursors(Message& m) {
int *x = (int *) m.data->_data;
x++; // reserved
int n = *x++;
assert( n >= 1 && n <= 2000 );
killCursors(n, (long long *) x);
}
void receivedUpdate(Message& m) {
DbMessage d(m);
const char *ns = d.getns();
@ -313,6 +322,10 @@ void t()
ss << "getmore ";
receivedGetMore(dbMsgPort, m);
}
else if( m.data->operation == dbKillCursors ) {
ss << "killcursors ";
receivedKillCursors(m);
}
else {
cout << " operation isn't supported ?" << endl;
}

View File

@ -583,6 +583,18 @@ QueryResult* runQuery(const char *ns, int ntoskip, int ntoreturn, JSObj jsobj,
return qr;
}
void killCursors(int n, long long *ids) {
int k = 0;
for( int i = 0; i < n; i++ ) {
CCMap::iterator it = clientCursors.find(ids[i]);
if( it != clientCursors.end() ) {
clientCursors.erase(it);
k++;
}
}
cout << "killCursors: found " << k << " of " << n << endl;
}
QueryResult* getMore(const char *ns, int ntoreturn, long long cursorid) {
// cout << "getMore ns:" << ns << " ntoreturn:" << ntoreturn << " cursorid:" <<

View File

@ -33,6 +33,10 @@
string collection; // redundant, might use for security.
int nToReturn;
int64 cursorID;
dbKillCursors=2007
int reserved;
int n;
int64 cursorIDs[n];
Note that on Update, there is only one object, which is different
from insert where you can pass a list of objects to insert in the db.

View File

@ -56,7 +56,8 @@ enum Operations {
// dbGetByOID = 2003,
dbQuery = 2004,
dbGetMore = 2005,
dbDelete = 2006
dbDelete = 2006,
dbKillCursors = 2007
};
struct MsgData {