bool MsaaIdGenerator::IsIDForThisContentProcess(uint32_t aID) { MOZ_ASSERT(XRE_IsContentProcess()); detail::MsaaIDCracker cracked(aID); return cracked.GetContentProcessId() == ResolveContentProcessID(); }
bool MsaaIdGenerator::IsIDForContentProcess(uint32_t aID, dom::ContentParentId aIPCContentProcessId) { MOZ_ASSERT(XRE_IsParentProcess()); detail::MsaaIDCracker cracked(aID); return cracked.GetContentProcessId() == GetContentProcessIDFor(aIPCContentProcessId); }
bool MsaaIdGenerator::ReleaseID(uint32_t aID) { MOZ_ASSERT(aID != AccessibleWrap::kNoID); detail::MsaaIDCracker cracked(aID); if (cracked.GetContentProcessId() != ResolveContentProcessID()) { return false; } mIDSet.ReleaseID(cracked.GetUniqueId()); return true; }
void MsaaIdGenerator::ReleaseID(AccessibleWrap* aAccWrap) { MOZ_ASSERT(aAccWrap); uint32_t id = aAccWrap->GetExistingID(); MOZ_ASSERT(id != AccessibleWrap::kNoID); detail::MsaaIDCracker cracked(id); if (cracked.GetContentProcessId() != ResolveContentProcessID()) { // This may happen if chrome holds a proxy whose ID was originally generated // by a content process. Since ReleaseID only has meaning in the process // that originally generated that ID, we ignore ReleaseID calls for any ID // that did not come from the current process. MOZ_ASSERT(aAccWrap->IsProxy()); return; } mIDSet.ReleaseID(cracked.GetUniqueId()); }
bool MsaaIdGenerator::IsChromeID(uint32_t aID) { detail::MsaaIDCracker cracked(aID); return cracked.GetContentProcessId() == 0; }
// Running the service bool WebServiceServer::RunService() { // Configure our threadpool if(m_pool == nullptr) { m_pool = new ThreadPool(); m_poolOwner = true; } // Setting the correct parameters if(m_maxThreads) { m_pool->TrySetMaximum(m_maxThreads); } // Starting the logfile if(m_log == nullptr) { m_logOwner = true; m_log = new LogAnalysis("Webservice: " + m_name); if(!m_logFilename.IsEmpty()) { m_log->SetLogFilename(m_logFilename); } } // Default is logging in file, propagate that setting m_log->SetLogLevel(m_logLevel); // Start right type of server if not already given. if(m_httpServer == nullptr) { m_httpServer = new HTTPServerMarlin(m_name); m_serverOwner = true; m_httpServer->SetWebroot(m_webroot); } else { // Use the webroot of the existing server! m_webroot = m_httpServer->GetWebroot(); } // Try to set our caching policy m_httpServer->SetCachePolicy(m_cachePolicy,m_cacheSeconds); // Set our logfile m_httpServer->SetLogging(m_log); m_httpServer->SetLogLevel(m_logLevel); // Use our error reporting facility if(m_errorReport) { m_httpServer->SetErrorReport(m_errorReport); } // Make sure the server is initialized m_httpServer->Initialise(); // Starting a WSDL StartWsdl(); // Try to read an external WSDL if(!m_externalWsdl.IsEmpty()) { m_generateWsdl = false; if(m_wsdl->ReadWSDLFile(m_externalWsdl) == false) { m_errorMessage.Format("ERROR reading WSDL file: %s\n",m_externalWsdl.GetString()); m_errorMessage += m_wsdl->GetErrorMessage(); m_log->AnalysisLog(__FUNCTION__,LogType::LOG_ERROR,false,m_errorMessage); return false; } } // Init the WSDL cache for this service m_wsdl->SetWebroot(m_webroot); m_wsdl->SetTargetNamespace(m_targetNamespace); m_wsdl->SetService(m_name,m_url); m_wsdl->SetServicePostfix(m_servicePostfix); m_wsdl->SetLogAnalysis(m_log); // Try to generate the WSDL if(m_generateWsdl && m_wsdl->GenerateWSDL() == false) { m_errorMessage.Format("Cannot start the service. No legal WSDL generated for: %s",m_url.GetString()); m_log->AnalysisLog(__FUNCTION__, LogType::LOG_ERROR,false,m_errorMessage); return false; } // Analyze the URL CrackedURL cracked(m_url); if(cracked.Valid() == false) { m_errorMessage.Format("WebServiceServer has no legal URL to run on: %s",m_url.GetString()); m_log->AnalysisLog(__FUNCTION__,LogType::LOG_ERROR,false,m_errorMessage); return false; } // Keep the absolute path in separate form m_absPath = cracked.m_path; if(m_absPath.Right(1) != "/") { m_absPath += "/"; } // Creating a HTTP site m_site = m_httpServer->CreateSite(m_channelType ,cracked.m_secure ,cracked.m_port ,cracked.m_path ,m_subsite); if(m_site == nullptr) { m_errorMessage.Format("Cannot register an HTTP channel on this machine for URL: %s",m_url.GetString()); m_log->AnalysisLog(__FUNCTION__, LogType::LOG_ERROR,false,m_errorMessage); return false; } // Setting the service as the payload!! // Used in the SiteHandlerSoapWSService m_site->SetPayload(this); // Read the general settings first ReadingWebconfig(); // Standard text content types m_site->AddContentType("", "text/xml"); // SOAP 1.0 / 1.1 m_site->AddContentType("xml","application/soap+xml"); // SOAP 1.2 m_site->SetEncryptionLevel(m_securityLevel); m_site->SetEncryptionPassword(m_enc_password); m_site->SetAsync(m_asyncMode); m_site->SetAuthenticationScheme(m_authentScheme); m_site->SetAuthenticationRealm(m_authentRealm); m_site->SetAuthenticationDomain(m_authentDomain); m_site->SetReliable(m_reliable); if(m_reliable) { m_site->SetReliableLogIn(m_reliableLogin); } // If already set, pass on the SOAP handler // It's always the POST handler! if(m_soapHandler) { m_site->SetHandler(HTTPCommand::http_post,m_soapHandler); } else { // If not use the default WSService handler m_soapHandler = new SiteHandlerSoapWSService(); m_site->SetHandler(HTTPCommand::http_post,m_soapHandler); } // If already set, pass on the GET handler if(m_getHandler) { m_site->SetHandler(HTTPCommand::http_get,m_getHandler); } else if(m_jsonTranslation) { // If JSON/SOAP translation: provide a handler for that m_getHandler = new SiteHandlerJson2Soap(); m_site->SetHandler(HTTPCommand::http_get,m_getHandler); } else if(m_wsdl->GetOperationsCount() > 0) { // If not, use the default GetWSService handler // but only if we generate a WSDL for the users m_getHandler = new SiteHandlerGetWSService(); m_site->SetHandler(HTTPCommand::http_get,m_getHandler); } // If set, pass on the PUT handler if(m_putHandler) { m_site->SetHandler(HTTPCommand::http_put,m_putHandler); } // Adding the extra content types to the site for(auto& ctype : m_contentTypes) { m_site->AddContentType(ctype.first,ctype.second.GetContentType()); } // New: Explicit starting the site for HTTP API Version 2.0 if(m_site->StartSite() == false) { m_errorMessage.Format("Cannot start HTTPSite for webservice server on: %s",m_url.GetString()); m_log->AnalysisLog(__FUNCTION__, LogType::LOG_ERROR,false,m_errorMessage); return false; } // Only starting the server if no errors found if(m_httpServer->GetLastError() == NO_ERROR) { // Go run our service!! if(m_httpServer->GetIsRunning() == false) { m_httpServer->Run(); } } else { m_errorMessage.Format("Cannot start HTTPServer. Server in error state. Error %lu: %s" ,m_httpServer->GetLastError() ,GetLastErrorAsString(m_httpServer->GetLastError()).GetString()); m_log->AnalysisLog(__FUNCTION__, LogType::LOG_ERROR,false,m_errorMessage); return false; } // Now legally running return (m_isRunning = true); }
void Vivarium::run() { std::ofstream cracked(setting::cracked_file.c_str()); std::mutex pool_mutex; std::thread user_input; if(setting::interactive) user_input = std::thread ( [this,&pool_mutex]() { while(true) { if(setting::verbose) std::cerr << "Give me a hint:"; Organism organism; std::getline(std::cin, organism.gene); std::lock_guard<std::mutex> lock(pool_mutex); pool.push_back(organism); if(setting::verbose) std::cerr << organism.gene << " was added" << std::endl; } } ); //checks if a duplicate string has passed through this function recently. Its memory of recent elements is 1024 std::deque<std::string> precheck_cache; auto duplicate = [&precheck_cache](const std::string& in) -> bool { if(std::find(precheck_cache.begin(), precheck_cache.end(), in) != precheck_cache.end() && !precheck_cache.empty()) return true; precheck_cache.push_front(in); if(precheck_cache.size()>1024)//keep the queue small precheck_cache.pop_back(); return false; }; while(true) { size_t parent_1_index = random_engine.uniform_int(0,pool.size()-1); const auto parent_1 = pool[parent_1_index]; size_t parent_2_index = random_engine.reverse_exponential_int(pool.size()-1); auto parent_2 = pool[parent_2_index]; mutate(parent_2); do { crossover(pool[parent_1_index], parent_2); parent_1_index = random_engine.uniform_int(0,pool.size()-1); }while(random_engine.bernoulli(setting::multi_parent_crossover_prob));//chance to combine dna of more than 2 organisms if(setting::dump_candidates && !duplicate(parent_2.gene)) std::cout << parent_2.gene << std::endl; if(matches(parent_2.gene)) { cracked << parent_2.gene << std::endl; std::lock_guard<std::mutex> lock(pool_mutex); pool.push_back(parent_2); } //remove an organism if the max_vivarium_size has been exeeded, provided setting::max_vivarium_size is not 0, which means there is no maximum size(it is infinite) if(pool.size()>setting::max_population && setting::max_population!=0) { std::lock_guard<std::mutex> lock(pool_mutex); pool.pop_front(); } } }