Index: XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_client.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_client.cpp	(revision 1550)
+++ XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_client.cpp	(revision 1554)
@@ -125,5 +125,4 @@
          // We force the getBuffers call to be non-blocking on classical servers
         list<CBufferOut*> buffList;
-//        bool couldBuffer = getBuffers(timeLine, ranks, sizes, buffList, (!CXios::isClient && (CServer::serverLevel == 0) ));
         getBuffers(timeLine, ranks, sizes, buffList) ;
 
@@ -195,5 +194,4 @@
       }
 
-      if (CXios::isServer) info(100)<<" getBuffers : entering loop"<<endl ;
       CTimer::get("Blocking time").resume();
       do
@@ -205,13 +203,9 @@
         }
 
-        if (CXios::isServer) info(100)<<" getBuffers : areBuffersFree ? "<<areBuffersFree<<endl ; ;
         if (!areBuffersFree)
         {
           for (itBuffer = bufferList.begin(); itBuffer != bufferList.end(); itBuffer++) (*itBuffer)->unlockBuffer();
-          if (CXios::isServer) info(100)<<" getBuffers : buffers unlocked "<<endl ;
           checkBuffers();
-          if (CXios::isServer) info(100)<<" getBuffers : buffers checked "<<endl ;
           if (CServer::serverLevel == 0)  context->server->listen();
-          if (CXios::isServer) info(100)<<" getBuffers : server listened... "<<endl ;
           else if (CServer::serverLevel == 1)
           {
@@ -225,5 +219,4 @@
         }
       } while (!areBuffersFree && !nonBlocking);
-      if (CXios::isServer) info(100)<<" getBuffers : out of loop"<<endl ;
       CTimer::get("Blocking time").suspend();
 
@@ -233,5 +226,4 @@
           retBuffers.push_back((*itBuffer)->getBuffer(timeLine, *itSize));
       }
-      if (CXios::isServer) info(100)<<" getBuffers : message pushed"<<endl ;
       return areBuffersFree;
    }
@@ -260,7 +252,5 @@
         MPI_Intercomm_create(commSelf, 0, interCommMerged, clientSize+rank, 0, &OneSidedInterComm );
         MPI_Intercomm_merge(OneSidedInterComm,false,&oneSidedComm);
-        info(100)<<"DEBUG: before creating windows (client)"<<endl ;
         buffer->createWindows(oneSidedComm) ;
-        info(100)<<"DEBUG: after creating windows (client)"<<endl ;
       }
        
@@ -286,11 +276,5 @@
       for (itBuff = buffers.begin(); itBuff != buffers.end(); itBuff++)
       {
-//          CEventClient event(CContext::GetType(), CContext::EVENT_ID_CLOSE_P2P_CHANNEL);
-//          CMessage msg;
-//          event.push(itBuff->first, 1, msg);
-//          timeLine = std::numeric_limits<size_t>::max() ;
-//          sendEvent(event);
-//          while (itBuff->second->checkBuffer(!pureOneSided));
-          delete itBuff->second;
+         delete itBuff->second;
       }
       buffers.clear();
Index: XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_server.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_server.cpp	(revision 1550)
+++ XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/context_server.cpp	(revision 1554)
@@ -84,11 +84,7 @@
   bool CContextServer::eventLoop(bool enableEventsProcessing /*= true*/)
   {
-//    info(100)<<"CContextServer::eventLoop : listen"<<endl ;
     listen();
-//    info(100)<<"CContextServer::eventLoop : checkPendingRequest"<<endl ;
     checkPendingRequest();
-//    info(100)<<"CContextServer::eventLoop : process events"<<endl ;
     if (enableEventsProcessing)  processEvents();
-//    info(100)<<"CContextServer::eventLoop : finished "<<finished<<endl ;
     return finished;
   }
@@ -150,7 +146,5 @@
          MPI_Intercomm_create(commSelf, 0, interCommMerged, rank, 0, &OneSidedInterComm );
          MPI_Intercomm_merge(OneSidedInterComm,true,&oneSidedComm);
-         info(100)<<"DEBUG: before creating windows (server)"<<endl ;
          buffers[rank]->createWindows(oneSidedComm) ;
-         info(100)<<"DEBUG: before creating windows (server)"<<endl ;
        }
        lastTimeLine[rank]=0 ;
