Esempio n. 1
0
/*!
  \brief Attempts to process a Request received by the GSA
*/
FSTATUS
ProcessRequest( void *ServiceContext, IBT_DGRM_ELEMENT *pDgrmList )
{
    FSTATUS Status = FSUCCESS;
    SA_MAD  *pMad = (SA_MAD *)GsiDgrmGetRecvMad(pDgrmList);

    _DBG_ENTER_LVL(_DBG_LVL_FUNC_TRACE, ProcessRequest);

    switch ( pMad->common.MgmtClass )
    {
    case MCLASS_SUBN_ADM:
        switch ( pMad->common.mr.AsReg8 )
        {
        case MMTHD_REPORT:
            Status = ProcessReport( ServiceContext, pDgrmList );
            break;

        default:
        case MMTHD_GET:
        case MMTHD_SET:
        case MMTHD_SEND:
        case MMTHD_TRAP:
        case MMTHD_TRAP_REPRESS:
        case MMTHD_GET_RESP:
        case MMTHD_REPORT_RESP:
            break;
        }
        break;

    default:
    case MCLASS_SM_LID_ROUTED:
    case MCLASS_SM_DIRECTED_ROUTE:
    case MCLASS_PERF:
    case MCLASS_BM:
    case MCLASS_DEV_MGT:
    case MCLASS_COMM_MGT:
    case MCLASS_SNMP:
    case MCLASS_DEV_CONF_MGT:
    case MCLASS_DTA:
        break;
    }

    _DBG_LEAVE_LVL( _DBG_LVL_FUNC_TRACE );
    return Status;
}
Esempio n. 2
0
	void Run()
	{
		// Set libcurl's proxy configuration
		// (This has to be done in the thread because it's potentially very slow)
		SetStatus("proxy");
		std::wstring proxy;

		{
			PROFILE2("get proxy config");
			if (sys_get_proxy_config(wstring_from_utf8(m_URL), proxy) == INFO::OK)
				curl_easy_setopt(m_Curl, CURLOPT_PROXY, utf8_from_wstring(proxy).c_str());
		}

		SetStatus("waiting");

		/*
		 * We use a semaphore to let the thread be woken up when it has
		 * work to do. Various actions from the main thread can wake it:
		 *   * SetEnabled()
		 *   * Shutdown()
		 *   * Submit()
		 *   * Retransmission timeouts, once every several seconds
		 *
		 * If multiple actions have triggered wakeups, we might respond to
		 * all of those actions after the first wakeup, which is okay (we'll do
		 * nothing during the subsequent wakeups). We should never hang due to
		 * processing fewer actions than wakeups.
		 *
		 * Retransmission timeouts are triggered via the main thread - we can't simply
		 * use SDL_SemWaitTimeout because on Linux it's implemented as an inefficient
		 * busy-wait loop, and we can't use a manual busy-wait with a long delay time
		 * because we'd lose responsiveness. So the main thread pings the worker
		 * occasionally so it can check its timer.
		 */

		// Wait until the main thread wakes us up
		while (true)
		{
			g_Profiler2.RecordRegionEnter("semaphore wait");

			ENSURE(SDL_SemWait(m_WorkerSem) == 0);

			g_Profiler2.RecordRegionLeave();

			// Handle shutdown requests as soon as possible
			if (GetShutdown())
				return;

			// If we're not enabled, ignore this wakeup
			if (!GetEnabled())
				continue;

			// If we're still pausing due to a failed connection,
			// go back to sleep again
			if (timer_Time() < m_PauseUntilTime)
				continue;

			// We're enabled, so process as many reports as possible
			while (ProcessReport())
			{
				// Handle shutdowns while we were sending the report
				if (GetShutdown())
					return;
			}
		}
	}