コード例 #1
0
ファイル: ADBFilter.cpp プロジェクト: fanliaokeji/lvdun
//不弹过滤框,只有在VideoState里存在且等于2的才不弹
static bool isMatchState(std::vector<std::string> & v_domain)
{
	readLock rdLock(rw_cfgmutex);
	for (std::vector<std::string>::const_iterator c_iter = v_domain.begin();c_iter!= v_domain.end();c_iter++)
	{
		ConfigRuleMap::iterator map_iter =map_VideoState.find(*c_iter);
		if (map_iter != map_VideoState.end() && map_iter->second == 2)
		{
			return false;
		}
		
	}
	return true; 
}
コード例 #2
0
ファイル: AttributesImpl.cpp プロジェクト: mycp/mycp
bool AttributesImpl::getBPropertys(std::vector<cgcKeyValue::pointer>& outValues) const
{
	char buffer[24];
	BoostReadLock rdLock(const_cast<boost::shared_mutex&>(m_bigintPropertys.mutex()));
	CLockMultiMap<bigint, cgcValueInfo::pointer>::const_iterator iter = m_bigintPropertys.begin();
	for (; iter!=m_bigintPropertys.end(); iter++)
	{
//#ifdef WIN32
//		sprintf(buffer, "%I64d", iter->first);
//#else
		sprintf(buffer, "%lld", iter->first);
//#endif
		 outValues.push_back(CGC_KEYVALUE(buffer, iter->second));
	}
	return !outValues.empty();
	//return !m_bigintPropertys.empty();
}
コード例 #3
0
ファイル: FilterManager.cpp プロジェクト: fanliaokeji/lvdun
int FilterManager::checkConfigHost(const Url & url,bool &bFind,std::string &strMatchHost,int cfgFlag)
{
	readLock rdLock(rw_cfgmutex);
	std::string res;
	StringVector dotsplits;
	boost::split(dotsplits,url.GetHost(),boost::is_any_of("."));
	if(dotsplits.size()<=1) //domain error? no dot? at least g.cn
		return false;
	int ignore=2;
	std::string l2domain=dotsplits[dotsplits.size()-2];
	if(l2domain =="com" ||
		l2domain=="net" ||
		l2domain=="org" ||
		l2domain=="edu")
		ignore=3;
	for(int i=dotsplits.size()-ignore;i>=0;i--) 
	{
		std::string domain=dotsplits[i];
		for(int j=i+1;j<dotsplits.size();j++) {
			domain=domain+"."+dotsplits[j];
		}
		if (cfgFlag & CFG_CHECK_WHITE)
		{
			ConfigRuleMap::iterator it_White=this->m_ConfigWhiteRules.find(domain);
			if(it_White!=m_ConfigWhiteRules.end()) 
			{
				bFind = true;
				return 0;
			}

		}	

		if (cfgFlag & CFG_CHECK_VIDEO)
		{
			ConfigRuleMap::iterator it_video=map_VideoState.find(domain);
			if(it_video!=map_VideoState.end()) 
			{
				strMatchHost = domain;
				bFind = true;
				return it_video->second;
			}
		}
	}
	return 0;
}
コード例 #4
0
ファイル: log.cpp プロジェクト: gema-arta/zim-vendor
  Logger* Logger::getCategoryLogger(const std::string& category)
  {
    if (!enabled)
      return 0;

    // search existing Logger
    ReadLock rdLock(rwmutex);

    loggers_type::iterator lower_bound_it = getCacheLoggers().begin();
    while (lower_bound_it != getCacheLoggers().end()
        && (*lower_bound_it)->getCategory() < category)
      ++lower_bound_it;

    if (lower_bound_it != getCacheLoggers().end()
     && (*lower_bound_it)->getCategory() == category)
        return *lower_bound_it;

    // Logger not in list - change to write-lock
    rdLock.unlock();
    WriteLock wrLock(rwmutex);

    // we have to do it again after gaining write-lock
    lower_bound_it = getCacheLoggers().begin();
    while (lower_bound_it != getCacheLoggers().end()
        && (*lower_bound_it)->getCategory() < category)
      ++lower_bound_it;

    if (lower_bound_it != getCacheLoggers().end()
     && (*lower_bound_it)->getCategory() == category)
        return *lower_bound_it;

    // Logger still not in list, but we have a position to insert

    log_level_type base_level = getBaseLogLevel(category);

    // insert the new Logger in list and return pointer to the new list-element
    return *(getCacheLoggers().insert(lower_bound_it, new LoggerImpl(category, base_level)));
  }