Exemplo n.º 1
0
bool LLTrackingData::haveTrackingInfo()
{
	LLViewerObject* object = gObjectList.findObject(mAvatarID);
	if(object && !object->isDead())
	{
		mCoarseLocationTimer.checkExpirationAndReset(COARSE_FREQUENCY);
		mUpdateTimer.setTimerExpirySec(FIND_FREQUENCY);
		mAgentGone.setTimerExpirySec(OFFLINE_SECONDS);
		mHaveInfo = true;
		return true;
	}
	if(mHaveCoarseInfo &&
	   !mCoarseLocationTimer.checkExpirationAndReset(COARSE_FREQUENCY))
	{
		// if we reach here, then we have a 'recent' coarse update
		mUpdateTimer.setTimerExpirySec(FIND_FREQUENCY);
		mAgentGone.setTimerExpirySec(OFFLINE_SECONDS);
		return true;
	}
	if(mUpdateTimer.checkExpirationAndReset(FIND_FREQUENCY))
	{
		LLAvatarTracker::instance().findAgent();
		mHaveCoarseInfo = false;
	}
	if(mAgentGone.checkExpirationAndReset(OFFLINE_SECONDS))
	{
		mHaveInfo = false;
		mHaveCoarseInfo = false;
	}
	return mHaveInfo;
}
Exemplo n.º 2
0
void LLTrackingData::setTrackedCoarseLocation(const LLVector3d& global_pos)
{
	mCoarseLocationTimer.setTimerExpirySec(COARSE_FREQUENCY);
	mGlobalPositionEstimate = global_pos;
	mHaveInfo = true;
	mHaveCoarseInfo = true;
}
void LLUpdaterServiceImpl::restartTimer(unsigned int seconds)
{
    LL_INFOS("UpdaterService") << "will check for update again in " <<
                               seconds << " seconds" << LL_ENDL;
    mTimer.start();
    mTimer.setTimerExpirySec((F32)seconds);
    LLEventPumps::instance().obtain("mainloop").listen(
        sListenerName, boost::bind(&LLUpdaterServiceImpl::onMainLoop, this, _1));
}
Exemplo n.º 4
0
void LLTrackingData::agentFound(const LLUUID& prey,
								const LLVector3d& estimated_global_pos)
{
	if(prey != mAvatarID)
	{
		llwarns << "LLTrackingData::agentFound() - found " << prey
				<< " but looking for " << mAvatarID << llendl;
	}
	mHaveInfo = true;
	mAgentGone.setTimerExpirySec(OFFLINE_SECONDS);
	mGlobalPositionEstimate = estimated_global_pos;
}
Exemplo n.º 5
0
F32 pump_loop(LLPumpIO* pump, F32 seconds)
{
	LLTimer timer;
	timer.setTimerExpirySec(seconds);
	while(!timer.hasExpired())
	{
		LLFrameTimer::updateFrameTime();			
		pump->pump();
		pump->callback();
	}
	return timer.getElapsedTimeF32();
}
//static
void LLMarketplaceInventoryImporter::update()
{
	if (instanceExists())
	{
		static LLTimer update_timer;
		if (update_timer.hasExpired())
		{
			LLMarketplaceInventoryImporter::instance().updateImport();
			//static LLCachedControl<F32> MARKET_IMPORTER_UPDATE_FREQUENCY("MarketImporterUpdateFreq", 1.0f);
			update_timer.setTimerExpirySec(MARKET_IMPORTER_UPDATE_FREQUENCY);
		}
	}
}
void timeDelay(LLCoros::self& self, LLPanelMarketplaceOutbox* outboxPanel)
{
	waitForEventOn(self, "mainloop");

	LLTimer delayTimer;
	delayTimer.reset();
	delayTimer.setTimerExpirySec(5.0f);

	while (!delayTimer.hasExpired())
	{
		waitForEventOn(self, "mainloop");
	}

	outboxPanel->onSyncComplete();

	gTimeDelayDebugFunc = "";
}
		void runThePump(float timeout = 100.0f)
		{
			LLTimer timer;
			timer.setTimerExpirySec(timeout);

			while(!mSawCompleted && !mSawCompletedHeader && !timer.hasExpired())
			{
				if (mServerPump)
				{
					mServerPump->pump();
					mServerPump->callback();
				}
				if (mClientPump)
				{
					mClientPump->pump();
					mClientPump->callback();
				}
			}
		}
