Ejemplo n.º 1
0
bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)
{
	if(mTimer.getStarted() && mTimer.hasExpired())
	{
		stopTimer();

		// Check for failed install.
		if(LLFile::isfile(ll_install_failed_marker_path()))
		{
			int requiredValue = 0; 
			{
				llifstream stream(ll_install_failed_marker_path());
				stream >> requiredValue;
				if(stream.fail()) requiredValue = 0;
			}
			// TODO: notify the user.
			llinfos << "found marker " << ll_install_failed_marker_path() << llendl;
			llinfos << "last install attempt failed" << llendl;
			LLFile::remove(ll_install_failed_marker_path());
			
			LLSD event;
			event["type"] = LLSD(LLUpdaterService::INSTALL_ERROR);
			event["required"] = LLSD(requiredValue);
			LLEventPumps::instance().obtain(LLUpdaterService::pumpName()).post(event);
			
			setState(LLUpdaterService::TERMINAL);
		}
		else
		{
bool LLUpdaterServiceImpl::onMainLoop(LLSD const & event)
{
    if(mTimer.getStarted() && mTimer.hasExpired())
    {
        stopTimer();

        // Check for failed install.
        if(LLFile::isfile(ll_install_failed_marker_path()))
        {
            LL_DEBUGS("UpdaterService") << "found marker " << ll_install_failed_marker_path() << LL_ENDL;
            int requiredValue = 0;
            {
                llifstream stream(ll_install_failed_marker_path().c_str());
                stream >> requiredValue;
                if(stream.fail())
                {
                    requiredValue = 0;
                }
            }
            // TODO: notify the user.
            LL_WARNS("UpdaterService") << "last install attempt failed" << LL_ENDL;;
            LLFile::remove(ll_install_failed_marker_path());

            LLSD event;
            event["type"] = LLSD(LLUpdaterService::INSTALL_ERROR);
            event["required"] = LLSD(requiredValue);
            LLEventPumps::instance().obtain(LLUpdaterService::pumpName()).post(event);

            setState(LLUpdaterService::TERMINAL);
        }
        //<FS:TM> 3.6.4 check this, commented out to compile
        //else
        //{
        //	std::string query_url = LLGridManager::getInstance()->getUpdateServiceURL();
        //	if ( !query_url.empty() )
        //	{
        //		mUpdateChecker.checkVersion(query_url, mChannel, mVersion,
        //									mPlatform, mPlatformVersion, mUniqueId,
        //									mWillingToTest);
        //		setState(LLUpdaterService::CHECKING_FOR_UPDATE);
        //	}
        //	else
        //	{
        //		LL_WARNS("UpdaterService")
        //			<< "No updater service defined for grid '" << LLGridManager::getInstance()->getGrid()
        //			<< "' will check again in " << mCheckPeriod << " seconds"
        //			<< LL_ENDL;
        //		// Because the grid can be changed after the viewer is started (when the first check takes place)
        //		// but before the user logs in, the next check may be on a different grid, so set the retry timer
        //		// even though this check did not happen.  The default time is once an hour, and if we're not
        //		// doing the check anyway the performance impact is completely insignificant.
        //		restartTimer(mCheckPeriod);
        //	}
        //}
    }
Ejemplo n.º 3
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();
				}
			}
		}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
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;
	}	
}