void AdobeReaderAction::FinishExecution(ExecutionProcess process)
{	
	Runner runner;
	vector <DWORD> processIDs = _getProcessIDs(process.GetName());

	if (_getMajorVersion() == 9)
	{
		if (processIDs.size() > 0)
		{
			OSVersion version;

			if (version.GetVersion() == WindowsXP)
			{
				runner.TerminateProcessID(processIDs.at(0));
			}
			else // Windows Vista, 7 or better
			{
				runner.RequestCloseToProcessID(processIDs.at(0), false);
			}
		}
	}
	else
	{
		for (unsigned int i = 0; i < processIDs.size(); i++)
		{
			runner.RequestQuitToProcessID(processIDs.at(i));
		}
	}
}
int main(int argc, char** argv){
  
  ros::init(argc, argv, "go_home");
  
  // Create Runner object
  Runner Robot;
  
  // Docking position is:
  //x=-0.65, y=0.02, a=-0.15
  
  // Assign input arguments to goal object
  Robot.setCurrentGoal(-0.65, 0.02, 180);
  
  // Send the goal
  Robot.sendGoal(Robot.current_goal);
  
  ros::Duration(1.0).sleep();
  
  // If successful, start docking
  if (Robot.nav_state == actionlib::SimpleClientGoalState::SUCCEEDED) {
      ROS_INFO("Beginning docking.");
      Robot.dock();
  }else {
    ROS_INFO("Did not succeed, will not dock.");
  }// end if (goal)

  return 0;
}
    Value DocumentSourceCursor::serialize(bool explain) const {
        // we never parse a documentSourceCursor, so we only serialize for explain
        if (!explain)
            return Value();

        Lock::DBRead lk(_ns);
        Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);

        ClientCursorPin pin(_cursorId);
        ClientCursor* cursor = pin.c();

        uassert(17135, "Cursor deleted. Was the collection or database dropped?",
                cursor);

        Runner* runner = cursor->getRunner();
        runner->restoreState();

        return Value(DOC(getSourceName() <<
            DOC("query" << Value(_query)
             << "sort" << (!_sort.isEmpty() ? Value(_sort) : Value())
             << "limit" << (_limit ? Value(_limit->getLimit()) : Value())
             << "fields" << (!_projection.isEmpty() ? Value(_projection) : Value())
             // << "indexOnly" << canUseCoveredIndex(cursor)
             // << "cursorType" << cursor->c()->toString()
        ))); // TODO get more plan information
    }
Beispiel #4
0
int DoRun(Runner& runner)
{
	if (g_RunningArgs.nameSuite.empty())
		runner.RunAll();
	else if (g_RunningArgs.nameCase.empty())
		runner.RunSuite(g_RunningArgs.nameSuite.c_str());
	else
		runner.RunCase(g_RunningArgs.nameSuite.c_str(), g_RunningArgs.nameCase.c_str());

	runner.Close();

	if (g_RunningArgs.flags & fPause)
	{
		puts("Press any key to exit...");

#ifdef _WINDOWS
		getch();
#else
		getchar();
#endif
		puts("\r\n");
	}

	return 0;
}
Beispiel #5
0
void ChromeAction::FinishExecution(ExecutionProcess process)
{
    if (_getProcessIDs(process.GetName()).size() > 0)
    {
        Runner runner;
        runner.RequestCloseToProcessID(_getProcessIDs(process.GetName()).at(0), true);
    }
}
Beispiel #6
0
/** G³ówna klasa programu */
int main (int argc, char* argv[])
{
	Runner* runner = new Runner;
	runner->RunProgram();
	delete runner;
	_CrtDumpMemoryLeaks();
	return 0;
}
    void DocumentSourceCursor::loadBatch() {
        if (!_cursorId) {
            dispose();
            return;
        }

        // We have already validated the sharding version when we constructed the cursor
        // so we shouldn't check it again.
        Lock::DBRead lk(_ns);
        Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);

        ClientCursorPin pin(_cursorId);
        ClientCursor* cursor = pin.c();

        uassert(16950, "Cursor deleted. Was the collection or database dropped?",
                cursor);

        Runner* runner = cursor->getRunner();
        runner->restoreState();

        int memUsageBytes = 0;
        BSONObj obj;
        Runner::RunnerState state;
        while ((state = runner->getNext(&obj, NULL)) == Runner::RUNNER_ADVANCED) {
            // TODO SERVER-11831: consider using documentFromBsonWithDeps(obj, _dependencies)

            _currentBatch.push_back(Document(obj));

            if (_limit) {
                if (++_docsAddedToBatches == _limit->getLimit()) {
                    break;
                }
                verify(_docsAddedToBatches < _limit->getLimit());
            }

            memUsageBytes += _currentBatch.back().getApproximateSize();

            if (memUsageBytes > MaxBytesToReturnToClientAtOnce) {
                // End this batch and prepare cursor for yielding.
                runner->saveState();
                cc().curop()->yielded();
                return;
            }
        }

        // If we got here, there won't be any more documents, so destroy the cursor and runner.
        _cursorId = 0;
        pin.deleteUnderlying();

        uassert(16028, "collection or index disappeared when cursor yielded",
                state != Runner::RUNNER_DEAD);

        uassert(17285, "cursor encountered an error",
                state != Runner::RUNNER_ERROR);

        massert(17286, str::stream() << "Unexpected return from Runner::getNext: " << state,
                state == Runner::RUNNER_EOF || state == Runner::RUNNER_ADVANCED);
    }
