void MySQL_Logger::flush() { wrlock(); if (logfile) { logfile->flush(); } wrunlock(); }
void MySQL_Logger::log_request(MySQL_Session *sess) { if (enabled==false) return; if (logfile==NULL) return; MySQL_Connection_userinfo *ui=sess->client_myds->myconn->userinfo; MySQL_Event me(sess->thread_session_id,ui->username,ui->schemaname,sess->CurrentQuery.start_time,sess->CurrentQuery.end_time,GloQPro->get_digest(&sess->CurrentQuery.QueryParserArgs)); char *c=(char *)sess->CurrentQuery.QueryPointer; if (c) { me.set_query(c,sess->CurrentQuery.QueryLength); } else { me.set_query("",0); } /* ev.set_server(""); ev.set_client(""); */ wrlock(); me.write(logfile); unsigned long curpos=logfile->tellp(); if (curpos > max_log_file_size) { flush_log_unlocked(); } wrunlock(); }
// true:添加到白名单 // false:从白名单中删除 bool FilterManager::updateConfigWhiteHost(const Url & url,bool bEnable) { writeLock wrlock(rw_cfgmutex); std::string host = url.GetHost(); //ConfigRuleMap::iterator hit=this->m_ConfigWhileRules.find(host); if (bEnable) { ConfigRuleMap::iterator hit=this->m_ConfigWhiteRules.find(host); if(hit == m_ConfigWhiteRules.end()) { m_ConfigWhiteRules.insert(ConfigRuleMap::value_type(host, 0)); } } else { m_ConfigWhiteRules.erase(host); } return true; }
// 0:弹框 // 1:过滤 // 2:不过滤 bool FilterManager::updateConfigVideoHost(const Url & url,int istate) { writeLock wrlock(rw_cfgmutex); std::string host = url.GetHost(); if (host.empty()) { return false; } ConfigRuleMap::iterator hit=map_VideoState.find(host); if(hit!=map_VideoState.end()) { hit->second=istate; } else { map_VideoState.insert(ConfigRuleMap::value_type(host, istate)); } return true; }
void MySQL_Logger::set_base_filename() { // if filename is the same, return wrlock(); max_log_file_size=mysql_thread___eventslog_filesize; if (strcmp(base_filename,mysql_thread___eventslog_filename)==0) { wrunlock(); return; } // close current log close_log_unlocked(); // set file id to 0 , so that find_next_id() will be called log_file_id=0; free(base_filename); base_filename=strdup(mysql_thread___eventslog_filename); if (strlen(base_filename)) { enabled=true; open_log_unlocked(); } else { enabled=false; } wrunlock(); }
void MySQL_Logger::flush_log() { wrlock(); flush_log_unlocked(); wrunlock(); }