Salome HOME
Fix "23657: [CEA] A crash when saving hdf study with GEOM or SMESH objects under...
[modules/kernel.git] / src / Communication / SALOME_Comm_i.cxx
index 632ce7a7375cd2d1474af94cbbf9b6c0b965e9d3..52d59cf18a7ad0c7841a197dd75a2cf5be9647bc 100644 (file)
@@ -1,36 +1,40 @@
-// Copyright (C) 2005  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-// 
+//
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
-// License as published by the Free Software Foundation; either 
-// version 2.1 of the License.
-// 
-// This library is distributed in the hope that it will be useful 
-// but WITHOUT ANY WARRANTY; without even the implied warranty of 
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
-// You should have received a copy of the GNU Lesser General Public  
-// License along with this library; if not, write to the Free Software 
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 //
-// See http://www.salome-platform.org/
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 #include "SALOME_Comm_i.hxx"
-#ifndef WNT
+#ifndef WIN32
+#ifndef __APPLE__
 #include <rpc/xdr.h>
 #endif
-#include "poa.h"
+#endif
+#include "omniORB4/poa.h"
 #include "omnithread.h"
 #include "Utils_SINGLETON.hxx"
 #include "Utils_ORB_INIT.hxx"
 #include "utilities.h"
 
 #include "SenderFactory.hxx"
-using namespace std;
 
-#ifndef WNT
+#ifndef WIN32
 CORBA::ORB_var &getGlobalORB(){
   ORB_INIT &init = *SINGLETON_<ORB_INIT>::Instance();
   CORBA::ORB_var &orb = init(0,0);
@@ -39,7 +43,7 @@ CORBA::ORB_var &getGlobalORB(){
 #endif
 
 /*! Return the C++ data associated to the array to transmit.
-  Used when sender and receiver are collocalized.
+  Used when sender and receiver are colocalized.
  */
 const void *SALOME_Sender_i::getData(long &size) const{
   size=_lgrTabToSend;
@@ -90,7 +94,7 @@ SALOME::SenderDouble_ptr SALOME_SenderDouble_i::buildOtherWithProtocol(SALOME::T
   return SenderFactory::buildSender(type,this);
 }
 
-/*! Method to establish if the CORBA object refered by pCorba is collocalised.\n
+/*! Method to establish if the CORBA object referred by pCorba is colocalized.\n
   If it is, the pointer to the servant that incarnates the CORBA object is returned.
 */
 SALOME_SenderDouble_i *SALOME_SenderDouble_i::find(SALOME::SenderDouble_ptr pCorba){
@@ -124,7 +128,7 @@ SALOME::SenderInt_ptr SALOME_SenderInt_i::buildOtherWithProtocol(SALOME::TypeOfC
   return SenderFactory::buildSender(type,this);
 }
 
-/*! Method to establish if the CORBA object refered by pCorba is collocalised.\n
+/*! Method to establish if the CORBA object referred by pCorba is colocalized.\n
   If it is, the pointer to the servant that incarnates the CORBA object is returned.
 */
 SALOME_SenderInt_i *SALOME_SenderInt_i::find(SALOME::SenderInt_ptr pCorba){
@@ -238,7 +242,7 @@ SALOME_MPISender_i::~SALOME_MPISender_i(){
 SALOME::MPISender::param* SALOME_MPISender_i::getParam()
 {
   char stag[12];
-  int myproc,i=0;
+  int i=0;
 
   SALOME::MPISender::param_var p = new SALOME::MPISender::param;
   MPI_Comm_rank(MPI_COMM_WORLD,&_cproc);
@@ -313,7 +317,6 @@ void* SALOME_MPISender_i::myThread(void *args)
 void SALOME_MPISender_i::close(const SALOME::MPISender::param& p)
 {
   std::string service(p.service);
-  const char *st=p.service;
   void *r;
   _newThr->join(&r);
   MPI_Comm_free(&_com); 
@@ -376,7 +379,7 @@ std::string SALOME_SocketSender_i::inetAddress()
       host = gethostbyname(s);
       if (host != NULL)
          inet_ntop(AF_INET, (struct in_addr *) *host->h_addr_list, 
-                  t, INET_ADDRSTRLEN);
+                   t, INET_ADDRSTRLEN);
    }
    return std::string(t);
 }
@@ -430,19 +433,19 @@ void* SALOME_SocketSender_i::myThread(void *args)
 
       *errorFlag = false;
       while( n < *lgrTabToSend*sizeof(double) ){
-       m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(double)-n);
-       if( m < 0 ){
-         if( *clientSockfd >= 0 ){
-           ::close(*clientSockfd);
-           *clientSockfd = -1;
-         }
-         if( *serverSockfd >= 0 ){
-           ::close(*serverSockfd);
-           *serverSockfd = -1;
-         }
-         *errorFlag = true;
-       }
-       n += m;
+        m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(double)-n);
+        if( m < 0 ){
+          if( *clientSockfd >= 0 ){
+            ::close(*clientSockfd);
+            *clientSockfd = -1;
+          }
+          if( *serverSockfd >= 0 ){
+            ::close(*serverSockfd);
+            *serverSockfd = -1;
+          }
+          *errorFlag = true;
+        }
+        n += m;
       }
       xdr_destroy( &xp );
 
@@ -456,19 +459,19 @@ void* SALOME_SocketSender_i::myThread(void *args)
 
       *errorFlag = false;
       while( n < *lgrTabToSend*sizeof(int) ){
-       m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(int)-n);
-       if( m < 0 ){
-         if( *clientSockfd >= 0 ){
-           ::close(*clientSockfd);
-           *clientSockfd = -1;
-         }
-         if( *serverSockfd >= 0 ){
-           ::close(*serverSockfd);
-           *serverSockfd = -1;
-         }
-         *errorFlag = true;
-       }
-       n += m;
+        m = write(*clientSockfd, (char*)tabToSend+n, *lgrTabToSend*sizeof(int)-n);
+        if( m < 0 ){
+          if( *clientSockfd >= 0 ){
+            ::close(*clientSockfd);
+            *clientSockfd = -1;
+          }
+          if( *serverSockfd >= 0 ){
+            ::close(*serverSockfd);
+            *serverSockfd = -1;
+          }
+          *errorFlag = true;
+        }
+        n += m;
       }
       xdr_destroy( &xp );
 
@@ -500,7 +503,7 @@ void SALOME_SocketSender_i::initCom() throw(SALOME::SALOME_Exception)
 
   /* Association of socket with a port */
   if( ::bind(_serverSockfd, (struct sockaddr *) & serv_addr, 
-          sizeof(struct sockaddr)) < 0 ) {
+           sizeof(struct sockaddr)) < 0 ) {
     closeCom();
     es.type = SALOME::COMM;
     es.text = "error bind Socket exception";