certi-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[certi-cvs] certi RTIA/FederationManagement.cc RTIA/RTIA.cc...


From: certi-cvs
Subject: [certi-cvs] certi RTIA/FederationManagement.cc RTIA/RTIA.cc...
Date: Fri, 14 Mar 2008 14:52:24 +0000

CVSROOT:        /sources/certi
Module name:    certi
Changes by:     ROUSSELOT <rousse>      08/03/14 14:52:24

Modified files:
        RTIA           : FederationManagement.cc RTIA.cc RTIA.hh 
                         RTIA_federate.cc 
        RTIG           : FederationsList.cc RTIG_processing.cc 

Log message:
        Bug #22578, #22509, #22591 corrections

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/FederationManagement.cc?cvsroot=certi&r1=3.50&r2=3.51
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.cc?cvsroot=certi&r1=3.14&r2=3.15
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA.hh?cvsroot=certi&r1=3.10&r2=3.11
http://cvs.savannah.gnu.org/viewcvs/certi/RTIA/RTIA_federate.cc?cvsroot=certi&r1=3.68&r2=3.69
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/FederationsList.cc?cvsroot=certi&r1=3.53&r2=3.54
http://cvs.savannah.gnu.org/viewcvs/certi/RTIG/RTIG_processing.cc?cvsroot=certi&r1=3.56&r2=3.57

Patches:
Index: RTIA/FederationManagement.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/FederationManagement.cc,v
retrieving revision 3.50
retrieving revision 3.51
diff -u -b -r3.50 -r3.51
--- RTIA/FederationManagement.cc        12 Mar 2008 15:00:45 -0000      3.50
+++ RTIA/FederationManagement.cc        14 Mar 2008 14:52:23 -0000      3.51
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationManagement.cc,v 3.50 2008/03/12 15:00:45 rousse Exp $
+// $Id: FederationManagement.cc,v 3.51 2008/03/14 14:52:23 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -216,7 +216,8 @@
     //if (strcmp(theName, _nom_federation))
     //    e = e_FederationExecutionDoesNotExist ;
 