Beispiel #8
0
int _main_(int /*_argc*/, char** /*_argv*/)
{
	Runner runner;
	runner.Init();
	runner.Run();
	runner.Shutdown();

	return 0;
}
int 
Runner::runCommandLine( int argc, const char *argv[] ) const
{
   typedef std::deque<std::string> TestNames;
   Runner subrunner;
   for ( int index = 1; index < argc; ++index )
   {
      std::string opt = argv[index];
      if ( opt == "--list-tests" )
      {
         listTests();
         return 0;
      }
      else if ( opt == "--test-auto" )
      {
         preventDialogOnCrash();
      }
      else if ( opt == "--test" )
      {
         ++index;
         if ( index < argc )
         {
            unsigned int testNameIndex;
            if ( testIndex( argv[index], testNameIndex ) )
            {
               subrunner.add( tests_[testNameIndex] );
            }
            else
            {
               fprintf( stderr, "Test '%s' does not exist!\n", argv[index] );
               return 2;
            }
         }
         else
         {
            printUsage( argv[0] );
            return 2;
         }
      }
      else
      {
         printUsage( argv[0] );
         return 2;
      }
   }
   bool succeeded;
   if ( subrunner.testCount() > 0 )
   {
      succeeded = subrunner.runAllTest( subrunner.testCount() > 1 );
   }
   else
   {
      succeeded = runAllTest( true );
   }
   return succeeded ? 0 
                    : 1;
}
Beispiel #10
0
void MarketBook::fromJson(const Json::Value& json) {
    if (json.isMember("marketId")) {
        marketId = json["marketId"].asString();
    }
    if (json.isMember("isMarketDataDelayed")) {
        isMarketDataDelayed.fromJson(json["isMarketDataDelayed"]);
    }
    if (json.isMember("status")) {
        status = json["status"].asString();
    }
    if (json.isMember("betDelay")) {
        betDelay = json["betDelay"].asInt();
    }
    if (json.isMember("bspReconciled")) {
        bspReconciled.fromJson(json["bspReconciled"]);
    }
    if (json.isMember("complete")) {
        complete.fromJson(json["complete"]);
    }
    if (json.isMember("inplay")) {
        inplay.fromJson(json["inplay"]);
    }
    if (json.isMember("numberOfWinners")) {
        numberOfWinners = json["numberOfWinners"].asInt();
    }
    if (json.isMember("numberOfRunners")) {
        numberOfRunners = json["numberOfRunners"].asInt();
    }
    if (json.isMember("numberOfActiveRunners")) {
        numberOfActiveRunners = json["numberOfActiveRunners"].asInt();
    }
    if (json.isMember("lastMatchTime")) {
        strptime(json["lastMatchTime"].asString().c_str(), "%Y-%m-%dT%H:%M:%S.000Z", &lastMatchTime);
    }
    if (json.isMember("totalMatched")) {
        totalMatched = json["totalMatched"].asDouble();
    }
    if (json.isMember("totalAvailable")) {
        totalAvailable = json["totalAvailable"].asDouble();
    }
    if (json.isMember("crossMatching")) {
        crossMatching.fromJson(json["crossMatching"]);
    }
    if (json.isMember("runnersVoidable")) {
        runnersVoidable.fromJson(json["runnersVoidable"]);
    }
    if (json.isMember("version")) {
        version = json["version"].asUInt64();
    }
    if (json.isMember("runners")) {
        for (unsigned i = 0; i < json["runners"].size(); ++i) {
                Runner runner;
                runner.fromJson(json["runners"][i]);
                runners.push_back(runner);
            };
    }
}
Beispiel #11
0
int main(int argc, char* argv[])
{
	Runner<PRVertex, PRComper> runner;
	string hdfs_inpath = argv[1];
	string hdfs_outpath = argv[2];
	string local_root = "/home/yanda/tmp/iopregel2";
	bool dump_with_edges = false;
	runner.runHH(hdfs_inpath, hdfs_outpath, local_root, dump_with_edges, argc, argv); //HDFS Load, HDFS Dump
    return 0;
}
void FirefoxAction::FinishExecution(ExecutionProcess process)
{
	vector <DWORD> processIDs = _getProcessIDs(process.GetName());

	if (processIDs.size() > 0)
	{
		Runner runner;
		runner.RequestCloseToProcessID(processIDs.at(0), true);
	}
}
Beispiel #13
0
int main() {
	Runner* runner = (Runner*)new Runner();
	runner->run();

	// Pause
	int a;
	cin >> a;

	return 0;
}
Beispiel #14
0
int main(int argc, char *argv[])
{
	Runner* runner = new Runner();
	if(runner->syntaxCheck(argc, argv) == false)
		runner->printHelp();
	else
		runner->run();//switch action inside run();
	delete runner;

	return 0;
}
int main(int argc, char* argv[])
{
    Runner<IDRecVertex, IDRecComper> runner;
    string local_root = "/home/yanda/tmp/iopregel";
    //runner.run_recode(local_root, argc, argv); //local Load
    //string hdfs_inpath = "/yuzhen/toy";
    string hdfs_inpath = argv[1];
    string hdfs_outpath = argv[2];
    runner.run_recode(hdfs_inpath, local_root, argc, argv); //HDFS Load
    return 0;
}
Beispiel #16
0
//@+node:gcross.20090418183921.17: ** Suites
//@+node:gcross.20090418183921.18: *3* class SuiteBase
void SuiteBase::run(Runner& log)
{
    log.enter(*this);
    vector<TestBase*> tests_to_run;
    for (TestBase* p = tests(); p != 0; p = p->nextPointer()) {
        tests_to_run.push_back(p);
    }
    for (vector<TestBase*>::reverse_iterator pp = tests_to_run.rbegin(); pp != tests_to_run.rend(); ++pp) {
        (*pp)->run(log);
    }
    log.exit(*this);
}
Beispiel #17
0
void LapManager:: dockWhenClose(Runner &runner) {
  // Check if we're close to dock
  double delta_x = std::abs(runner.pos_x_ - dock_x_);
  double delta_y = std::abs(runner.pos_y_ - dock_y_);
        
  // Only start docking once we are close enough
  if (delta_x < dock_proximity_ && delta_y < dock_proximity_) {
    ROS_INFO("Going to try and dock");
    runner.setActionGoal(dock_x_, dock_y_, dock_yaw_);
    runner.sendActionGoal();
    runner.dock();
  }// end if
}// end dockWhenClose
    Value DocumentSourceCursor::serialize(bool explain) const {
        // we never parse a documentSourceCursor, so we only serialize for explain
        if (!explain)
            return Value();

        Status explainStatus(ErrorCodes::InternalError, "");
        scoped_ptr<TypeExplain> plan;
        {
            Lock::DBRead lk(_ns);
            Client::Context ctx(_ns, storageGlobalParams.dbpath, /*doVersion=*/false);

            ClientCursorPin pin(_cursorId);
            ClientCursor* cursor = pin.c();

            uassert(17135, "Cursor deleted. Was the collection or database dropped?",
                    cursor);

            Runner* runner = cursor->getRunner();
            runner->restoreState();

            TypeExplain* explainRaw;
            explainStatus = runner->getExplainPlan(&explainRaw);
            if (explainStatus.isOK())
                plan.reset(explainRaw);

            runner->saveState();
        }

        MutableDocument out;
        out["query"] = Value(_query);

        if (!_sort.isEmpty())
            out["sort"] = Value(_sort);

        if (_limit)
            out["limit"] = Value(_limit->getLimit());

        if (!_projection.isEmpty())
            out["fields"] = Value(_projection);

        if (explainStatus.isOK()) {
            out["plan"] = Value(extractInfo(plan));
        } else {
            out["planError"] = Value(explainStatus.toString());
        }


        return out.freezeToValue();
    }
