示例#1
0
const void* SipXHandleMap::removeHandle(SIPXHANDLE handle) 
{
    const void* pRC = NULL ;
    
    if (lock())
    {
        releaseHandleRef(handle);
        
        UtlInt* pCount = static_cast<UtlInt*>(mLockCountHash.findValue(&UtlInt(handle))) ;
        
        if (pCount == NULL || pCount->getValue() < 1)
        {
            UtlInt key(handle) ;
            UtlVoidPtr* pValue ;
            
            pValue = (UtlVoidPtr*) findValue(&key) ;
            if (pValue != NULL)
            {
                pRC = pValue->getValue() ;                
                destroy(&key) ;
            }

            if (pCount)
            {
                mLockCountHash.destroy(&UtlInt(handle));
            }
        }
    
        unlock() ;
    }

    return pRC ;
}
示例#2
0
void SipXHandleMap::addHandleRef(SIPXHANDLE hHandle)
{
    mLock.acquire();

    mLockCountHash.findValue(&UtlInt(hHandle));
    UtlInt* count = static_cast<UtlInt*>(mLockCountHash.findValue(&UtlInt(hHandle))) ;
    if (count == NULL)
    {
        mLockCountHash.insertKeyAndValue(new UtlInt(hHandle), new UtlInt(1));
    }
    else
    {
        count->setValue(count->getValue() + 1);
    }
    mLock.release();
}
示例#3
0
bool SipXHandleMap::addHandleRef(SIPXHANDLE hHandle)
{
    bool bRC = false ;

    if (lock())
    {
        mLockCountHash.findValue(&UtlInt(hHandle));
        UtlInt* count = static_cast<UtlInt*>(mLockCountHash.findValue(&UtlInt(hHandle))) ;
        if (count == NULL)
        {
            mLockCountHash.insertKeyAndValue(new UtlInt(hHandle), new UtlInt(1));
        }
        else
        {
            count->setValue(count->getValue() + 1);
        }
    
        bRC = unlock() ;
    }

    return bRC ;
}
示例#4
0
void SipXHandleMap::releaseHandleRef(SIPXHANDLE hHandle)
{
    lock();
    UtlInt* pCount = static_cast<UtlInt*>(mLockCountHash.findValue(&UtlInt(hHandle))) ;
    if (pCount == NULL)
    {
        mLockCountHash.insertKeyAndValue(new UtlInt(hHandle), new UtlInt(0));
    }
    else
    {
        pCount->setValue(pCount->getValue() - 1);
    }
    unlock();
}
示例#5
0
bool AlarmRpcGetAlarmCount::execute(const HttpRequestContext& requestContext,
                                     UtlSList& params,
                                     void* userData,
                                     XmlRpcResponse& response,
                                     ExecutionStatus& status)
{
   bool result = false;
   status = XmlRpcMethod::FAILED;

   if (!params.at(0) || !params.at(0)->isInstanceOf(UtlString::TYPE))
   {
      handleMissingExecuteParam(name(), PARAM_NAME_CALLING_HOST, response, status);
   }
   else
   {
      UtlString* pCallingHostname = dynamic_cast<UtlString*>(params.at(0));

      if (1 != params.entries())
      {
         handleExtraExecuteParam(name(), response, status);
      }
      else
      {
         SipxRpc* pSipxRpcImpl = ((SipxRpc *)userData);

         if(validCaller(requestContext, *pCallingHostname, response, *pSipxRpcImpl, name()))
         {
            OsSysLog::add(FAC_ALARM, PRI_INFO,
                          "AlarmRpc::getAlarmCount: host %s requested alarm count",
                          pCallingHostname->data()
                          );

            // Get the count of alarms since last restart
            UtlInt alarm_count;
            alarm_count = UtlInt(cAlarmServer::getInstance()->getAlarmCount());

            // Construct and set the response.
            response.setResponse(&alarm_count);
            status = XmlRpcMethod::OK;
            result = true;

         }
      }
   }

   return result;
}
示例#6
0
bool SipXHandleMap::releaseHandleRef(SIPXHANDLE hHandle)
{
    bool bRC = false ;

    if (lock())
    {
        UtlInt* pCount = static_cast<UtlInt*>(mLockCountHash.findValue(&UtlInt(hHandle))) ;
        if (pCount == NULL)
        {
            mLockCountHash.insertKeyAndValue(new UtlInt(hHandle), new UtlInt(0));
        }
        else
        {
            pCount->setValue(pCount->getValue() - 1);
        }
        bRC = unlock();
    }
    return bRC ;
}