Changeset 11265


Ignore:
Timestamp:
07/06/11 16:06:48 (13 years ago)
Author:
lyard
Message:
Added the RemoveServer and RemoveAllServers functions. Seems to have fixed a bug occuring if the dns crashed (dim services were somehow corrupted)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/datalogger.cc

    r11261 r11265  
    385385    ///Remove all the services associated with a given server
    386386    void RemoveAllServices(const string&);
     387    ///Remove a server and all of its services
     388    void RemoveServer(const std::string &s);
     389    ///Remove all the servers and all subscriptions
     390    void RemoveAllServers();
    387391}; //DataLogger
    388392
     
    470474void DataLogger::AddService(const string& server, const string& service, const string&, bool isCmd)
    471475{
    472          //dataLogger does not subscribe to commands
     476    //dataLogger does not subscribe to commands
    473477    if (isCmd)
    474478        return;
     
    486490    }
    487491
    488     list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
     492//    list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
     493    list[service].dimInfo.reset(SubscribeToPlease(server, service));
    489494    list[service].server  = server;
    490495    list[service].service = service;
     
    535540        Debug("Removed all subscriptions to " + server + "/");
    536541    }
     542}
     543// --------------------------------------------------------------------------
     544//
     545//! Remove a given server
     546//! @param s the server to be removed
     547//
     548void DataLogger::RemoveServer(const std::string &s)
     549{
     550    if (fServiceSubscriptions.erase(s) != 1)
     551    {
     552        Error("The server " + s + " to be removed was not in the servers list");
     553    }
     554    DimServiceInfoList::RemoveServer(s);
     555}
     556// --------------------------------------------------------------------------
     557//
     558//! Remove all the server and associated subscriptions
     559//
     560void DataLogger::RemoveAllServers()
     561{
     562    fServiceSubscriptions.clear();
     563    DimServiceInfoList::RemoveAllServers();
    537564}
    538565// --------------------------------------------------------------------------
     
    10321059         RemoveOldestRunNumber();
    10331060     }
    1034     dim_unlock();
     1061//    dim_unlock();
    10351062    delete fOpenedNightlyFiles;
    10361063    delete fOpenedRunFiles;
     
    10601087    fPreviousStatsUpdateTime = cTime;
    10611088    //update the service. No need to check if data has been written, because some must have been, otherwise we would not have hit this piece of code
     1089    if (fStatVar.writingRate < 0)
     1090        fStatVar.writingRate = 0;
     1091    if (fStatVar.sizeWritten < 0)
     1092        fStatVar.sizeWritten = 0;
    10621093    fStatsMonitoring->updateService();
    10631094
     
    11041135
    11051136    //it may happen that we try to write a dimInfo while closing files. Prevent that with a dim_lock()
    1106     dim_lock();
     1137//    dim_lock();
    11071138
    11081139    //check if the service pointer corresponds to something that we subscribed to
     
    11251156    {
    11261157        DimServiceInfoList::infoHandler();
    1127         dim_unlock();
     1158//        dim_unlock();
    11281159        return;
    11291160    }
    11301161    if (I->getSize() <= 0 || I->getData()==NULL)
    11311162    {
    1132         dim_unlock();
     1163//        dim_unlock();
     1164        return;
     1165    }
     1166    if (strlen(I->getFormat()) == 0)
     1167    {
     1168        ostringstream str;
     1169        str << "Format of " << I->getName() << " is empty. Ignoring it";
     1170        Error(str);
    11331171        return;
    11341172    }
     
    11381176    if (I->getTimestamp() == 0)
    11391177    {
    1140         dim_unlock();
     1178//        dim_unlock();
    11411179        return;
    11421180    }
     
    11491187    ReportPlease(I, y->second);
    11501188
    1151     dim_unlock();
     1189//    dim_unlock();
    11521190    //update the fits files sizes
    11531191    UpdateStatisticsService();
     
    14361474            str << " failed: " << e.what();
    14371475            Error(str);
     1476//            if (fDebugIsOn)
     1477//           {
     1478//              ostringstream str2;
     1479//             str2 << sub.dimInfo->getString() << "\n";
     1480//                Debug(str2);
     1481//            }
    14381482            return;
    14391483        }
     
    23182362    //it may be that dim tries to write a dimInfo at the same time as we're closing files. Prevent this
    23192363
    2320     dim_lock();
     2364//    dim_lock();
    23212365    for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
    23222366    {
     
    23522396        RemoveOldestRunNumber();
    23532397    }
    2354     dim_unlock();
     2398//    dim_unlock();
    23552399    return kSM_WaitingRun;
    23562400}
     
    23702414       StopRunPlease();
    23712415   //it may be that dim tries to write a dimInfo while we're closing files. Prevent that
    2372    dim_lock();
     2416//   dim_lock();
    23732417   const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
    23742418    if (fNightlyLogFile.is_open())
     
    24012445    CreateFitsGrouping(fOpenedNightlyFits, 0);
    24022446#endif
    2403     dim_unlock();
     2447//    dim_unlock();
    24042448    return kSM_Ready;
    24052449}
Note: See TracChangeset for help on using the changeset viewer.