bool MSOfficeLPIAction::_extractCabFile(wchar_t * file, wchar_t * path)
{
	Runner runnerCab;
	wchar_t szParams[MAX_PATH];
	wchar_t szApp[MAX_PATH];
	
	GetSystemDirectory(szApp, MAX_PATH);
	wcscat_s(szApp, L"\\expand.exe ");

	swprintf_s (szParams, L" %s %s -f:*", file, path);
	g_log.Log(L"MSOfficeLPIAction::_extractCabFile '%s' with params '%s'", szApp, szParams);
	runnerCab.Execute(szApp, szParams);
	runnerCab.WaitUntilFinished();
	return true;
}
Beispiel #20
0
int RunTest(const char* pcszDllPath, int nParams, const char* params[])
{
	bool fOk = CheckArgs(nParams, params);
	if (!fOk)
		return 1;

	Runner runner;

	g_RunningArgs.nameModule = pcszDllPath;

	if (!runner.TryLoad())
		return 2;

	return DoRun(runner);
}
Beispiel #21
0
int main(int, char**)
{
  Runner runner;
  int    exit_status = 1;

  Crails::environment = "test";
  Router::singleton::Initialize();
  Router::singleton::Get()->initialize();
  runner.setup();
  if (runner.execute())
    exit_status = 0;
  runner.shutdown();
  Router::singleton::Finalize();
  return exit_status;
}
QString ResultList::getItemString(ResultList::ColumnType type, QVariant* item) const
{	
	const QString resultTypeTexts[6] = {
		tr("OK"),
		tr("OT"),
		tr("MP"),
		tr("DNF"),
		tr("DISQ"),
		tr("DNS")
	};
	
	switch (type)
	{
	case ColumnRank:
		if (item->isValid() && item->toInt() > 0)
			return item->toString();
		else
			return "-";
	case ColumnCategory:
		return reinterpret_cast<AbstractCategory*>(item->value<void*>())->name;
	case ColumnRunner:
	{
		Runner* runner = reinterpret_cast<Runner*>(item->value<void*>());
		if (runner)
			return runner->getShortDesc();
		else
			return "";
	}
	case ColumnClub:
	{
		Club* club = reinterpret_cast<Club*>(item->value<void*>());
		if (club)
			return club->getName();
		else if (item->type() == QVariant::String)
			return item->toString();
		else
			return tr("- no club -");
	}
	case ColumnPoints: case ColumnPointInfo:
		return item->isValid() ? pointsToString(item->toInt(), decimal_places, decimal_factor) : "-";
	case ColumnTime:
		return item->isValid() ? timeToString(item->toInt()) : "";
	case ColumnResult:
		return resultTypeTexts[item->toInt()];
	default:
		return item->toString();
	}
}
bool AdobeReaderAction::IsIERunning()
{
	Runner runner;
	vector <DWORD> processIDs;

	processIDs = runner.GetProcessID(wstring(L"iexplore.exe"));
	if (processIDs.size() > 0)
	{
		MessageBox(NULL,
			L"Cal que tanqueu l'Internet Explorer completament per poder catalanitzar l'Adobe Reader.",
			L"Catalanitzador per al Windows",
			NULL);
		return true;
	}
	return false;
}
Beispiel #24
0
int RunTest2(void* pTestProject, int nParams, const char* params[])
{
	if (pTestProject == NULL)
	{
		ASSERT(false);
		return 2;
	}

	bool fOk = CheckArgs(nParams, params);
	if (!fOk)
		return 1;

	Runner	runner;
	runner.SetProject((ITestProject*)pTestProject);

	return DoRun(runner);
}
void OpenOfficeAction::FinishExecution(ExecutionProcess process)
{
	HWND hwndTray; 
		
	hwndTray = FindWindow( LISTENER_WINDOWCLASS, NULL);

    if (hwndTray)
	{
		SendMessage(hwndTray, RegisterWindowMessage(KILLTRAY_MESSAGE), 0, 0);
	}

	Runner runner;
	vector <DWORD> processIDs = runner.GetProcessID(wstring(SOFFICE_PROCESSNAME));

	for (unsigned int i = 0; i < processIDs.size(); i++)
	{
		runner.TerminateProcessID(processIDs.at(i));
	}
}
Beispiel #26
0
    /* must call this on a delete so we clean up the cursors. */
    void ClientCursor::aboutToDelete(const StringData& ns,
                                     const NamespaceDetails* nsd,
                                     const DiskLoc& dl) {
        // Begin cursor-only
        NoPageFaultsAllowed npfa;
        // End cursor-only

        recursive_scoped_lock lock(ccmutex);

        Database *db = cc().database();
        verify(db);

        aboutToDeleteForSharding( ns, db, nsd, dl );

        // Check our non-cached active runner list.
        for (set<Runner*>::iterator it = nonCachedRunners.begin(); it != nonCachedRunners.end();
             ++it) {

            Runner* runner = *it;
            if (0 == ns.compare(runner->ns())) {
                runner->invalidate(dl);
            }
        }

        // TODO: This requires optimization.  We walk through *all* CCs and send the delete to every
        // CC open on the db we're deleting from.  We could:
        // 1. Map from ns to open runners,
        // 2. Map from ns -> (a map of DiskLoc -> runners who care about that DL)
        //
        // We could also queue invalidations somehow and have them processed later in the runner's
        // read locks.
        for (CCById::const_iterator it = clientCursorsById.begin(); it != clientCursorsById.end();
             ++it) {

            ClientCursor* cc = it->second;
            // We're only interested in cursors over one db.
            if (cc->_db != db) { continue; }
            if (NULL == cc->_runner.get()) { continue; }
            cc->_runner->invalidate(dl);
        }
    }
