Changeset 11405 for trunk/FACT++/src/datalogger.cc
- Timestamp:
- 07/14/11 11:42:42 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/datalogger.cc
r11347 r11405 506 506 void DataLogger::RemoveService(const string& server, const string& service, bool isCmd) 507 507 { 508 if (fDestructing)//this function is called by the super class, after the destructor has deleted its own subscriptions 509 return; 510 508 511 if (isCmd) 509 512 return; … … 1052 1055 { 1053 1056 if (fDebugIsOn) 1054 {1055 1057 Debug("DataLogger destruction starts"); 1056 } 1058 1059 //this boolean should not be required anymore, because it 1057 1060 fDestructing = true; 1058 //first let's go to the ready state 1059 GoToReadyPlease(); 1061 1062 //first, let's backup the datalogger/message service subscription 1063 shared_ptr<DimStampedInfo> messageBackup; 1064 bool dataloggerMessageFound = false; 1065 SubscriptionsListType::iterator x; 1066 map<string, SubscriptionType>::iterator y; 1067 x = fServiceSubscriptions.find("DATA_LOGGER"); 1068 if (x != fServiceSubscriptions.end()) 1069 { 1070 y = x->second.find("MESSAGE"); 1071 if (y != x->second.end()) 1072 { 1073 dataloggerMessageFound = true; 1074 messageBackup = y->second.dimInfo; 1075 } 1076 } 1077 1060 1078 dim_lock(); 1061 //release the services subscriptions 1079 1080 //now clear the services subscriptions 1062 1081 fServiceSubscriptions.clear(); 1063 1082 1064 1083 //clear any remaining run number (should remain only one) 1065 1084 while (fRunNumber.size() > 0) 1066 1085 { 1067 1086 RemoveOldestRunNumber(); 1068 } 1069 // dim_unlock(); 1087 } 1088 //go to the ready state. i.e. close all files, run-wise first 1089 GoToReadyPlease(); 1090 1091 dim_unlock(); 1092 1093 Info("Will soon close the daily log file"); 1094 1070 1095 delete fOpenedNightlyFiles; 1071 1096 delete fOpenedRunFiles; 1072 1097 delete fNumSubAndFits; 1073 // delete fStatsMonitoring; 1098 1099 //release message service before closing nightly log file 1100 if (dataloggerMessageFound) 1101 messageBackup.reset(); 1102 1103 if (fNightlyLogFile.is_open())//this file is the only one that has not been closed by GoToReadyPlease 1104 { 1105 dim_lock(); 1106 fNightlyLogFile.close(); 1107 dim_unlock(); 1108 } 1074 1109 1075 1110 if (fDebugIsOn) 1076 {1077 1111 Debug("DataLogger desctruction ends"); 1078 }1079 1112 } 1080 1113 // -------------------------------------------------------------------------- … … 1133 1166 void DataLogger::infoHandler() 1134 1167 { 1135 // Make sure getTimestamp is called _before_ getTimestampMillisecs1136 if (fDestructing)1137 return;1138 1139 1168 DimInfo* I = getInfo(); 1140 1169 … … 1360 1389 const bool isItaReport = fmt!="C"; 1361 1390 1362 if (!fNightly ReportFile.is_open())1391 if (!fNightlyLogFile.is_open()) 1363 1392 return; 1364 1393 … … 1481 1510 ostringstream str; 1482 1511 str << "Parsing service " << sub.dimInfo->getName(); 1483 str << " failed: " << e.what() ;1512 str << " failed: " << e.what() << " removing the subscription for now."; 1484 1513 Error(str); 1485 // if (fDebugIsOn) 1486 // { 1487 // ostringstream str2; 1488 // str2 << sub.dimInfo->getString() << "\n"; 1489 // Debug(str2); 1490 // } 1514 //remove this subscription from the list. 1515 //because these operators use references to elements, and because they're supposed here to erase these objects on the way, I'm not too sure... so duplicate the names ! 1516 string server = sub.server; 1517 string service = sub.service; 1518 fServiceSubscriptions.find(server)->second.erase(service); 1491 1519 return; 1492 1520 } … … 1533 1561 else 1534 1562 {//write entry to both Nightly and run logs 1535 vector<string> strings = sub.fConv->ToStrings(I->getData()); 1563 vector<string> strings; 1564 try 1565 { 1566 strings = sub.fConv->ToStrings(I->getData()); 1567 } 1568 catch (const runtime_error &e) 1569 { 1570 ostringstream str; 1571 str << "Parsing service " << sub.dimInfo->getName(); 1572 str << " failed: " << e.what() << " removing the subscription for now."; 1573 Error(str); 1574 //remove this subscription from the list. 1575 //because these operators use references to elements, and because they're supposed here to erase these objects on the way, I'm not too sure... so duplicate the names ! 1576 string server = sub.server; 1577 string service = sub.service; 1578 fServiceSubscriptions.find(server)->second.erase(service); 1579 return; 1580 } 1536 1581 if (strings.size() > 1) 1537 1582 { … … 2443 2488 // dim_lock(); 2444 2489 const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", ""); 2445 if (fNightlyLogFile.is_open() )2490 if (fNightlyLogFile.is_open() && !fDestructing)//in case we're destructing the datalogger, wait before closing the log file. 2446 2491 { 2447 2492 fNightlyLogFile.close();
Note:
See TracChangeset
for help on using the changeset viewer.