Index: trunk/zoo-project/zoo-kernel/service_internal.c
===================================================================
--- trunk/zoo-project/zoo-kernel/service_internal.c	(revision 383)
+++ trunk/zoo-project/zoo-kernel/service_internal.c	(revision 384)
@@ -78,49 +78,39 @@
 
 void updateStatus(maps *conf){
-	fprintf(stderr,"OK Final 1 \n");
-	fflush(stderr);
-	LPWSTR lpszTmp;
-	BOOL fInit;
-	char *s=NULL;
-	map *tmpMap=getMapFromMaps(conf,"lenv","sid");
-	fprintf(stderr,"OK Final 11 \n");
-	fflush(stderr);
-	if(hMapObjectG==NULL)
-	hMapObjectG = CreateFileMapping( 
-		INVALID_HANDLE_VALUE,   // use paging file
-		NULL,                   // default security attributes
-		PAGE_READWRITE,         // read/write access
-		0,                      // size: high 32-bits
-		SHMEMSIZE,              // size: low 32-bits
-		TEXT(tmpMap->value));   // name of map object
-	if (hMapObjectG == NULL){
-		fprintf(stderr,"Unable to create share memory segment %s !! \n",tmpMap->value);
-		return ;
-	}
-	fprintf(stderr,"OK Final 2 \n");
-	fflush(stderr);
-	fInit = (GetLastError() != ERROR_ALREADY_EXISTS); 
-	if(lpvMemG==NULL)
-	lpvMemG = MapViewOfFile( 
-		hMapObjectG,     // object to map view of
-		FILE_MAP_WRITE, // read/write access
-		0,              // high offset:  map from
-		0,              // low offset:   beginning
-		0);             // default: map entire file
-	if (lpvMemG == NULL){
-		fprintf(stderr,"Unable to create or access the shared memory segment %s !! \n",tmpMap->value);
-		return ;
-	} 
-	fprintf(stderr,"OK Final 3 \n");
-	fflush(stderr);
-	if (fInit)
-		memset(lpvMemG, '\0', SHMEMSIZE);
-	fprintf(stderr,"OK Final 4 \n");
-	fflush(stderr);
-	tmpMap=getMapFromMaps(conf,"lenv","status");
-	lpszTmp = (LPWSTR) lpvMemG;
-	for(s=tmpMap->value;*s!=NULL;s++)
-		*lpszTmp++ = *s;
-	*lpszTmp = '\0'; 
+  LPWSTR lpszTmp;
+  BOOL fInit;
+  char *s=NULL;
+  map *tmpMap=getMapFromMaps(conf,"lenv","sid");
+  if(hMapObjectG==NULL)
+    hMapObjectG = CreateFileMapping( 
+				    INVALID_HANDLE_VALUE,   // use paging file
+				    NULL,                   // default security attributes
+				    PAGE_READWRITE,         // read/write access
+				    0,                      // size: high 32-bits
+				    SHMEMSIZE,              // size: low 32-bits
+				    TEXT(tmpMap->value));   // name of map object
+  if (hMapObjectG == NULL){
+    fprintf(stderr,"Unable to create share memory segment %s !! \n",tmpMap->value);
+    return ;
+  }
+  fInit = (GetLastError() != ERROR_ALREADY_EXISTS); 
+  if(lpvMemG==NULL)
+    lpvMemG = MapViewOfFile( 
+			    hMapObjectG,     // object to map view of
+			    FILE_MAP_WRITE, // read/write access
+			    0,              // high offset:  map from
+			    0,              // low offset:   beginning
+			    0);             // default: map entire file
+  if (lpvMemG == NULL){
+    fprintf(stderr,"Unable to create or access the shared memory segment %s !! \n",tmpMap->value);
+    return ;
+  } 
+  if (fInit)
+    memset(lpvMemG, '\0', SHMEMSIZE);
+  tmpMap=getMapFromMaps(conf,"lenv","status");
+  lpszTmp = (LPWSTR) lpvMemG;
+  for(s=tmpMap->value;*s!=NULL;s++)
+    *lpszTmp++ = *s;
+  *lpszTmp = '\0'; 
 }
 
@@ -159,10 +149,5 @@
     return "-1"; 
   lpszTmp = (LPWSTR) lpvMem;
-  while (*lpszTmp!=NULL)
-    *lpszBuf++ = *lpszTmp++;
-  *lpszBuf = '\0';
-  fIgnore = UnmapViewOfFile(lpvMem); 
-  fIgnore = CloseHandle(hMapObject);
-  return (char*)lpszBuf;
+  return (char*)lpszTmp;
 }
 
@@ -1391,4 +1376,5 @@
   char *encoding=getEncoding(m);
   if(pid==getpid()){
+    printHeaders(m);
     printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
   }
@@ -1745,5 +1731,4 @@
   xmlNodePtr n;
 
-  printHeaders(m);
   doc = xmlNewDoc(BAD_CAST "1.0");
   maps* tmpMap=getMaps(m,"main");
@@ -1752,9 +1737,13 @@
     map *tmpSid=getMapFromMaps(m,"lenv","sid");
     if(tmpSid!=NULL){
-      if( getpid()==atoi(tmpSid->value) )
+      if( getpid()==atoi(tmpSid->value) ){
+	printHeaders(m);
 	printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
-    }
-    else
+      }
+    }
+    else{
+      printHeaders(m);
       printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
+    }
   }else
     printf("Content-Type: text/xml; charset=%s\r\nStatus: 200 OK\r\n\r\n",encoding);
@@ -1862,6 +1851,4 @@
   }
   
-  printHeaders(m);
-
   if(asRaw==0){
 #ifdef DEBUG
@@ -2007,5 +1994,5 @@
 	if(rs!=NULL)
 	  printf("Content-Length: %s\r\n",rs->value);
-
+	printHeaders(m);
 	char mime[1024];
 	map* mi=getMap(tmpI->content,"mimeType");
