(file) Return to Socket.cpp CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Pegasus / Common

Diff for /pegasus/src/Pegasus/Common/Socket.cpp between version 1.27.4.1 and 1.37

version 1.27.4.1, 2008/01/02 21:00:39 version 1.37, 2008/12/02 09:00:52
Line 1 
Line 1 
 //%2006////////////////////////////////////////////////////////////////////////  //%LICENSE////////////////////////////////////////////////////////////////
 // //
 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development  // Licensed to The Open Group (TOG) under one or more contributor license
 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.  // agreements.  Refer to the OpenPegasusNOTICE.txt file distributed with
 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;  // this work for additional information regarding copyright ownership.
 // IBM Corp.; EMC Corporation, The Open Group.  // Each contributor licenses this file to you under the OpenPegasus Open
 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;  // Source License; you may not use this file except in compliance with the
 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.  // License.
 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; VERITAS Software Corporation; The Open Group.  
 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;  
 // EMC Corporation; Symantec Corporation; The Open Group.  
 // //
 // Permission is hereby granted, free of charge, to any person obtaining a copy  // Permission is hereby granted, free of charge, to any person obtaining a
 // of this software and associated documentation files (the "Software"), to  // copy of this software and associated documentation files (the "Software"),
 // deal in the Software without restriction, including without limitation the  // to deal in the Software without restriction, including without limitation
 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or  // the rights to use, copy, modify, merge, publish, distribute, sublicense,
 // sell copies of the Software, and to permit persons to whom the Software is  // and/or sell copies of the Software, and to permit persons to whom the
 // furnished to do so, subject to the following conditions:  // Software is furnished to do so, subject to the following conditions:
 // //
 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN  // The above copyright notice and this permission notice shall be included
 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED  // in all copies or substantial portions of the Software.
 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT  
 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR  
 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT  
 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN  
 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION  
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  
 // //
 //==============================================================================  // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
   // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
   // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
   // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
   // CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
   // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
   //
   //////////////////////////////////////////////////////////////////////////
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
  
Line 39 
Line 37 
 #include <Pegasus/Common/Logger.h> #include <Pegasus/Common/Logger.h>
 #include <Pegasus/Common/System.h> #include <Pegasus/Common/System.h>
 #include <Pegasus/Common/Tracer.h> #include <Pegasus/Common/Tracer.h>
   #include <Pegasus/Common/Threads.h>
  
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
Line 51 
Line 50 
     Uint32 timeoutMilliseconds)     Uint32 timeoutMilliseconds)
 { {
     int connectResult;     int connectResult;
     PEGASUS_RETRY_SYSTEM_CALL(  #ifdef PEGASUS_OS_TYPE_WINDOWS
         ::connect(socket, address, addressLength), connectResult);      connectResult = ::connect(socket, address, addressLength);
   #else
       Boolean connectionAlreadyRefused = false;
       Uint32 maxConnectAttempts = 100;
       // Retry the connect() until it succeeds or it fails with an error other
       // than EINTR, EAGAIN (for Linux), or the first ECONNREFUSED (for HP-UX).
       while (((connectResult = ::connect(socket, address, addressLength)) == -1)
              && (maxConnectAttempts-- > 0)
              && ((errno == EINTR) || (errno == EAGAIN) ||
                  ((errno == ECONNREFUSED) && !connectionAlreadyRefused)))
       {
           if (errno == ECONNREFUSED)
           {
               connectionAlreadyRefused = true;
           }
           Threads::sleep(1);
       }
   #endif
  
     if (connectResult == 0)     if (connectResult == 0)
     {     {
Line 73 
Line 89 
             { timeoutMilliseconds/1000, timeoutMilliseconds%1000*1000 };             { timeoutMilliseconds/1000, timeoutMilliseconds%1000*1000 };
         int selectResult = -1;         int selectResult = -1;
  
   #ifdef PEGASUS_OS_TYPE_WINDOWS
           PEGASUS_RETRY_SYSTEM_CALL(
               select(FD_SETSIZE, NULL, &fdwrite, &fdwrite, &timeoutValue),
               selectResult);
   #else
         PEGASUS_RETRY_SYSTEM_CALL(         PEGASUS_RETRY_SYSTEM_CALL(
             select(FD_SETSIZE, NULL, &fdwrite, NULL, &timeoutValue),             select(FD_SETSIZE, NULL, &fdwrite, NULL, &timeoutValue),
             selectResult);             selectResult);
   #endif
         if (selectResult == 0)         if (selectResult == 0)
         {         {
             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,              PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL1,
                 "select() timed out waiting for the socket connection to be "                 "select() timed out waiting for the socket connection to be "
                     "established.");                     "established.");
             return false;             return false;
Line 96 
Line 118 
             }             }
             else             else
             {             {
                 PEG_TRACE((TRC_HTTP, Tracer::LEVEL2,                  PEG_TRACE((TRC_HTTP, Tracer::LEVEL1,
                     "Did not connect, getsockopt() returned optval = %d",                     "Did not connect, getsockopt() returned optval = %d",
                     optval));                     optval));
                 return false;                 return false;
Line 104 
Line 126 
         }         }
         else         else
         {         {
             PEG_TRACE((TRC_HTTP, Tracer::LEVEL2,              PEG_TRACE((TRC_HTTP, Tracer::LEVEL1,
                 "select() returned error code %d",                 "select() returned error code %d",
                 getSocketError()));                 getSocketError()));
             return false;             return false;
         }         }
     }     }
  
     PEG_TRACE((TRC_HTTP, Tracer::LEVEL2,      PEG_TRACE((TRC_HTTP, Tracer::LEVEL1,
         "connect() returned error code %d",         "connect() returned error code %d",
         getSocketError()));         getSocketError()));
     return false;     return false;
