Index: /trunk/FACT++/dim/README_v19.txt
===================================================================
--- /trunk/FACT++/dim/README_v19.txt	(revision 11880)
+++ /trunk/FACT++/dim/README_v19.txt	(revision 11881)
@@ -1,4 +1,4 @@
 
-                    DIM version 19.23 Release Notes
+                    DIM version 19.24 Release Notes
 
 Notes 1 and 2 for Unix Users only
@@ -17,5 +17,13 @@
 		Dns </dev/null >& dns.log &
 
-NOTE 3: The Version Number service provided by servers is now set to 1923.
+NOTE 3: The Version Number service provided by servers is now set to 1924.
+
+08/08/2011
+Changes for version 19.24:
+    - The funtion DimInfo::getFormat() never return the correct format of a service, if the first time
+      it was called, the service was not available, i.e. when called inside a "no_link" callback - Fixed.
+    - Deleting the last service of a server or stopping a server could generate "Invalid Service Id"
+      messages from the service that updates DID - Fixed.
+
 
 15/07/2011
Index: /trunk/FACT++/dim/dim/dim.h
===================================================================
--- /trunk/FACT++/dim/dim/dim.h	(revision 11880)
+++ /trunk/FACT++/dim/dim/dim.h	(revision 11881)
@@ -14,5 +14,5 @@
 #include "dim_common.h"
 
-#define DIM_VERSION_NUMBER 1923
+#define DIM_VERSION_NUMBER 1924
 
 #define MY_LITTLE_ENDIAN	0x1
Index: /trunk/FACT++/dim/src/diccpp.cxx
===================================================================
--- /trunk/FACT++/dim/src/diccpp.cxx	(revision 11880)
+++ /trunk/FACT++/dim/src/diccpp.cxx	(revision 11881)
@@ -110,12 +110,20 @@
 {
 	char *def;
+	int len = 0, new_len;
 
 	if(itsFormat)
 	{
-		return itsFormat;
+		len = strlen(itsFormat)+1;
+		if(len > 1)
+			return itsFormat;
 	}
 	def = dic_get_format(itsId);
-
-	itsFormat = new char[strlen(def)+1];
+	new_len = strlen(def)+1;
+	if(new_len > len)
+	{
+		if(itsFormat)
+			delete[] itsFormat;
+		itsFormat = new char[strlen(def)+1];
+	}
 	strcpy(itsFormat, def);
 	return itsFormat;
Index: /trunk/FACT++/dim/src/dis.c
===================================================================
--- /trunk/FACT++/dim/src/dis.c	(revision 11880)
+++ /trunk/FACT++/dim/src/dis.c	(revision 11881)
@@ -1015,5 +1015,6 @@
 {
 	dnsp->updating_service_list = 0;
-	dis_update_service(dnsp->dis_service_id);
+	if(dnsp->dis_service_id)
+		dis_update_service(dnsp->dis_service_id);
 }
 
Index: /trunk/FACT++/dim/src/examples/test_client.c
===================================================================
--- /trunk/FACT++/dim/src/examples/test_client.c	(revision 11880)
+++ /trunk/FACT++/dim/src/examples/test_client.c	(revision 11881)
@@ -64,5 +64,8 @@
 int *tag, *size;
 {
+	char *format;
 
+	format = dic_get_format(0);
+	printf("Received format = %s %08x, %d\n",format, format, *size);
 	if(*tag == 1100)
 	{
@@ -91,5 +94,5 @@
 	}
 	else
-		printf("%s Received %s for Service%03d\n",client_str,buf, *tag);
+		printf("%s Received %s %08X for Service%03d\n",client_str,buf, buf,*tag);
 
 /*
@@ -121,6 +124,8 @@
 	{
 		sprintf(str,"%s/Service_%03d",argv[2],i);
+//		dic_info_service( str, TIMED, 10, 0, 0, rout, i,
+//			  "No Link", 8 );
 		dic_info_service( str, TIMED, 10, 0, 0, rout, i,
-			  "No Link", 8 );
+			  NULL, 0 );
 	}
 	
Index: /trunk/FACT++/dim/src/examples/test_client.cxx
===================================================================
--- /trunk/FACT++/dim/src/examples/test_client.cxx	(revision 11880)
+++ /trunk/FACT++/dim/src/examples/test_client.cxx	(revision 11881)
@@ -30,6 +30,8 @@
 		int index = 0;
 		char **services;
+		char *format;
 //		cout << "Dns Node = " << DimClient::getDnsNode() << endl;
-		cout << "Received STRVAL : " << getString() << endl;
+		format = getFormat();
+		cout << "Received STRVAL : " << getString() << "format = " << format << endl;
 		services = DimClient::getServerServices();
 		cout<< "from "<< DimClient::getServerName() << " services:" << endl;
Index: /trunk/FACT++/dim/src/examples/test_server.cxx
===================================================================
--- /trunk/FACT++/dim/src/examples/test_server.cxx	(revision 11880)
+++ /trunk/FACT++/dim/src/examples/test_server.cxx	(revision 11881)
@@ -1,2 +1,62 @@
+//============================================================================
+// Name        : emptyDimFormat.cpp
+// Author      : Etienne Lyard etienne.lyard@unige.ch
+// Version     : 00
+// Copyright   :
+// Description : Demonstrates the occurence of an empty Dim format from the client's perspective
+//============================================================================
+/*
+#include <dic.hxx>
+#include <dis.hxx>
+#include <iostream>
+using namespace std;
+
+class EmptyServiceSubscriber : public DimInfo
+{
+    DimStampedInfo* info;
+	int noLink;
+public:
+    EmptyServiceSubscriber()
+    {
+//        info = new DimStampedInfo("TIME/EMPTY", const_cast<char*>(""), this);
+		noLink = -1;
+        info = new DimStampedInfo("TIME/EMPTY", noLink, this);
+    }
+    void infoHandler()
+    {
+        DimInfo* I = getInfo();
+		int data;
+        if (I == info)
+		{
+			data = I->getInt();
+//		cout << "EMPTY SERVICE UPDATED. " << "Format: " << I->getFormat() << endl;
+			cout << "EMPTY SERVICE UPDATED. " << data << " Format: " << I->getFormat() << endl;
+		}
+    }
+};
+
+int main(int, const char**)
+{
+    DimServer::start("TIME");
+
+    int emptyFormatVariable = 0;
+    DimService* emptyFormatService = new DimService("TIME/EMPTY", "I:1", &emptyFormatVariable, sizeof(long));
+    EmptyServiceSubscriber mySubscriber;
+    //The three lines below create (most of the time) an empty format on the client side.
+    //We must be able to deal with such cases in our framework because services can be stopped and re-spawned at any time
+    delete emptyFormatService;
+    usleep(1000000);
+    emptyFormatService = new DimService("TIME/EMPTY", "I:1", &emptyFormatVariable, sizeof(long));
+
+    while (1)
+    {
+        emptyFormatService->updateService();
+        usleep(1000000);
+    }
+
+	return 0;
+}
+*/
+
 #include <iostream>
 #include <dis.hxx>
