void Log2File(const char* section, const char* key, const char* msg, va_list& ap, int nFileType = 0) { char szTmp[MAX_LOG_BUFF_SIZE]; memset(szTmp, 0, MAX_LOG_BUFF_SIZE * sizeof(char)); _Log(szTmp, section, key, msg, ap); if(g_logger.IsSetPath()) { if(g_logger_mutex == NULL) { g_logger.NewLine(nFileType) << szTmp << EndLine; } else { //dbmgr的多线程日志要加锁 CMutexGuard gm(*g_logger_mutex); g_logger.NewLine(nFileType) << szTmp << EndLine; } } else { printf("%s\n", szTmp); } }
void CTracer::Dump (void) { if (m_bActive) { Stop (); } CLogger *pLogger = CLogger::Get (); unsigned nEvent = 0; if (m_nEntries == m_nDepth) { nEvent = m_nCurrent; } for (unsigned i = 1; i <= m_nEntries; i++) { TTraceEntry *pEntry = m_pEntry + nEvent; pLogger->Write (FromTracer, LogNotice, "%2u: %2u.%06u %2u %08X %08X %08X %08X", i, pEntry->nClockTicks / CLOCKHZ, pEntry->nClockTicks % CLOCKHZ, pEntry->nEventID, pEntry->nParam[0], pEntry->nParam[1], pEntry->nParam[2], pEntry->nParam[3]); nEvent = (nEvent+1) % m_nDepth; } }
void CSyncDebugger::Initialize(bool useBacktrace, unsigned numPlayers) { delete[] history; history = NULL; delete[] historybt; historybt = NULL; #ifdef HAVE_BACKTRACE if (useBacktrace) { historybt = new HistItemWithBacktrace[HISTORY_SIZE * BLOCK_SIZE]; memset(historybt, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItemWithBacktrace)); } else #endif { history = new HistItem[HISTORY_SIZE * BLOCK_SIZE]; memset(history, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItem)); } //cleanup historyIndex = 0; disable_history = false; may_enable_history = false; flop = 0; players.clear(); players.resize(numPlayers); pendingBlocksToRequest.clear(); waitingForBlockResponse = false; // init logger logger.SetFilename(useBacktrace ? LOGFILE_SERVER : LOGFILE_CLIENT); logger.AddLine("SyncDebugger initialized"); logger.FlushBuffer(); }
StartLineProcessConnector::~StartLineProcessConnector() { DDSDomainParticipant *participant = RTIConnector::getParticipant(); DDS_ReturnCode_t retcode; if (NULL != m_reader_cache) { if (DDS_RETCODE_OK != RTIConnector::getSubscriber()->delete_datareader(m_reader_cache)) { g_cSystemLogger.LogMessage("(%s:%s(:%d))::Unable to delete m_reader_cache \n", LOG_LOCATION); } m_reader_cache = NULL; } if (NULL != m_read_topic) { if (DDS_RETCODE_OK != participant->delete_topic(m_read_topic)) { g_cSystemLogger.LogMessage("(%s:%s(:%d))::Unable to delete m_read_topic \n", LOG_LOCATION); } m_read_topic = NULL; } // Un-register the type... if ((NULL != participant) && (NULL != m_type_name_cache)) { retcode = MONITORING::leaseProcessStartTypeSupport::unregister_type(participant, m_type_name_cache); if (retcode != DDS_RETCODE_OK) { g_cSystemLogger.LogMessage("(%s:%s(:%d))::Error ---> RTCConnector() unregister_type RTC error \n", LOG_LOCATION); } m_type_name_cache = NULL; } pt_rtc = 0; return; }
void CConfigurationDialog::OnButton(wxCommandEvent& event) { if(event.GetId() == GetAffirmativeId()) { m_config.Write(_T("LogDirectory"), m_pLogDirPicker->GetPath()); m_config.Write(_T("FilenameFormat"), m_pFilenameInput->GetValue()); m_config.Write(_T("ReplacementChar"), m_pReplacementInput->GetValue()); m_config.Write(_T("MessageFormat"), m_pMessageInput->GetValue()); m_config.Write(_T("EmoteFormat"), m_pEmoteInput->GetValue()); m_config.Write(_T("SeparationString"), m_pSeparationInput->GetValue()); m_config.Write(_T("DateFormat"), m_pDateInput->GetValue()); m_config.Write(_T("TimeFormat"), m_pTimeInput->GetValue()); m_config.Write(_T("Unstable"), pUnstableCheckBox->IsChecked()); CLogger* pLogger = wxGetApp().GetLogger(); pLogger->SetLogDirectory(m_pLogDirPicker->GetPath()); pLogger->SetFilenameFormat(m_pFilenameInput->GetValue()); pLogger->SetReplacementChar(m_pReplacementInput->GetValue()[0]); pLogger->SetMessageFormat(m_pMessageInput->GetValue()); pLogger->SetEmoteFormat(m_pEmoteInput->GetValue()); pLogger->SetSeparationString(m_pSeparationInput->GetValue()); pLogger->SetDateFormat(m_pDateInput->GetValue()); pLogger->SetTimeFormat(m_pTimeInput->GetValue()); pLogger->UseClientInterfaces(pUnstableCheckBox->IsChecked()); } this->Close(); }
bool StartLineProcessConnector::createReader() { DDSSubscriber *subscriber = RTIConnector::getSubscriber(); if(FAILURE==CControllerThread::getInstance()->CommandWriter("Monitoring_Library","psl_profile")) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error ---> StartLineProcessConnector::CreateWriter Failure\n ", LOG_LOCATION); } if (NULL == m_read_topic) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error ---> StartLineProcessConnector::CreateReader() m_read_topic is NULL for RTC! \n ", LOG_LOCATION); return false; } if (NULL != m_reader_cache) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error ---> RTCConnector::CreateReader() m_reader_cache exists for RTC!\n \n ", LOG_LOCATION); return false; } /* Create a data reader listener for cache */ LineProcessStatusListener *m_reader_listener_cache = new LineProcessStatusListener(); /* To customize the data reader QoS, use the configuration file USER_QOS_PROFILES.xml */ m_reader_cache = subscriber->create_datareader_with_profile(m_read_topic, "Monitoring_Library", "Monitoring_Profile", m_reader_listener_cache, DDS_STATUS_MASK_ALL); if (m_reader_cache == NULL) { g_cSystemLogger.LogMessage("(%s:%s:%d)::CreateReader() error for RTC\n \n ", LOG_LOCATION); delete m_reader_listener_cache; m_reader_listener_cache = NULL; return false; } g_cSystemLogger.LogMessage("(%s:%s:%d):: Create Reader sucess", LOG_LOCATION); return true; }
CLogger* CLogger::NewL() { CLogger* self = new(ELeave) CLogger(); CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); return self; }
void CThreadPool::thread_pool_run() { CLogger* pl = CLogger::CreateInstance(m_strLogPath); while (!m_bThreadPoolRun) { try { int nRet = WaitForSingleObject(m_hWaitingWork,m_nThreadTimeOut); if ( nRet == WAIT_OBJECT_0) { int sTime = GetTickCount(); InterlockedIncrement(&m_nThreadRunCount); CTaskUnit* TaskUnit = NULL; m_LockDeq.Lock(); if (m_DequeTask.size() > 0 ) { TaskUnit = m_DequeTask.front(); m_DequeTask.pop_front(); } m_LockDeq.UnLock(); SetEvent(m_hGotgWork); if (TaskUnit) { TaskUnit->DoWork(); delete TaskUnit; TaskUnit = NULL; } InterlockedDecrement(&m_nThreadRunCount); if (m_bLogger) { int eTime = GetTickCount(); int ntime = eTime - sTime; TCHAR szData[2048] ={ 0 }; m_LockDeq.Lock(); _stprintf(szData,L" task:%d ms ;thr:%d; thrid:%d; deq:%d", ntime, m_nThreadRunCount, GetCurrentThreadId(), m_DequeTask.size()); m_LockDeq.UnLock(); OutputDebugString(szData); pl->add_log_to_deque(szData); } } } catch(...) { } } }
void DQuitFunction() { _log.Log(LOG_NORM,"Closing application!..."); fflush(stdout); #if defined WIN32 TrayMessage(NIM_DELETE,NULL); #endif _log.Log(LOG_NORM,"stopping worker..."); _mainworker.Stop(); }
/** * @brief serverside network receiver * * Plugin for the CGameServer network code in GameServer.cpp. * @return the number of bytes read from the network stream */ bool CSyncDebugger::ServerReceived(const unsigned char* inbuf) { bool syncDebugPacket = false; switch (inbuf[0]) { case NETMSG_SD_CHKRESPONSE: if (*(short*)&inbuf[1] != HISTORY_SIZE * sizeof(unsigned) + 12) { logger.AddLine("Server: received checksum response of %d instead of %d bytes", *(short*)&inbuf[1], HISTORY_SIZE * 4 + 12); } else { int player = inbuf[3]; if(player >= playerHandler->ActivePlayers() || player < 0) { logger.AddLine("Server: got invalid playernum %d in checksum response", player); } else { logger.AddLine("Server: got checksum response from %d", player); const unsigned* begin = (unsigned*)&inbuf[12]; const unsigned* end = begin + HISTORY_SIZE; players[player].checksumResponses.resize(HISTORY_SIZE); std::copy(begin, end, players[player].checksumResponses.begin()); players[player].remoteFlop = *(uint64_t*)&inbuf[4]; assert(!players[player].checksumResponses.empty()); int i = 0; while (i < playerHandler->ActivePlayers() && !players[i].checksumResponses.empty()) ++i; if (i == playerHandler->ActivePlayers()) { ServerQueueBlockRequests(); logger.AddLine("Server: checksum responses received; %d block requests queued", pendingBlocksToRequest.size()); } } } syncDebugPacket = true; break; case NETMSG_SD_BLKRESPONSE: if (*(short*)&inbuf[1] != BLOCK_SIZE * sizeof(unsigned) + 4) { logger.AddLine("Server: received block response of %d instead of %d bytes", *(short*)&inbuf[1], BLOCK_SIZE * 4 + 4); } else { int player = inbuf[3]; if(player >= playerHandler->ActivePlayers() || player < 0) { logger.AddLine("Server: got invalid playernum %d in block response", player); } else { const unsigned* begin = (unsigned*)&inbuf[4]; const unsigned* end = begin + BLOCK_SIZE; unsigned size = players[player].remoteHistory.size(); players[player].remoteHistory.resize(size + BLOCK_SIZE); std::copy(begin, end, players[player].remoteHistory.begin() + size); int i = 0; size += BLOCK_SIZE; while (i < playerHandler->ActivePlayers() && size == players[i].remoteHistory.size()) ++i; if (i == playerHandler->ActivePlayers()) { logger.AddLine("Server: block responses received"); ServerReceivedBlockResponses(); } } } syncDebugPacket = true; break; default: logger.AddLine("Server: unknown packet"); break; } logger.FlushBuffer(); return syncDebugPacket; }
CLogger * CLogger::getLogger(const CLoggerDomain & domain) { TLockGuardRec _(smx); CLogger * logger = CLogManager::get().getLogger(domain); if(!logger) // Create new logger { logger = new CLogger(domain); if(domain.isGlobalDomain()) logger->setLevel(ELogLevel::TRACE); CLogManager::get().addLogger(logger); } return logger; }
//Add files to list box void CLeftPanel::AddFileToListBox(string file_name) { CLogger logger ("CLeftPanel::AddFileListToListBox"); logger.Log("Adding file to list box"); //Add if(file_list_box->GetCount() == 2) { wxMessageBox("Only supported diffing two files."); } else { file_list_box->Append(file_name); } }
void CLoggerAccess::Reset() { delete m_logfile; m_logfile = new wxFFileInputStream(theLogger.GetLogfileName()); m_pos = 0; m_ready = false; }
/** * @brief initialize * * Initialize the sync debugger. Pass true for a server (this requires approx. * 144 megabytes on 32 bit systems and 240 megabytes on 64 bit systems) and * false for a client (requires only 16 megabytes extra). */ void CSyncDebugger::Initialize(bool useBacktrace) { delete[] history; history = 0; delete[] historybt; historybt = 0; #ifdef HAVE_BACKTRACE if (useBacktrace) { historybt = new HistItemWithBacktrace[HISTORY_SIZE * BLOCK_SIZE]; memset(historybt, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItemWithBacktrace)); } else #endif { history = new HistItem[HISTORY_SIZE * BLOCK_SIZE]; memset(history, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItem)); } //cleanup historyIndex = 0; disable_history = false; may_enable_history = false; flop = 0; for (int j = 0; j < MAX_PLAYERS; ++j) { checksumResponses[j].clear(); remoteHistory[j].clear(); remoteFlop[j] = 0; } pendingBlocksToRequest.clear(); waitingForBlockResponse = false; // init logger logger.SetFilename(useBacktrace ? LOGFILE_SERVER : LOGFILE_CLIENT); }
/** * @brief output a backtrace to the log * * Writes the backtrace attached to history item # index to the log. * The backtrace is prefixed with prefix. */ void CSyncDebugger::Backtrace(int index, const char* prefix) const { if (historybt) { for (unsigned i = 0; i < historybt[index].bt_size; ++i) { // the "{%p}" part is resolved to "functionname [filename:lineno]" // by the CLogger class. #ifndef _WIN32 logger.AddLine("%s#%u {%p}", prefix, i, historybt[index].bt[i]); #else if (sizeof(void*) == 8) logger.AddLine("%s#%u {%llx}", prefix, i, (uint64_t)historybt[index].bt[i]); else logger.AddLine("%s#%u {%x}", prefix, i, (uint32_t)historybt[index].bt[i]); #endif } } }
CLogger *CLogger::StartLog(LPCTSTR strPath, CLogger::DEBUG_LEVEL debuglevel) { bool ret = false; CLogger * p = new CLogger(std::wstring(L"")); if(!p) { goto startlogexit; } if(!p->lock_init()) { goto startlogexit; } p->m_curlevel = debuglevel; p->SetDebugName(strPath); ret = true; startlogexit: if(ret) return p; if(p) delete p; return NULL; }
void CSyncDebugger::ServerQueueBlockRequests() { logger.AddLine("Server: queuing block requests"); boost::uint64_t correctFlop = 0; for (int j = 0; j < playerHandler->ActivePlayers(); ++j) { if (correctFlop) { if (players[j].remoteFlop != correctFlop) logger.AddLine( #ifdef _WIN32 "Server: bad flop# %I64u instead of %I64u for player %d", #else "Server: bad flop# %llu instead of %llu for player %d", #endif players[j].remoteFlop, correctFlop, j); } else { correctFlop = players[j].remoteFlop; } } unsigned i = ((unsigned)(correctFlop % (HISTORY_SIZE * BLOCK_SIZE)) / BLOCK_SIZE) + 1; for (unsigned c = 0; c < HISTORY_SIZE; ++i, ++c) { unsigned correctChecksum = 0; if (i == HISTORY_SIZE) i = 0; for (int j = 0; j < playerHandler->ActivePlayers(); ++j) { if (correctChecksum && players[j].checksumResponses[i] != correctChecksum) { pendingBlocksToRequest.push_back(i); break; } correctChecksum = players[j].checksumResponses[i]; } } if (!pendingBlocksToRequest.empty()) { logger.AddLine("Server: blocks: %u equal, %u not equal", HISTORY_SIZE - pendingBlocksToRequest.size(), pendingBlocksToRequest.size()); requestedBlocks = pendingBlocksToRequest; // we know the first FPU bug occured in block # ii, so we send out a block request for it. // serverNet->SendData<unsigned> (NETMSG_SD_BLKREQUEST, ii); } else { logger.AddLine("Server: huh, all blocks equal?!?"); clientNet->Send(CBaseNetProtocol::Get().SendSdReset()); } //cleanup for (PlayerVec::iterator it = players.begin(); it != players.end(); ++it) it->checksumResponses.clear(); logger.FlushBuffer(); }
/** * @brief clientside network receiver * * Plugin for the CGame network code in Game.cpp. * @return the number of bytes read from the network stream */ int CSyncDebugger::ClientReceived(const unsigned char* inbuf) { int length = 0; switch (inbuf[0]) { case NETMSG_SD_CHKREQUEST: if (gs->frameNum != *(int*)&inbuf[1]) { logger.AddLine("Client: received checksum request for frame %d instead of %d", *(int*)&inbuf[1], gs->frameNum); } else { disable_history = true; // no more additions to the history until we're done may_enable_history = false; ClientSendChecksumResponse(); logger.AddLine("Client: checksum response sent"); } length = 5; break; case NETMSG_SD_BLKREQUEST: if (*(unsigned short*)&inbuf[1] >= HISTORY_SIZE) { logger.AddLine("Client: invalid block number %d in block request", *(unsigned short*)&inbuf[1]); } else { ClientSendBlockResponse(*(unsigned short*)&inbuf[1]); logger.AddLine("Client: block response sent for block %d", *(unsigned short*)&inbuf[1]); // simple progress indication logOutput.Print("[SD] Client: %d / %d", *(unsigned short*)&inbuf[3], *(unsigned short*)&inbuf[5]); } length = 7; break; case NETMSG_SD_RESET: logger.CloseSession(); logOutput.Print("[SD] Client: Done!"); // disable_history = false; may_enable_history = true; if (gu->autoQuit) { logOutput.Print("[SD] Client: Automatical quit enforced from commandline"); globalQuit = true; } length = 1; break; default: logOutput.Print("[SD] Client: invalid msg"); length = 0; break; } return length; }
/** * @brief output a backtrace to the log * * Writes the backtrace attached to history item # index to the log. * The backtrace is prefixed with prefix. */ void CSyncDebugger::Backtrace(int index, const char* prefix) const { if (historybt) { for (unsigned i = 0; i < historybt[index].bt_size; ++i) { // the "{%p}" part is resolved to "functionname [filename:lineno]" // by the CLogger class. logger.AddLine("%s#%u {%p}", prefix, i, historybt[index].bt[i]); } } }
void Log2Console(const char* section, const char* key, const char* msg, va_list& ap, int nFileType = 0) { char szTmp[MAX_LOG_BUFF_SIZE]; _Log(szTmp, section, key, msg, ap); #ifdef _DEBUG_VERSION_ printf("%s\n", szTmp); #else if(g_logger.IsSetPath()) { g_logger.NewLine(nFileType) << szTmp << EndLine; printf("%s\n", szTmp); } else { printf("%s\n", szTmp); } #endif }
/** * @brief serverside network receiver * * Plugin for the CGameServer network code in GameServer.cpp. * @return the number of bytes read from the network stream */ int CSyncDebugger::ServerReceived(const unsigned char* inbuf) { int length = 0; switch (inbuf[0]) { case NETMSG_SD_CHKRESPONSE: if (*(short*)&inbuf[1] != HISTORY_SIZE * sizeof(unsigned) + 12) { logger.AddLine("Server: received checksum response of %d instead of %d bytes", *(short*)&inbuf[1], HISTORY_SIZE * 4 + 12); } else { int player = inbuf[3]; if(player >= gs->activeTeams || player < 0) { logger.AddLine("Server: got invalid playernum %d in checksum response", player); } else { const unsigned* begin = (unsigned*)&inbuf[12]; const unsigned* end = begin + HISTORY_SIZE; checksumResponses[player].resize(HISTORY_SIZE); std::copy(begin, end, checksumResponses[player].begin()); remoteFlop[player] = *(Uint64*)&inbuf[4]; int i = 0; while (i < gs->activeTeams && !checksumResponses[i].empty()) ++i; if (i == gs->activeTeams) { ServerQueueBlockRequests(); logger.AddLine("Server: checksum responses received; %d block requests queued", pendingBlocksToRequest.size()); } } } length = *(short*)&inbuf[1]; break; case NETMSG_SD_BLKRESPONSE: if (*(short*)&inbuf[1] != BLOCK_SIZE * sizeof(unsigned) + 4) { logger.AddLine("Server: received block response of %d instead of %d bytes", *(short*)&inbuf[1], BLOCK_SIZE * 4 + 4); } else { int player = inbuf[3]; if(player >= gs->activeTeams || player < 0) { logger.AddLine("Server: got invalid playernum %d in block response", player); } else { const unsigned* begin = (unsigned*)&inbuf[4]; const unsigned* end = begin + BLOCK_SIZE; unsigned size = remoteHistory[player].size(); remoteHistory[player].resize(size + BLOCK_SIZE); std::copy(begin, end, remoteHistory[player].begin() + size); int i = 0; size += BLOCK_SIZE; while (i < gs->activeTeams && size == remoteHistory[i].size()) ++i; if (i == gs->activeTeams) { logger.AddLine("Server: block responses received"); ServerReceivedBlockResponses(); } } } length = *(short*)&inbuf[1]; break; default: logger.AddLine("Server: invalid msg"); length = 0; break; } return length; }
//--------------------------------------------------------------------------- // @function: // CErrorHandlerStandard::Process // // @doc: // Process pending error context; // //--------------------------------------------------------------------------- void CErrorHandlerStandard::Process ( CException exc ) { CTask *ptsk = CTask::PtskSelf(); GPOS_ASSERT(NULL != ptsk && "No task in current context"); IErrorContext *perrctxt = ptsk->Perrctxt(); CLogger *plog = dynamic_cast<CLogger*>(ptsk->PlogErr()); GPOS_ASSERT(perrctxt->FPending() && "No error to process"); GPOS_ASSERT(perrctxt->Exc() == exc && "Exception processed different from pending"); // print error stack trace if (CException::ExmaSystem == exc.UlMajor() && !perrctxt->FRethrow()) { if ((CException::ExmiIOError == exc.UlMinor() || CException::ExmiNetError == exc.UlMinor() ) && 0 < errno) { perrctxt->AppendErrnoMsg(); } if (ILogger::EeilMsgHeaderStack <= plog->Eil()) { perrctxt->AppendStackTrace(); } } // scope for suspending cancellation { // suspend cancellation CAutoSuspendAbort asa; // log error message plog->Log(perrctxt->WszMsg(), perrctxt->UlSev(), __FILE__, __LINE__); } }
CLogger * CLogger::getLogger(const CLoggerDomain & domain) { boost::lock_guard<boost::recursive_mutex> _(smx); CLogger * logger = CLogManager::get().getLogger(domain); if(logger) { return logger; } else { logger = new CLogger(domain); if(domain.isGlobalDomain()) { logger->setLevel(ELogLevel::INFO); } CLogManager::get().addLogger(logger); return logger; } }
int main(int argc, char *argv[]) { TBSYS_LOG(INFO, "xxx: %s:%d", "xxxx", 1); TBSYS_LOG(ERROR, "xxx: %s:%d", "xxxx", 1); TBSYS_LOGGER.setFileName("/tmp/test.txt"); for(int i=0; i<50; i++) { TBSYS_LOG(ERROR, "xxx: %s:%d", "xxxx", i); TBSYS_LOG(WARN, "xxx: %s:%d", "xxxx", i); TBSYS_LOG(INFO, "xxx: %s:%d", "xxxx", i); TBSYS_LOG(DEBUG, "xxx: %s:%d", "xxxx", i); //getchar(); } //test rotateLog() CLogger logger; logger.setFileName("/tmp/test.log", false, true); logger.setLogLevel("INFO"); logger.setMaxFileIndex(100); for (int i = 0; i < 10; i++) { for (int j = 0; j < 50; j++) { logger.logMessage(TBSYS_LOG_LEVEL_ERROR, __FILE__, __LINE__, __FUNCTION__, pthread_self(), "test rotateLog(): %d", j); } logger.rotateLog(NULL); sleep(2); } return 0; }
//--------------------------------------------------------------------------- // @function: // FSimulateIOErrorInternal // // @doc: // Inject I/O exception // //--------------------------------------------------------------------------- static BOOL FSimulateIOErrorInternal ( INT iErrno, const CHAR *szFile, ULONG ulLine ) { BOOL fRes = false; ITask *ptsk = ITask::PtskSelf(); if (NULL != ptsk && ptsk->FTrace(EtraceSimulateIOError) && CFSimulator::Pfsim()->FNewStack(CException::ExmaSystem, CException::ExmiIOError) && !GPOS_MATCH_EX(ptsk->Perrctxt()->Exc(), CException::ExmaSystem, CException::ExmiIOError)) { // disable simulation temporarily to log injection CAutoTraceFlag(EtraceSimulateIOError, false); CLogger *plogger = dynamic_cast<CLogger*>(ITask::PtskSelf()->Ptskctxt()->PlogErr()); if (!plogger->FLogging()) { GPOS_TRACE_FORMAT_ERR("Simulating I/O error at %s:%d", szFile, ulLine); } errno = iErrno; if (ptsk->Perrctxt()->FPending()) { ptsk->Perrctxt()->Reset(); } // inject I/O error fRes = true; } return fRes; }
/** * @brief initialize * * Initialize the sync debugger. Pass true for a server (this requires approx. * 144 megabytes on 32 bit systems and 240 megabytes on 64 bit systems) and * false for a client (requires only 16 megabytes extra). * FIXME update this comment to reflect new values */ void CSyncDebugger::Initialize(bool useBacktrace, unsigned numPlayers) { delete[] history; history = 0; delete[] historybt; historybt = 0; #ifdef HAVE_BACKTRACE if (useBacktrace) { historybt = new HistItemWithBacktrace[HISTORY_SIZE * BLOCK_SIZE]; memset(historybt, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItemWithBacktrace)); } else #endif { history = new HistItem[HISTORY_SIZE * BLOCK_SIZE]; memset(history, 0, HISTORY_SIZE * BLOCK_SIZE * sizeof(HistItem)); } //cleanup historyIndex = 0; disable_history = false; may_enable_history = false; flop = 0; for (unsigned j = 0; j < numPlayers; ++j) { PlayerStruct buf; buf.checksumResponses.clear(); buf.remoteHistory.clear(); buf.remoteFlop = 0; players.push_back(buf); } pendingBlocksToRequest.clear(); waitingForBlockResponse = false; // init logger logger.SetFilename(useBacktrace ? LOGFILE_SERVER : LOGFILE_CLIENT); logger.AddLine("Syncdebugger initialised"); logger.FlushBuffer(); }
void signal_handler(int sig_num) { switch(sig_num) { #ifndef WIN32 case SIGHUP: if (logfile!="") { _log.SetOutputFile(logfile.c_str()); } break; #endif case SIGINT: case SIGTERM: #ifndef WIN32 if ((g_bRunAsDaemon)||(g_bUseSyslog)) syslog(LOG_INFO, "Domoticz is exiting..."); #endif g_bStopApplication = true; break; case SIGSEGV: case SIGILL: case SIGABRT: case SIGFPE: if (fatal_handling) { _log.Log(LOG_ERROR, "Domoticz received fatal signal %d while backtracing !...", sig_num); exit(EXIT_FAILURE); } fatal_handling = 1; _log.Log(LOG_ERROR, "Domoticz received fatal signal %d !...", sig_num); dumpstack(); // re-raise signal to enforce core dump signal(sig_num, SIG_DFL); raise(sig_num); break; } }
//--------------------------------------------------------------------------- // @function: // netutils::FSimulateNetError // // @doc: // Inject networking exception // //--------------------------------------------------------------------------- BOOL gpos::netutils::FSimulateNetError ( INT iErrno, const CHAR *szFile, ULONG ulLine ) { GPOS_ASSERT(0 < iErrno); ITask *ptsk = ITask::PtskSelf(); if (NULL != ptsk && ptsk->FTrace(EtraceSimulateNetError) && CFSimulator::Pfsim()->FNewStack(CException::ExmaSystem, CException::ExmiNetError) && !GPOS_MATCH_EX(ptsk->Perrctxt()->Exc(), CException::ExmaSystem, CException::ExmiNetError)) { // disable simulation temporarily to log injection CAutoTraceFlag(EtraceSimulateNetError, false); CLogger *plogger = dynamic_cast<CLogger*>(ITask::PtskSelf()->Ptskctxt()->PlogErr()); if (!plogger->FLogging()) { GPOS_TRACE_FORMAT_ERR("Simulating networking error at %s:%d", szFile, ulLine); } errno = iErrno; if (ptsk->Perrctxt()->FPending()) { ptsk->Perrctxt()->Reset(); } return true; } return false; }
/** * @brief third step after desync * * Called by server after all checksum responses have been received. * Compares the checksumResponses and figures out which blocks are out of sync * (have different checksum). For these blocks requests are queued which will * be send next frames (one request at a time, see * CSyncDebugger::ServerHandlePendingBlockRequests()). */ void CSyncDebugger::ServerQueueBlockRequests() { Uint64 correctFlop = 0; for (int j = 0; j < gs->activeTeams; ++j) { if (correctFlop) { if (remoteFlop[j] != correctFlop) logger.AddLine("Server: bad flop# %llu instead of %llu for player %d", remoteFlop[j], correctFlop, j); } else { correctFlop = remoteFlop[j]; } } unsigned i = ((unsigned)(correctFlop % (HISTORY_SIZE * BLOCK_SIZE)) / BLOCK_SIZE) + 1, c = 0; for (; c < HISTORY_SIZE; ++i, ++c) { unsigned correctChecksum = 0; if (i == HISTORY_SIZE) i = 0; for (int j = 0; j < gs->activeTeams; ++j) { if (correctChecksum && checksumResponses[j][i] != correctChecksum) { pendingBlocksToRequest.push_back(i); break; } correctChecksum = checksumResponses[j][i]; } } if (!pendingBlocksToRequest.empty()) { logger.AddLine("Server: blocks: %u equal, %u not equal", HISTORY_SIZE - pendingBlocksToRequest.size(), pendingBlocksToRequest.size()); requestedBlocks = pendingBlocksToRequest; // we know the first FPU bug occured in block # ii, so we send out a block request for it. // serverNet->SendData<unsigned> (NETMSG_SD_BLKREQUEST, ii); } else { logger.AddLine("Server: huh, all blocks equal?!?"); serverNet->SendData(NETMSG_SD_RESET); } //cleanup for (int j = 0; j < MAX_PLAYERS; ++j) checksumResponses[j].clear(); }
StartLineProcessConnector::StartLineProcessConnector(const char* rd_topic) { DDS_ReturnCode_t retcode_cache; DDSDomainParticipant *participant = RTIConnector::getParticipant(); m_read_topic = NULL; pt_rtc = NULL; m_reader_cache = NULL; if (rd_topic == NULL) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error --->rd_topic is NULL \n", LOG_LOCATION); return; } if (participant == NULL) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error --->Participant is NULL \n", LOG_LOCATION); return; } /* Register the type before creating the topic for RTC */ m_type_name_cache = MONITORING::leaseProcessStartTypeSupport::get_type_name(); retcode_cache = MONITORING::leaseProcessStartTypeSupport::register_type(participant, m_type_name_cache); if (retcode_cache != DDS_RETCODE_OK) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error --->Register Type RTC ERROR \n", LOG_LOCATION); m_type_name_cache = NULL; return; } if (NULL == m_read_topic) { /* To customize the topic QoS, use the configuration file USER_QOS_PROFILES.xml */ m_read_topic = participant->create_topic(rd_topic, m_type_name_cache, DDS_TOPIC_QOS_DEFAULT, NULL /* listener */ , DDS_STATUS_MASK_NONE); if (m_read_topic == NULL) { g_cSystemLogger.LogMessage("(%s:%s:%d):: Error --->create topic success is NULL \n", LOG_LOCATION); return; } } g_cSystemLogger.LogMessage("(%s:%s:%d):: --->create topic success \n", LOG_LOCATION); }