Line 205 
Line 227 
     }     }
 } }
  
 void Socket::close(SocketHandle socket)  void Socket::close(SocketHandle& socket)
 { {
     if (socket != -1)      if (socket != PEGASUS_INVALID_SOCKET)
     {     {
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
         if (!closesocket(socket))         if (!closesocket(socket))
             socket = -1;          {
               socket = PEGASUS_INVALID_SOCKET;
           }
 #else #else
         int status;         int status;
         PEGASUS_RETRY_SYSTEM_CALL(::close(socket), status);         PEGASUS_RETRY_SYSTEM_CALL(::close(socket), status);
  
         if (status == 0)         if (status == 0)
             socket = -1;          {
               socket = PEGASUS_INVALID_SOCKET;
           }
 #endif #endif
     }     }
 } }
Line 227 
Line 253 
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
     unsigned long flag = 1;    // Use "flag = 0" to enable blocking     unsigned long flag = 1;    // Use "flag = 0" to enable blocking
     ioctlsocket(socket, FIONBIO, &flag);     ioctlsocket(socket, FIONBIO, &flag);
   #elif PEGASUS_OS_VMS
       int flag=1;                // Use "flag = 0" to enable blocking
       ioctl(socket, FIONBIO, &flag);
 #else #else
     int flags = fcntl(socket, F_GETFL, 0);     int flags = fcntl(socket, F_GETFL, 0);
     flags |= O_NONBLOCK;    // Use "flags &= ~O_NONBLOCK" to enable blocking     flags |= O_NONBLOCK;    // Use "flags &= ~O_NONBLOCK" to enable blocking
Line 241 
Line 270 
     {     {
         WSADATA tmp;         WSADATA tmp;
  
         if (WSAStartup(0x202, &tmp) == SOCKET_ERROR)          int err = WSAStartup(0x202, &tmp);
             WSACleanup();          if (err != 0)
           {
               throw Exception(MessageLoaderParms(
                   "Common.Socket.WSASTARTUP_FAILED.WINDOWS",
                   "WSAStartup failed with error $0.",
                   err));
           }
     }     }
  
     _socketInterfaceRefCount++;     _socketInterfaceRefCount++;
Line 331 
Line 366 
         {         {
             Logger::put_l(             Logger::put_l(
                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,                 Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION,
                   MessageLoaderParms(
                 "Common.Socket.WAIT_FOR_TCPIP",                 "Common.Socket.WAIT_FOR_TCPIP",
                 "TCP/IP temporary unavailable.");                      "TCP/IP temporary unavailable."));
             sendTcpipMsg = false;             sendTcpipMsg = false;
         }         }
  


Legend:
Removed from v.1.27.4.1  
changed lines
  Added in v.1.37

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2