-    if (e == e_NO_EXCEPTION) {
+    if (e == e_NO_EXCEPTION)
+        {
         requete.type = NetworkMessage::DESTROY_FEDERATION_EXECUTION ;
         requete.federation = _numero_federation ;
         requete.federate = federate ;
@@ -231,7 +232,8 @@
                           NetworkMessage::DESTROY_FEDERATION_EXECUTION,
                           federate);
 
-        if (reponse.exception == e_NO_EXCEPTION) {
+        if (reponse.exception == e_NO_EXCEPTION)
+            {
             _nom_federation = NULL ;
             _numero_federation = 0 ;
             //_est_createur_federation = false ;
@@ -270,10 +272,15 @@
 
     e = e_NO_EXCEPTION ;
 
+    // this federate, may be, has yet joined federation so don't disturb RTIG
     if (_est_membre_federation)
+        {
         e = e_FederateAlreadyExecutionMember ;
+        return(0);
+        }
 
-    if (e == e_NO_EXCEPTION) {
+    if (e == e_NO_EXCEPTION)
+        {
         requete.type = NetworkMessage::JOIN_FEDERATION_EXECUTION ;
         requete.federationName = new char[strlen(Federation)+1] ;
         strcpy(requete.federationName, Federation);
@@ -291,11 +298,13 @@
 
         if ( reponse.exception != e_NO_EXCEPTION)
             {
-            // Bad answer from RTIG
+            // Bad answer from RTIG, join has failed
+            // We will receive a JFE message with exception
             e = reponse.exception ;
             }
         else
             {
+            // Good answer from RTIG, we will get FED file
            stat->rtiService(NetworkMessage::GET_FED_FILE);
             // RTIA have to open a new file for working
             // We have to build a name for working file, name begins by _RTIA_ 
(6 char)
@@ -323,7 +332,9 @@
                   strcat(filename,".xml");
                   } 
               else 
+                  {
                   throw CouldNotOpenFED("nor .fed nor .xml"); 
+                  }
             // FED filename for working must be stored
             _FEDid =  new char[strlen(filename)+1] ;
             strcpy(_FEDid,filename) ;              
@@ -381,16 +392,17 @@
                 }
             // close working file
             fclose(fdd); 
-            }                          
- 
         G.Out(pdGendoc,"joinFederationExecution====> end FED file get from 
RTIG"); 
+            }
           
          // Waiting RTIG answer (from any federate)
+            // We always receive an answer JFE message from RTIG
         comm->waitMessage(&reponse, NetworkMessage::JOIN_FEDERATION_EXECUTION, 
0);
 
         // If OK, regulators number is inside the answer.
         // Then we except a NULL message from each.
-        if (reponse.exception == e_NO_EXCEPTION) {
+            if (reponse.exception == e_NO_EXCEPTION)
+                {
             _nom_federation = new char[strlen(Federation)+1] ;
             strcpy(_nom_federation, Federation);
             strcpy(_nom_federe, Federate);
@@ -404,19 +416,20 @@
 #endif
 
             nb = reponse.numberOfRegulators ;
-            for (i=0 ; i<nb ; i++) {
+                for (i=0 ; i<nb ; i++)
+                    {
                 comm->waitMessage(&reponse, NetworkMessage::MESSAGE_NULL, 0);
                 assert(tm != NULL);
                 tm->insert(reponse.federate, reponse.date);
             }
-
             _est_membre_federation = true ;
             G.Out(pdGendoc,"exit(%d) 
FederationManagement::joinFederationExecution",federate);
             return(federate);
         }
         else
-            e = reponse.exception ;
+                 {e = reponse.exception ;}
     }
+ 
     G.Out(pdGendoc,"exit(0) FederationManagement::joinFederationExecution");
     return(0);
 }
@@ -1012,4 +1025,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: FederationManagement.cc,v 3.50 2008/03/12 15:00:45 rousse Exp $
+// $Id: FederationManagement.cc,v 3.51 2008/03/14 14:52:23 rousse Exp $

Index: RTIA/RTIA.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.cc,v
retrieving revision 3.14
retrieving revision 3.15
diff -u -b -r3.14 -r3.15
--- RTIA/RTIA.cc        13 Mar 2008 14:39:19 -0000      3.14
+++ RTIA/RTIA.cc        14 Mar 2008 14:52:23 -0000      3.15
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIA.cc,v 3.14 2008/03/13 14:39:19 siron Exp $
+// $Id: RTIA.cc,v 3.15 2008/03/14 14:52:23 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -62,6 +62,15 @@
 {
     // BUG: TCP link destroyed ?
 
+     // Remove temporary file (if not yet done)
+     if ( fm->_FEDid != NULL)
+        {
+        if ( fm->_FEDid[0] != '\0' )
+           {
+           std::remove(fm->_FEDid);
+           fm->_FEDid[0] = '\0' ;
+           }
+        }
     delete tm ;
     delete dm ;
     delete om ;
@@ -161,4 +170,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: RTIA.cc,v 3.14 2008/03/13 14:39:19 siron Exp $
+// $Id: RTIA.cc,v 3.15 2008/03/14 14:52:23 rousse Exp $

Index: RTIA/RTIA.hh
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA.hh,v
retrieving revision 3.10
retrieving revision 3.11
diff -u -b -r3.10 -r3.11
--- RTIA/RTIA.hh        16 Nov 2007 15:04:21 -0000      3.10
+++ RTIA/RTIA.hh        14 Mar 2008 14:52:23 -0000      3.11
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIA.hh,v 3.10 2007/11/16 15:04:21 rousse Exp $
+// $Id: RTIA.hh,v 3.11 2008/03/14 14:52:23 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #ifndef _CERTI_RTIA_HH
@@ -65,11 +65,12 @@
     void processNetworkMessage(NetworkMessage *);
     void processFederateRequest(Message *);
     void chooseFederateProcessing(Message *, Message &, TypeException &)
-       throw 
(CouldNotOpenFED,FederationExecutionAlreadyExists,ErrorReadingFED);
+       throw (CouldNotOpenFED,FederationExecutionAlreadyExists,ErrorReadingFED,
+              FederateAlreadyExecutionMember);
 };
 
 }} // namespace certi
 
 #endif // _CERTI_RTIA_HH
 
-// $Id: RTIA.hh,v 3.10 2007/11/16 15:04:21 rousse Exp $
+// $Id: RTIA.hh,v 3.11 2008/03/14 14:52:23 rousse Exp $

Index: RTIA/RTIA_federate.cc
===================================================================
RCS file: /sources/certi/certi/RTIA/RTIA_federate.cc,v
retrieving revision 3.68
retrieving revision 3.69
diff -u -b -r3.68 -r3.69
--- RTIA/RTIA_federate.cc       13 Mar 2008 14:39:19 -0000      3.68
+++ RTIA/RTIA_federate.cc       14 Mar 2008 14:52:23 -0000      3.69
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIA_federate.cc,v 3.68 2008/03/13 14:39:19 siron Exp $
+// $Id: RTIA_federate.cc,v 3.69 2008/03/14 14:52:23 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -92,7 +92,8 @@
 //! Choose federate processing.
 void
 RTIA::chooseFederateProcessing(Message *req, Message &rep, TypeException &e)
-       throw (CouldNotOpenFED,FederationExecutionAlreadyExists,ErrorReadingFED)
+       throw (CouldNotOpenFED,FederationExecutionAlreadyExists,ErrorReadingFED,
+              FederateAlreadyExecutionMember)
 {
     G.Out(pdGendoc,"enter RTIA::chooseFederateProcessing for type = 
%d",req->type);
 
@@ -137,6 +138,8 @@
           rep.setFederate(fm->joinFederationExecution(req->getFederateName(),
                                                       req->getFederationName(),
                                                       e));
+          if ( e == e_NO_EXCEPTION )              
+              {
           /// Set RTIA PrettyDebug federate name
           PrettyDebug::setFederateName(req->getFederateName());
           // Set federation name for the answer message (rep)
@@ -191,6 +194,13 @@
               throw CouldNotOpenFED("File not found");
           break ;
       }
+          else
+              {
+              // JOIN FAILED
+              throw FederateAlreadyExecutionMember("Federate yet joined or 
same name");
+              break;
+              }
+      }
       case Message::RESIGN_FEDERATION_EXECUTION:
         D.Out(pdTrace,
               "Receiving Message from Federate, type ResignFederation.");
@@ -1054,7 +1064,7 @@
     }
     catch (FederateAlreadyExecutionMember &e) {
         D.Out(pdExcept, "Catched %s Exception.", e._name);
-        rep.setException(e_FederateAlreadyExecutionMember);
+        rep.setException(e_FederateAlreadyExecutionMember,e._reason);
     }
     catch (FederateDoesNotExist &e) {
         D.Out(pdExcept, "Catched %s Exception.", e._name);
@@ -1318,4 +1328,4 @@
 
 }} // namespace certi/rtia
 
-// $Id: RTIA_federate.cc,v 3.68 2008/03/13 14:39:19 siron Exp $
+// $Id: RTIA_federate.cc,v 3.69 2008/03/14 14:52:23 rousse Exp $

Index: RTIG/FederationsList.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/FederationsList.cc,v
retrieving revision 3.53
retrieving revision 3.54
diff -u -b -r3.53 -r3.54
--- RTIG/FederationsList.cc     28 Feb 2008 14:47:58 -0000      3.53
+++ RTIG/FederationsList.cc     14 Mar 2008 14:52:24 -0000      3.54
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: FederationsList.cc,v 3.53 2008/02/28 14:47:58 rousse Exp $
+// $Id: FederationsList.cc,v 3.54 2008/03/14 14:52:24 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -100,13 +100,16 @@
     G.Out(pdGendoc,"enter FederationsList::addFederate");
 
     // It may throw RTIinternalError
+    // Verify integrity of the handle of the federation
     checkHandle(handle);
 
     // It may throw FederationExecutionDoesNotExist
+    // Return  federation address giving its handle
     Federation *federation = NULL ;
     searchFederation(handle, federation);
 
     // It may raise a bunch of exceptions
+    // adding the federate and return its handle
     FederateHandle federate = federation->add(name, tcp_link);
 
     G.Out(pdGendoc,"exit FederationsList::addFederate");
@@ -1557,5 +1560,5 @@
 
 }} // certi::rtig
 