void ResultList::exportToCSV(CSVFile* file)
{
	// Column names
	QStringList stringList;
	int numColumns = columnCount();
	for (int i = 0; i < numColumns; ++i)
	{
		ColumnType type = columnTypes[i];
		if (type == ColumnRunner)
			stringList << tr("First name") << tr("Surname");
		else
			stringList << columnLabel[i];
	}
	
	file->writeLine(stringList);
	stringList.clear();
	
	int numRows = rowCount();
	for (int row = 0; row < numRows; ++row)
	{
		for (int i = 0; i < numColumns; ++i)
		{
			ColumnType type = columnTypes[i];
			
			if (type == ColumnRunner)
			{
				Runner* runner = reinterpret_cast<Runner*>(getData(row, i).value<void*>());
				if (runner)
					stringList << runner->getFirstName() << runner->getLastName();
				else
					stringList << "" << "";
			}
			else
				stringList << data(index(row, i), Qt::DisplayRole).toString();
		}
		
		file->writeLine(stringList);
		stringList.clear();
	}
}
int main(int argc, char** argv)
{
  char *reporter = NULL;
  char showColors = false;

  int c, index;

  while ((c = getopt(argc, argv, "cr:")) != -1) {
    switch(c) {
      case 'c':
        showColors = true;
        break;
      case 'r':
        reporter = optarg;
        break;
    }
  }

  if (optind == argc) {
    std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
    std::cerr << "  specrunner [-c] [-r <report file>] specrunner.html ..." << std::endl;
    return 1;
  }

  QApplication app(argc, argv);
  app.setApplicationName("jasmine-headless-webkit");
  Runner runner;
  runner.setColors(showColors);

  runner.reportFile(reporter);

  for (index = optind; index < argc; index++) {
    runner.addFile(QString::fromLocal8Bit(argv[index]));
  }

  runner.go();

  return app.exec();
}
int main(int argc, char** argv)
{
  bool showColors = false;
  bool isQuiet = false;
  QString seed;
  QStack<QString> reporterFiles;

  int c, index;

  while ((c = getopt(argc, argv, "cr:s:q")) != -1) {
    switch(c) {
      case 'c':
        showColors = true;
        break;
      case 'q':
        isQuiet = true;
        break;
      case 'r':
        reporterFiles.push(QString(optarg));
        break;
      case 's':
        seed = QString(optarg);
        break;
    }
  }

  if (optind == argc) {
    std::cerr << "Run Jasmine's SpecRunner headlessly" << std::endl << std::endl;
    std::cerr << "  specrunner [-c] [-s seed] [-r report file ...] specrunner.html ..." << std::endl;
    return 1;
  }

  QApplication app(argc, argv);
  app.setApplicationName("jasmine-headless-webkit");
  Runner runner;

  runner.setColors(showColors);
  runner.setQuiet(isQuiet);
  runner.setReportFiles(reporterFiles);
  runner.setSeed(seed);

  for (index = optind; index < argc; index++) {
    runner.addFile(QString::fromLocal8Bit(argv[index]));
  }

  runner.go();

  return app.exec();
}
Beispiel #30
0
    /**
     * Also called by db/ops/query.cpp.  This is the new getMore entry point.
     */
    QueryResult* newGetMore(const char* ns, int ntoreturn, long long cursorid, CurOp& curop,
                            int pass, bool& exhaust, bool* isCursorAuthorized) {
        exhaust = false;
        int bufSize = 512 + sizeof(QueryResult) + MaxBytesToReturnToClientAtOnce;

        BufBuilder bb(bufSize);
        bb.skip(sizeof(QueryResult));

        // This is a read lock.  TODO: There is a cursor flag for not needing this.  Do we care?
        Client::ReadContext ctx(ns);

        QLOG() << "running getMore in new system, cursorid " << cursorid << endl;

        // This checks to make sure the operation is allowed on a replicated node.  Since we are not
        // passing in a query object (necessary to check SlaveOK query option), the only state where
        // reads are allowed is PRIMARY (or master in master/slave).  This function uasserts if
        // reads are not okay.
        replVerifyReadsOk();

        // A pin performs a CC lookup and if there is a CC, increments the CC's pin value so it
        // doesn't time out.  Also informs ClientCursor that there is somebody actively holding the
        // CC, so don't delete it.
        ClientCursorPin ccPin(cursorid);
        ClientCursor* cc = ccPin.c();

        // These are set in the QueryResult msg we return.
        int resultFlags = ResultFlag_AwaitCapable;

        int numResults = 0;
        int startingResult = 0;

        if (NULL == cc) {
            cursorid = 0;
            resultFlags = ResultFlag_CursorNotFound;
        }
        else {
            // Quote: check for spoofing of the ns such that it does not match the one originally
            // there for the cursor
            uassert(17011, "auth error", str::equals(ns, cc->ns().c_str()));
            *isCursorAuthorized = true;

            // TODO: fail point?

            // If the operation that spawned this cursor had a time limit set, apply leftover
            // time to this getmore.
            curop.setMaxTimeMicros(cc->getLeftoverMaxTimeMicros());
            killCurrentOp.checkForInterrupt(); // May trigger maxTimeAlwaysTimeOut fail point.

            // TODO:
            // curop.debug().query = BSONForQuery
            // curop.setQuery(curop.debug().query);

            // TODO: What is pass?
            if (0 == pass) { cc->updateSlaveLocation(curop); }

            CollectionMetadataPtr collMetadata = cc->getCollMetadata();

            // If we're replaying the oplog, we save the last time that we read.
            OpTime slaveReadTill;

            // What number result are we starting at?  Used to fill out the reply.
            startingResult = cc->pos();

            // What gives us results.
            Runner* runner = cc->getRunner();
            const int queryOptions = cc->queryOptions();

            // Get results out of the runner.
            runner->restoreState();

            BSONObj obj;
            Runner::RunnerState state;
            while (Runner::RUNNER_ADVANCED == (state = runner->getNext(&obj, NULL))) {
                // Add result to output buffer.
                bb.appendBuf((void*)obj.objdata(), obj.objsize());

                // Count the result.
                ++numResults;

                // Possibly note slave's position in the oplog.
                if (queryOptions & QueryOption_OplogReplay) {
                    BSONElement e = obj["ts"];
                    if (Date == e.type() || Timestamp == e.type()) {
                        slaveReadTill = e._opTime();
                    }
                }

                if ((ntoreturn && numResults >= ntoreturn)
                    || bb.len() > MaxBytesToReturnToClientAtOnce) {
                    break;
                }
            }

            if (Runner::RUNNER_EOF == state && 0 == numResults
                && (queryOptions & QueryOption_CursorTailable)
                && (queryOptions & QueryOption_AwaitData) && (pass < 1000)) {
                // If the cursor is tailable we don't kill it if it's eof.  We let it try to get
                // data some # of times first.
                return 0;
            }

            bool saveClientCursor = false;

            if (Runner::RUNNER_DEAD == state || Runner::RUNNER_ERROR == state) {
                // If we're dead there's no way to get more results.
                saveClientCursor = false;
                // In the old system tailable capped cursors would be killed off at the
                // cursorid level.  If a tailable capped cursor is nuked the cursorid
                // would vanish.
                // 
                // In the new system they die and are cleaned up later (or time out).
                // So this is where we get to remove the cursorid.
                if (0 == numResults) {
                    resultFlags = ResultFlag_CursorNotFound;
                }
            }
            else if (Runner::RUNNER_EOF == state) {
                // EOF is also end of the line unless it's tailable.
                saveClientCursor = queryOptions & QueryOption_CursorTailable;
            }
            else {
                verify(Runner::RUNNER_ADVANCED == state);
                saveClientCursor = true;
            }

            if (!saveClientCursor) {
                ccPin.deleteUnderlying();
                // cc is now invalid, as is the runner
                cursorid = 0;
                cc = NULL;
                QLOG() << "getMore NOT saving client cursor, ended w/state "
                       << Runner::statestr(state)
                       << endl;
            }
            else {
                // Continue caching the ClientCursor.
                cc->incPos(numResults);
                runner->saveState();
                QLOG() << "getMore saving client cursor ended w/state "
                       << Runner::statestr(state)
                       << endl;

                // Possibly note slave's position in the oplog.
                if ((queryOptions & QueryOption_OplogReplay) && !slaveReadTill.isNull()) {
                    cc->slaveReadTill(slaveReadTill);
                }

                exhaust = (queryOptions & QueryOption_Exhaust);

                // If the getmore had a time limit, remaining time is "rolled over" back to the
                // cursor (for use by future getmore ops).
                cc->setLeftoverMaxTimeMicros( curop.getRemainingMaxTimeMicros() );
            }
        }

        QueryResult* qr = reinterpret_cast<QueryResult*>(bb.buf());
        qr->len = bb.len();
        qr->setOperation(opReply);
        qr->_resultFlags() = resultFlags;
        qr->cursorId = cursorid;
        qr->startingFrom = startingResult;
        qr->nReturned = numResults;
        bb.decouple();
        QLOG() << "getMore returned " << numResults << " results\n";
        return qr;
    }