Index: /Evidence/DColl.cc
===================================================================
--- /Evidence/DColl.cc	(revision 212)
+++ /Evidence/DColl.cc	(revision 213)
@@ -80,5 +80,5 @@
 	void AddService(string);
 	void RemoveService(string);
-	float FileSize(FILE *);
+	off_t FileSize(FILE *);
 	FILE *OpenHistFile(string, const char *);
    
@@ -124,5 +124,5 @@
   DataSizeService = new DimService(SERVER_NAME "/DataSizekB", DataSizekB);
   
-  LogSizekB = FileSize(LogFile);
+  LogSizekB = FileSize(LogFile)/1024.0;
   LogSizeService = new DimService(SERVER_NAME "/LogSizekB", LogSizekB);
 
@@ -220,4 +220,5 @@
   // ====== Part A: Handle service subscriptions ===
   //
+  // Services are added here, removal only in constructor.
   
   // If service is DIS_DNS/SERVER_LIST, subscribe to all SERVICE_LIST services
@@ -225,5 +226,5 @@
 	char *Token = strtok(Info->getString(), "+-!@");	
 	while (Token != NULL) {
-	  if (*Info->getString()=='+') AddService(string(Token)+"/SERVICE_LIST");
+	  AddService(string(Token)+"/SERVICE_LIST"); // 'add' also for '-' and '!'
 	  Token = strtok(NULL, "|"); // Skip server IP address
 	  Token = strtok(NULL, "@");
@@ -240,8 +241,5 @@
 	  char *Type = strtok(NULL, "\n");
 	  if (Type == NULL) return; // for safety, should not happen
-      if (strstr(Type, "|CMD")==NULL && strstr(Type, "|RPC")==NULL) {
-	    // Add or remove service
-	    if (*Info->getString()=='+') AddService(Name);
-	  }
+      if (strstr(Type, "|CMD")==NULL && strstr(Type, "|RPC")==NULL) AddService(Name); // 'add' also for '-' and '!'
 	  Name = strtok(NULL, "|");
 	}
@@ -346,5 +344,5 @@
       fflush(DataFile); // not continuously to reduce load
 
-	  DataSizekB = FileSize(DataFile);
+	  DataSizekB = FileSize(DataFile)/1024.0;
 	  DataSizeService->updateService();
 	  DataSizeLastUpdate = time(NULL);
@@ -454,5 +452,5 @@
   // Update logfile size service
   if (time(NULL) - LogSizeLastUpdate > SizeUpdateDelay) {
-	LogSizekB = FileSize(LogFile);
+	LogSizekB = FileSize(LogFile)/1024.0;
 	LogSizeService->updateService();
 	LogSizeLastUpdate = time(NULL);
@@ -473,7 +471,27 @@
 	}
   }
-  
-  // Default response
-  setData(NULL, 0);
+
+  // Try to open history file if not found in memory
+  FILE *File = OpenHistFile(getString(), "rb");
+  if (File == NULL) {
+    setData(NULL, 0);
+	return;
+  }
+
+  // Read history file
+  off_t Size = FileSize(File);
+  if (Size != -1) {
+	char *Buffer = new char [Size-sizeof(int)];
+	fseek(File, sizeof(int), SEEK_SET);
+	fread(Buffer, sizeof(char), Size-sizeof(int), File);
+	if (ferror(File) != 0) {
+	  State(WARN, "Error reading history file '%s' in rpcHandler()", getString());
+	  setData(NULL, 0);		// Default response
+	}
+	else setData((void *) Buffer, Size);
+	delete[] Buffer;
+  }
+  
+  if (fclose(File) != 0) State(WARN, "Error closing history file '%s' in rpcHandler()", getString());
 }
 
@@ -517,5 +535,6 @@
       fread(&New.Next, sizeof(New.Next), 1, File);
       fread(New.Buffer, sizeof(char), New.HistSize, File);
-      fclose(File);
+	  if (ferror(File) != 0) State(WARN, "Error reading history file '%s' in AddService()", Name.c_str());
+      if (fclose(File) != 0) State(WARN, "Error closing history file '%s' in AddService()", Name.c_str());;
 	}
   }
@@ -545,5 +564,6 @@
       fwrite(&(*E).Next, sizeof((*E).Next), 1, File);
       fwrite((*E).Buffer, sizeof(char), (*E).HistSize, File);
-      fclose(File);
+	  if (ferror(File) != 0) State(WARN, "Error writing history file '%s' in RemoveService()", Name.c_str());
+      if (fclose(File) != 0) State(WARN, "Error closing history file '%s' in RemoveService()", Name.c_str());;
 	}
 	
@@ -558,5 +578,5 @@
 // Determine size of file in kB
 //
-float DataHandler::FileSize(FILE *File) {
+off_t DataHandler::FileSize(FILE *File) {
 
   struct stat FileStatus;
@@ -567,5 +587,5 @@
   }
 
-  return (float) FileStatus.st_size/1024;
+  return FileStatus.st_size;
 }
 
Index: /Evidence/readme.txt
===================================================================
--- /Evidence/readme.txt	(revision 212)
+++ /Evidence/readme.txt	(revision 213)
@@ -28,5 +28,7 @@
 			When regular expression compiling results in error, State is set to ERROR, not
 			FATAL. The erroneous expression is ignored in the following.
-25/5/2010	Service history remains available if service itself become unavailable
+25/5/2010	Service history remains available if service itself become unavailable. If not
+			yet in memory, reading from history file is tried. Improved error handling of
+			history files.
 			
 