Exemplo n.º 9
0
// blocking asset fetch which bypasses the VFS
// this is a very limited function for use by the simstate loader and other one-offs
S32 LLHTTPAssetStorage::getURLToFile(const LLUUID& uuid, LLAssetType::EType asset_type, const LLString &url, const char *filename, progress_callback callback, void *userdata)
{
	// *NOTE: There is no guarantee that the uuid and the asset_type match
	// - not that it matters. - Doug
	lldebugs << "LLHTTPAssetStorage::getURLToFile() - " << url << llendl;

	FILE *fp = LLFile::fopen(filename, "wb"); /*Flawfinder: ignore*/
	if (! fp)
	{
		llwarns << "Failed to open " << filename << " for writing" << llendl;
		return LL_ERR_ASSET_REQUEST_FAILED;
	}

	// make sure we use the normal curl setup, even though we don't really need a request object
	LLHTTPAssetRequest req(this, uuid, asset_type, RT_DOWNLOAD, url.c_str(), mCurlMultiHandle);
	req.mFP = fp;
	
	req.setupCurlHandle();
	curl_easy_setopt(req.mCurlHandle, CURLOPT_FOLLOWLOCATION, TRUE);
	curl_easy_setopt(req.mCurlHandle, CURLOPT_WRITEFUNCTION, &curlFileDownCallback);
	curl_easy_setopt(req.mCurlHandle, CURLOPT_WRITEDATA, req.mCurlHandle);

	curl_multi_add_handle(mCurlMultiHandle, req.mCurlHandle);
	llinfos << "Requesting as file " << req.mURLBuffer << llendl;

	// braindead curl loop
	int queue_length;
	CURLMsg *curl_msg;
	LLTimer timeout;
	timeout.setTimerExpirySec(GET_URL_TO_FILE_TIMEOUT);
	bool success = false;
	S32 xfer_result = 0;
	do
	{
		curl_multi_perform(mCurlMultiHandle, &queue_length);
		curl_msg = curl_multi_info_read(mCurlMultiHandle, &queue_length);

		if (callback)
		{
			callback(userdata);
		}

		if ( curl_msg && (CURLMSG_DONE == curl_msg->msg) )
		{
			success = true;
		}
		else if (timeout.hasExpired())
		{
			llwarns << "Request for " << url << " has timed out." << llendl;
			success = false;
			xfer_result = LL_ERR_ASSET_REQUEST_FAILED;
			break;
		}
	} while (!success);

	if (success)
	{
		long curl_result = 0;
		curl_easy_getinfo(curl_msg->easy_handle, CURLINFO_HTTP_CODE, &curl_result);
		
		if (curl_result == HTTP_OK && curl_msg->data.result == CURLE_OK)
		{
			S32 size = ftell(req.mFP);
			if (size > 0)
			{
				// everything seems to be in order
				llinfos << "Success downloading " << req.mURLBuffer << " to file, size " << size << llendl;
			}
			else
			{
				llwarns << "Found " << req.mURLBuffer << " to be zero size" << llendl;
				xfer_result = LL_ERR_ASSET_REQUEST_FAILED;
			}
		}
		else
		{
			xfer_result = curl_result == HTTP_MISSING ? LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE : LL_ERR_ASSET_REQUEST_FAILED;
			llinfos << "Failure downloading " << req.mURLBuffer << 
				" with result " << curl_easy_strerror(curl_msg->data.result) << ", http result " << curl_result << llendl;
		}
	}

	fclose(fp);
	if (xfer_result)
	{
		LLFile::remove(filename);
	}
	return xfer_result;
}
Exemplo n.º 10
0
// Static
//	Called from MAIN thread
void FLLua::execClientEvents()
{
	if(!sInstance)
	{
		llinfos << "LUA isn't running yet." << llendl;
		return;
	}
	if(sInstance->mPendingEvents)
	{
		lldebugs << __LINE__ << ": Events pending.  Iterating through events." << llendl;
		sInstance->mPendingEvents=false;
		sInstance->lockData();
		while(!sInstance->mQueuedEvents.empty())
		{
#ifdef FL_PRI_EVENTS
			lldebugs << __LINE__ << ": Acquiring highest-priority event." << llendl;
			CB_Base *cb=sInstance->mQueuedEvents.top();
#else
			lldebugs << __LINE__ << ": Acquiring first event in queue." << llendl;
			CB_Base *cb=sInstance->mQueuedEvents.front();
#endif
			if(!cb)
			{
				llwarns << "Invalid pointer to event!" << llendl;
			} else {
				lldebugs << __LINE__ << ": Calling event." << llendl;
				cb->OnCall();
				delete cb;
			}
			sInstance->mQueuedEvents.pop();
		}
		sInstance->unlockData();
	}
	if(sInstance->isPaused())
	{
		if(sInstance->mAllowPause) //shouldn't ever happen.
		{
			sInstance->unpause();
			return;
		}
		int yields=0;
		LLTimer timer;
		timer.setTimerExpirySec(.25);
		while(!sInstance->mAllowPause)//mAllowPause == true when Lua thread finishes loop.
		{
			sInstance->unpause();
			yield(); //Hopefully let the Lua thread resume
			yields++;
			if(timer.hasExpired())
			{
				LL_WARNS("Lua") << "Aborting critical section after " 
					<< timer.getElapsedTimeF64()*(F64)1000.f << "ms " << llendl;
				sInstance->mAllowPause=true; // NOTE: Lua taking too much time. Force new critical requests
											 // to next frame.
				break;
			}
		}
		int sec=sInstance->mCriticalSections;
		if(sec)	//Main has resumed with Lua in a critical section. Not thread safe.
			LL_WARNS("Lua") << sec << " critical sections active. Unsafe resume!" << llendl;
		LL_INFOS("Lua") << "Finished critical section after " 
			<< timer.getElapsedTimeF64()*(F64)1000.f << "ms. Yields=" << yields << llendl;
	}	
}