Мое клиентское приложение c ++ scribe (многопоточная среда Thrift) периодически отправляет журналы на центральный сервер, но через некоторое время происходит сбой. После исследования я обнаружил проблему с сигналами, поэтому я использовал код для обработки сигналов, после чего обнаружилон получает сигнал SIGABRT, я не знаю, как решить это,
class MyTimer : public CppTimer{
void timerEvent() {
cout<<"timer Event"<<endl;
for(int i = 0; i < g_config->logFileNames.size(); i++) {
try{
int ret = -1;
string tempfile = g_config->tempFolder + g_config->logFileNames[i];
string category = g_config->logCategories[g_config->logFileNames[i]];
//addLog("timerEvent: reading file ...");
string content = read_file_content(tempfile);
trim(content);
if(content.size() == 0)
continue;
try{
g_client->reinitialize();
}catch(TException &tx){
stringstream ss1;
ss1<<"cause :"<<tx.what()<<endl;
addLog(ss1.str().c_str());
g_transport->close();
g_transport->open();
addLog("Connection reinitialized");
}catch(std::exception& e){
stringstream ss;
ss<<"std :: exception in timerEvent! : in std catch : "<<e.what();
addLog(ss.str());
//g_client->reinitialize();
g_transport->close();
g_transport->open();
addLog("connection Established");
}
addLog("timerEvent: reading file success.");
stringstream ss, srs;
ss <<"> "<<tempfile;
system(ss.str().c_str());
addLog("timerEvent: appending file name ");
LogEntry le;
le.message = content;
le.category = category;
addLog("timerEvent: pushing in queue ");
std::vector<LogEntry> messages;
messages.push_back(le);
// write to scribe server
addLog("timerEvent: queue ready ");
try{
ret = g_client->Log(messages);
}catch(TException &tx){
stringstream ss;
ss<<"TimerEvent :"<<tx.what()<<endl;
addLog("1 Server Connection Failed");
addLog(ss.str());
g_transport->close();
g_transport->open();
addLog("connection Established");
ret = g_client->Log(messages);
//printf("ERROR: %s\n",tx.what());
}catch(std::exception& e){
stringstream ss;
ss<<"exception in timerEvent! send : in std catch : "<<e.what();
addLog(ss.str());
//g_client->reinitialize();
g_transport->close();
g_transport->open();
addLog("connection Established");
ret = g_client->Log(messages);
}
//g_client->reinitialize();
addLog("timerEvent: data sent to server ");
if(0 != ret){
addLog("Log data was not sent to server:");
cout<<"Log data was not sent to server:"<<endl;
}
else{
addLog("Log data was sent to server:");
cout<<"Log data was sent to server:"<<endl;
}
stringstream sss;
sss<<"Category : "<<category;
addLog(sss.str());
cout<<sss.str()<<endl;
sss.str("");
sss<<"Content : " <<content;
//addLog(sss.str()); //prints logs contents
cout<<sss.str()<<endl;
}
catch(boost::exception const& ex){
stringstream ss;
ss<<"boost :: exception in timerEvent! : in boost catch : "<<boost::diagnostic_information(ex);
addLog(ss.str());
g_transport->close();
g_transport->open();
addLog("connection Established");
//throw 10;
}
catch(std::exception& e){
stringstream ss;
ss<<"std :: exception in timerEvent 269! : in std catch : "<<e.what();
addLog(ss.str());
//g_client->reinitialize();
g_transport->close();
g_transport->open();
addLog("connection Established");
}
catch(...){
addLog("exception in timerEvent! : in default catch ");
g_transport->close();
g_transport->open();
addLog("connection Established");
}
//transport->close();
}
}