Index: /trunk/FACT++/src/datalogger.cc
===================================================================
--- /trunk/FACT++/src/datalogger.cc	(revision 11264)
+++ /trunk/FACT++/src/datalogger.cc	(revision 11265)
@@ -385,4 +385,8 @@
     ///Remove all the services associated with a given server
     void RemoveAllServices(const string&);
+    ///Remove a server and all of its services
+    void RemoveServer(const std::string &s);
+    ///Remove all the servers and all subscriptions
+    void RemoveAllServers();
 }; //DataLogger
 
@@ -470,5 +474,5 @@
 void DataLogger::AddService(const string& server, const string& service, const string&, bool isCmd)
 {
-         //dataLogger does not subscribe to commands
+    //dataLogger does not subscribe to commands
     if (isCmd)
         return;
@@ -486,5 +490,6 @@
     }
 
-    list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
+//    list[service].dimInfo = shared_ptr<DimStampedInfo>(SubscribeToPlease(server, service));
+    list[service].dimInfo.reset(SubscribeToPlease(server, service));
     list[service].server  = server;
     list[service].service = service;
@@ -535,4 +540,26 @@
         Debug("Removed all subscriptions to " + server + "/");
     }
+}
+// --------------------------------------------------------------------------
+//
+//! Remove a given server
+//! @param s the server to be removed
+//
+void DataLogger::RemoveServer(const std::string &s)
+{
+    if (fServiceSubscriptions.erase(s) != 1)
+    {
+        Error("The server " + s + " to be removed was not in the servers list");
+    }
+    DimServiceInfoList::RemoveServer(s);
+}
+// --------------------------------------------------------------------------
+//
+//! Remove all the server and associated subscriptions
+//
+void DataLogger::RemoveAllServers()
+{
+    fServiceSubscriptions.clear();
+    DimServiceInfoList::RemoveAllServers();
 }
 // --------------------------------------------------------------------------
@@ -1032,5 +1059,5 @@
          RemoveOldestRunNumber();
      }
-    dim_unlock();
+//    dim_unlock();
     delete fOpenedNightlyFiles;
     delete fOpenedRunFiles;
@@ -1060,4 +1087,8 @@
     fPreviousStatsUpdateTime = cTime;
     //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
+    if (fStatVar.writingRate < 0)
+        fStatVar.writingRate = 0;
+    if (fStatVar.sizeWritten < 0)
+        fStatVar.sizeWritten = 0;
     fStatsMonitoring->updateService();
 
@@ -1104,5 +1135,5 @@
 
     //it may happen that we try to write a dimInfo while closing files. Prevent that with a dim_lock()
-    dim_lock();
+//    dim_lock();
 
     //check if the service pointer corresponds to something that we subscribed to
@@ -1125,10 +1156,17 @@
     {
         DimServiceInfoList::infoHandler();
-        dim_unlock();
+//        dim_unlock();
         return;
     }
     if (I->getSize() <= 0 || I->getData()==NULL)
     {
-        dim_unlock();
+//        dim_unlock();
+        return;
+    }
+    if (strlen(I->getFormat()) == 0)
+    {
+        ostringstream str;
+        str << "Format of " << I->getName() << " is empty. Ignoring it";
+        Error(str);
         return;
     }
@@ -1138,5 +1176,5 @@
     if (I->getTimestamp() == 0)
     {
-        dim_unlock();
+//        dim_unlock();
         return;
     }
@@ -1149,5 +1187,5 @@
     ReportPlease(I, y->second);
 
-    dim_unlock();
+//    dim_unlock();
     //update the fits files sizes
     UpdateStatisticsService();
@@ -1436,4 +1474,10 @@
             str << " failed: " << e.what();
             Error(str);
+//            if (fDebugIsOn)
+//           {
+//              ostringstream str2;
+//             str2 << sub.dimInfo->getString() << "\n";
+//                Debug(str2);
+//            }
             return;
         }
@@ -2318,5 +2362,5 @@
     //it may be that dim tries to write a dimInfo at the same time as we're closing files. Prevent this
 
-    dim_lock();
+//    dim_lock();
     for (list<RunNumberType>::const_iterator it=fRunNumber.begin(); it != fRunNumber.end(); it++)
     {
@@ -2352,5 +2396,5 @@
         RemoveOldestRunNumber();
     }
-    dim_unlock();
+//    dim_unlock();
     return kSM_WaitingRun;
 }
@@ -2370,5 +2414,5 @@
        StopRunPlease();
    //it may be that dim tries to write a dimInfo while we're closing files. Prevent that
-   dim_lock();
+//   dim_lock();
    const string baseFileName = CompileFileNameWithPath(fNightlyFilePath, "", "");
     if (fNightlyLogFile.is_open())
@@ -2401,5 +2445,5 @@
     CreateFitsGrouping(fOpenedNightlyFits, 0);
 #endif
-    dim_unlock();
+//    dim_unlock();
     return kSM_Ready;
 }