-// EOF $Id: FederationsList.cc,v 3.53 2008/02/28 14:47:58 rousse Exp $
+// EOF $Id: FederationsList.cc,v 3.54 2008/03/14 14:52:24 rousse Exp $
 

Index: RTIG/RTIG_processing.cc
===================================================================
RCS file: /sources/certi/certi/RTIG/RTIG_processing.cc,v
retrieving revision 3.56
retrieving revision 3.57
diff -u -b -r3.56 -r3.57
--- RTIG/RTIG_processing.cc     5 Mar 2008 15:33:50 -0000       3.56
+++ RTIG/RTIG_processing.cc     14 Mar 2008 14:52:24 -0000      3.57
@@ -18,7 +18,7 @@
 // along with this program ; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 //
-// $Id: RTIG_processing.cc,v 3.56 2008/03/05 15:33:50 rousse Exp $
+// $Id: RTIG_processing.cc,v 3.57 2008/03/14 14:52:24 rousse Exp $
 // ----------------------------------------------------------------------------
 
 #include <config.h>
@@ -152,9 +152,40 @@
 
     federations.exists(federation, num_federation);
 
+    try
+       {
     num_federe = federations.addFederate(num_federation,
                                           federate,
                                           (SecureTCPSocket *) link);
+        }
+    catch (RTI::FederateAlreadyExecutionMember &e)
+        {
+        // Federate yet has joined this federation(same or another with same 
name)
+        // RTIG has to return something to RTIA
+        // RTIA waits a GET_FED_FILE message
+        // RTIG says not OK to RTIA in a GET_FED_FILE message
+        NetworkMessage repFED ;
+       repFED.type = NetworkMessage::GET_FED_FILE ;
+       repFED.exception = e_FederateAlreadyExecutionMember ;
+       strcpy(repFED.exceptionReason,"Federate with same name has yet joined 
the federation");
+
+       G.Out(pdGendoc,"processJoinFederation==>Answer to RTIA GFF ERROR 
%s",repFED.exceptionReason);
+
+       repFED.write(link);
+
+       G.Out(pdGendoc,"exit RTIG::processJoinFederation on Error");
+       G.Out(pdGendoc,"END ** JOIN FEDERATION (BAD) SERVICE **");
+       // Prepare answer about JoinFederationExecution
+       NetworkMessage rep ;
+      rep.type = NetworkMessage::JOIN_FEDERATION_EXECUTION ;
+      rep.exception = e_FederateAlreadyExecutionMember ;
+      strcpy(rep.exceptionReason,"Federate with same name has yet joined the 
federation");
+
+      G.Out(pdGendoc,"processJoinFederation==>Answer to RTIA JFE ERROR 
%s",rep.exceptionReason);
+
+      rep.write(link);
+      return ;
+       }               
 
 #ifdef FEDERATION_USES_MULTICAST
     SocketMC *com_mc = NULL ;
@@ -1404,4 +1435,4 @@
 
 }} // namespace certi/rtig
 
-// $Id: RTIG_processing.cc,v 3.56 2008/03/05 15:33:50 rousse Exp $
+// $Id: RTIG_processing.cc,v 3.57 2008/03/14 14:52:24 rousse Exp $




reply via email to

[Prev in Thread] Current Thread [Next in Thread]