@@ -223,5 +217,4 @@
           if (buffers[rank]->getBufferFromClient(timeLine, buffer, count))
           {
-            info(100)<<"get buffer from client : timeLine "<<timeLine<<endl ;
             processRequest(rank, buffer, count);
             break ;
@@ -249,5 +242,4 @@
       CBufferIn newBuffer(startBuffer,buffer.remain());
       newBuffer>>size>>timeLine;
-      info(100)<<"new event :   timeLine : "<<timeLine<<"  size : "<<size<<endl ;
       it=events.find(timeLine);
       if (it==events.end()) it=events.insert(pair<int,CEventServer*>(timeLine,new CEventServer)).first;
Index: XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/node/context.cpp
===================================================================
--- XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/node/context.cpp	(revision 1550)
+++ XIOS/dev/dev_ym/XIOS_ONE_SIDED/src/node/context.cpp	(revision 1554)
@@ -404,24 +404,16 @@
     {
       client->checkBuffers();
-      bool hasTmpBufferedEvent = client->hasTemporarilyBufferedEvent();
-      if (hasTmpBufferedEvent)
-        hasTmpBufferedEvent = !client->sendTemporarilyBufferedEvent();
-      // Don't process events if there is a temporarily buffered event
-      return server->eventLoop(!hasTmpBufferedEvent || !enableEventsProcessing);
+      return server->eventLoop(true);
     }
     else if (CServer::serverLevel == 1)
     {
-      if (!finalized)
-        client->checkBuffers();
+      if (!finalized) client->checkBuffers();
       bool serverFinished = true;
-      if (!finalized)
-        serverFinished = server->eventLoop(enableEventsProcessing);
+      if (!finalized) serverFinished = server->eventLoop(enableEventsProcessing);
       bool serverPrimFinished = true;
       for (int i = 0; i < clientPrimServer.size(); ++i)
       {
-        if (!finalized)
-          clientPrimServer[i]->checkBuffers();
-        if (!finalized)
-          serverPrimFinished *= serverPrimServer[i]->eventLoop(enableEventsProcessing);
+        if (!finalized) clientPrimServer[i]->checkBuffers();
+        if (!finalized) serverPrimFinished *= serverPrimServer[i]->eventLoop(enableEventsProcessing);
       }
       return ( serverFinished && serverPrimFinished);
@@ -456,12 +448,15 @@
        {
          ++countChildCtx_;
-
+         
+         info(100)<<"DEBUG: context "<<getId()<<" Send client finalize"<<endl ;
          client->finalize();
-         while (client->havePendingRequests())
-            client->checkBuffers();
-
+         info(100)<<"DEBUG: context "<<getId()<<" Client finalize sent"<<endl ;
+         while (client->havePendingRequests()) client->checkBuffers();
+         client->releaseBuffers();
+         
+         info(100)<<"DEBUG: context "<<getId()<<" no pending request ok"<<endl ;
          while (!server->hasFinished())
            server->eventLoop();
-
+        info(100)<<"DEBUG: context "<<getId()<<" server has finished"<<endl ;
          if (hasServer) // Mode attache
          {
@@ -472,6 +467,6 @@
 
          //! Deallocate client buffers
-         client->releaseBuffers();
-
+//         client->releaseBuffers();
+        info(100)<<"DEBUG: context "<<getId()<<" release client ok"<<endl ;
          //! Free internally allocated communicators
          for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it)
@@ -488,5 +483,15 @@
        if (countChildCtx_ == 0)
          for (int i = 0; i < clientPrimServer.size(); ++i)
+         {
            clientPrimServer[i]->finalize();
+           bool bufferReleased;
+           do
+           {
+             clientPrimServer[i]->checkBuffers();
+             bufferReleased = !clientPrimServer[i]->havePendingRequests();
+           } while (!bufferReleased);
+           clientPrimServer[i]->releaseBuffers();
+         }
+           
 
        // (Last) context finalized message received
@@ -494,6 +499,7 @@
        {
          // Blocking send of context finalize message to its client (e.g. primary server or model)
-         info(100)<<"DEBUG: context "<<getId()<<" Send client finalize<<"<<endl ;
+         info(100)<<"DEBUG: context "<<getId()<<" Send client finalize"<<endl ;
          client->finalize();
+         info(100)<<"DEBUG: context "<<getId()<<" Client finalize sent"<<endl ;
          bool bufferReleased;
          do
@@ -502,6 +508,8 @@
            bufferReleased = !client->havePendingRequests();
          } while (!bufferReleased);
+         client->releaseBuffers();
          finalized = true;
-
+         info(100)<<"DEBUG: context "<<getId()<<" bufferRelease OK"<<endl ;
+         
          closeAllFile(); // Just move to here to make sure that server-level 1 can close files
          if (hasServer && !hasClient)
@@ -512,8 +520,11 @@
 
          //! Deallocate client buffers
-         client->releaseBuffers();
+//         client->releaseBuffers();
+         info(100)<<"DEBUG: context "<<getId()<<" client release"<<endl ;
+
+/*         
          for (int i = 0; i < clientPrimServer.size(); ++i)
            clientPrimServer[i]->releaseBuffers();
-
+*/
          //! Free internally allocated communicators
          for (std::list<MPI_Comm>::iterator it = comms.begin(); it != comms.end(); ++it)
