//instance.cpp文件第224行
assembleResponse( Message &m, DbResponse &dbresponse, const SockAddr &client ) {
.....
try {
if ( op == dbInsert ) { //添加记录操作
receivedInsert(m, currentOp);
}
else if ( op == dbUpdate ) { //更新记录
receivedUpdate(m, currentOp);
}
else if ( op == dbDelete ) { //删除记录
receivedDelete(m, currentOp);
}
else if ( op == dbKillCursors ) { //删除Cursors(游标)对象
currentOp.ensureStarted();
logThreshold = 10;
ss advance();//将游标跳转到下一条记录
if ( nscanned % 256 == 0 && ! atomic ) {
if ( cc.get() == 0 ) {
shared_ptr< Cursor > cPtr = c;
cc.reset( new ClientCursor( QueryOption_NoCursorTimeout , cPtr , ns ) );
}
if ( ! cc->yield() ) {
cc.release();
// TODO should we assert or something?
break;
}
if ( !c->ok() ) {
break;
}
}
continue;
}
Record *r = c->_current();//游标当前所指向的记录
DiskLoc loc = c->currLoc();//游标当前所指向的记录所在地址
// TODO Maybe this is unnecessary since we have seenObjects
if ( c->getsetdup( loc ) ) {//判断当前记录是否是重复
c->advance();
continue;
}
BSONObj js(r);
BSONObj pattern = patternOrig;
if ( logop ) {//记录日志
BSONObjBuilder idPattern;
BSONElement id;
// NOTE: If the matching object lacks an id, we'll log
// with the original pattern. This isn't replay-safe.
// It might make sense to suppress the log instead
// if there's no id.
if ( js.getObjectID( id ) ) {
idPattern.append( id );
pattern = idPattern.obj();
}
else {
uassert( 10157 , "multi-update requires all modified objects to have an _id" , ! multi );
}
}
if ( profile )
ss unindex(idx.head, idx, *changes[x].removed, dl);
}
catch (AssertionException&) {
ss