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

Diff for /pegasus/src/Pegasus/Common/HTTPAcceptor.cpp between version 1.99.2.4 and 1.100

version 1.99.2.4, 2007/06/20 10:47:03 version 1.100, 2007/06/08 18:00:04
Line 40 
Line 40 
 #include "TLS.h" #include "TLS.h"
 #include "HTTPAcceptor.h" #include "HTTPAcceptor.h"
 #include "HTTPConnection.h" #include "HTTPConnection.h"
 #include "HostAddress.h"  
 #include "Tracer.h" #include "Tracer.h"
 #include <Pegasus/Common/MessageLoader.h> #include <Pegasus/Common/MessageLoader.h>
  
Line 60 
Line 59 
 class HTTPAcceptorRep class HTTPAcceptorRep
 { {
 public: public:
     HTTPAcceptorRep(Uint16 connectionType)      HTTPAcceptorRep(Boolean local)
     {     {
         if (connectionType == HTTPAcceptor::LOCAL_CONNECTION)          if (local)
         {         {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
             address =             address =
Line 72 
Line 71 
             PEGASUS_ASSERT(false);             PEGASUS_ASSERT(false);
 #endif #endif
         }         }
 #ifdef PEGASUS_ENABLE_IPV6          else
         else if (connectionType == HTTPAcceptor::IPV6_CONNECTION)  
         {  
             address =  
                 reinterpret_cast<struct sockaddr*>(new struct sockaddr_in6);  
             address_size = sizeof(struct sockaddr_in6);  
         }  
 #endif  
         else if (connectionType == HTTPAcceptor::IPV4_CONNECTION)  
         {         {
             address =             address =
                 reinterpret_cast<struct sockaddr*>(new struct sockaddr_in);                 reinterpret_cast<struct sockaddr*>(new struct sockaddr_in);
             address_size = sizeof(struct sockaddr_in);             address_size = sizeof(struct sockaddr_in);
         }         }
         else  
         {  
             PEGASUS_ASSERT(false);  
     }  
     }     }
   
     ~HTTPAcceptorRep()     ~HTTPAcceptorRep()
     {     {
         delete address;         delete address;
Line 114 
Line 100 
  
 HTTPAcceptor::HTTPAcceptor(Monitor* monitor, HTTPAcceptor::HTTPAcceptor(Monitor* monitor,
                            MessageQueue* outputMessageQueue,                            MessageQueue* outputMessageQueue,
                            Uint16 connectionType,                             Boolean localConnection,
                            Uint32 portNumber,                            Uint32 portNumber,
                            SSLContext * sslcontext,                            SSLContext * sslcontext,
                            ReadWriteSem* sslContextObjectLock)                            ReadWriteSem* sslContextObjectLock)
Line 123 
Line 109 
      _outputMessageQueue(outputMessageQueue),      _outputMessageQueue(outputMessageQueue),
      _rep(0),      _rep(0),
      _entry_index(-1),      _entry_index(-1),
      _connectionType(connectionType),       _localConnection(localConnection),
      _portNumber(portNumber),      _portNumber(portNumber),
      _sslcontext(sslcontext),      _sslcontext(sslcontext),
      _sslContextObjectLock(sslContextObjectLock)      _sslContextObjectLock(sslContextObjectLock)
Line 266 
Line 252 
         throw BindFailedException(parms);         throw BindFailedException(parms);
     }     }
  
     _rep = new HTTPAcceptorRep(_connectionType);      _rep = new HTTPAcceptorRep(_localConnection);
  
     // bind address     // bind address
     _bind();     _bind();
Line 281 
Line 267 
 { {
     PEGASUS_ASSERT(_rep != 0);     PEGASUS_ASSERT(_rep != 0);
     // Create address:     // Create address:
     memset(_rep->address, 0, _rep->address_size);  
  
     if (_connectionType == LOCAL_CONNECTION)      memset(_rep->address, 0, sizeof(*_rep->address));
   
       if (_localConnection)
     {     {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
           //
           // Make sure the local domain socket can be owned by the cimserver
           // user.  Otherwise, the bind may fail with a vague "bind failed"
           // error.
           //
           if (System::exists(PEGASUS_LOCAL_DOMAIN_SOCKET_PATH))
           {
               if (!System::removeFile(PEGASUS_LOCAL_DOMAIN_SOCKET_PATH))
               {
                   throw CannotRemoveFile(PEGASUS_LOCAL_DOMAIN_SOCKET_PATH);
               }
           }
   
         reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family =         reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family =
             AF_UNIX;             AF_UNIX;
         strcpy(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path,         strcpy(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path,
             PEGASUS_LOCAL_DOMAIN_SOCKET_PATH);             PEGASUS_LOCAL_DOMAIN_SOCKET_PATH);
         ::unlink(  
             reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path);  
 #else #else
         PEGASUS_ASSERT(false);         PEGASUS_ASSERT(false);
 #endif #endif
     }     }
 #ifdef PEGASUS_ENABLE_IPV6      else
     else if (_connectionType == IPV6_CONNECTION)  
     {  
         reinterpret_cast<struct sockaddr_in6*>(_rep->address)->sin6_addr =  
             in6addr_any;  
         reinterpret_cast<struct sockaddr_in6*>(_rep->address)->sin6_family =  
             AF_INET6;  
         reinterpret_cast<struct sockaddr_in6*>(_rep->address)->sin6_port =  
             htons(_portNumber);  
     }  
 #endif  
     else if(_connectionType == IPV4_CONNECTION)  
     {     {
         reinterpret_cast<struct sockaddr_in*>(_rep->address)->sin_addr.s_addr =         reinterpret_cast<struct sockaddr_in*>(_rep->address)->sin_addr.s_addr =
             INADDR_ANY;             INADDR_ANY;
Line 316 
Line 303 
         reinterpret_cast<struct sockaddr_in*>(_rep->address)->sin_port =         reinterpret_cast<struct sockaddr_in*>(_rep->address)->sin_port =
             htons(_portNumber);             htons(_portNumber);
     }     }
     else  
     {  
         PEGASUS_ASSERT(false);  
     }  
  
     // Create socket:     // Create socket:
  
     if (_connectionType == LOCAL_CONNECTION)      if (_localConnection)
     {     {
         _rep->socket = Socket::createSocket(AF_UNIX, SOCK_STREAM, 0);         _rep->socket = Socket::createSocket(AF_UNIX, SOCK_STREAM, 0);
     }     }
 #ifdef PEGASUS_ENABLE_IPV6  
     else if (_connectionType == IPV6_CONNECTION)  
     {  
         _rep->socket = Socket::createSocket(PF_INET6, SOCK_STREAM, IPPROTO_TCP);  
     }  
 #endif  
     else if (_connectionType == IPV4_CONNECTION)  
     {  
         _rep->socket = Socket::createSocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);  
     }  
     else     else
     {     {
         PEGASUS_ASSERT(false);          _rep->socket = Socket::createSocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
     }     }
  
     if (_rep->socket < 0)     if (_rep->socket < 0)
Line 434 
Line 407 
 #if !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET) && \ #if !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET) && \
      (defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || \      (defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || \
       defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM))       defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM))
     if (_connectionType == LOCAL_CONNECTION)      if (_localConnection)
     {     {
         if (::chmod(PEGASUS_LOCAL_DOMAIN_SOCKET_PATH,         if (::chmod(PEGASUS_LOCAL_DOMAIN_SOCKET_PATH,
                 S_IRUSR | S_IWUSR | S_IXUSR |                 S_IRUSR | S_IWUSR | S_IXUSR |
Line 506 
Line 479 
         // close the socket         // close the socket
         Socket::close(_rep->socket);         Socket::close(_rep->socket);
         // Unlink Local Domain Socket Bug# 3312         // Unlink Local Domain Socket Bug# 3312
         if (_connectionType == LOCAL_CONNECTION)          if (_localConnection)
         {         {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,
Line 555 
Line 528 
         // close the socket         // close the socket
         Socket::close(_rep->socket);         Socket::close(_rep->socket);
         // Unlink Local Domain Socket Bug# 3312         // Unlink Local Domain Socket Bug# 3312
         if (_connectionType == LOCAL_CONNECTION)          if (_localConnection)
         {         {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,             PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,
Line 616 
Line 589 
         _portNumber = 0;         _portNumber = 0;
         Socket::close(_rep->socket);         Socket::close(_rep->socket);
  
         if (_connectionType == LOCAL_CONNECTION)          if (_localConnection)
         {         {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
             ::unlink(             ::unlink(
Line 673 
Line 646 
     struct sockaddr* accept_address;     struct sockaddr* accept_address;
     SocketLength address_size;     SocketLength address_size;
  
     if (_connectionType == LOCAL_CONNECTION)      if (_localConnection)
     {     {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
         accept_address =         accept_address =
Line 685 
Line 658 
     }     }
     else     else
     {     {
 #ifdef PEGASUS_ENABLE_IPV6  
         accept_address =  
            reinterpret_cast<struct sockaddr*>  
            (new struct sockaddr_storage);  
         address_size = sizeof(struct sockaddr_storage);  
 #else  
         accept_address =         accept_address =
             reinterpret_cast<struct sockaddr*>(new struct sockaddr_in);             reinterpret_cast<struct sockaddr*>(new struct sockaddr_in);
         address_size = sizeof(struct sockaddr_in);         address_size = sizeof(struct sockaddr_in);
 #endif  
     }     }
  
     SocketHandle socket;     SocketHandle socket;
Line 733 
Line 699 
  
     String ipAddress;     String ipAddress;
  
     if (_connectionType == LOCAL_CONNECTION)      if (_localConnection)
     {     {
         ipAddress = "localhost";         ipAddress = "localhost";
     }     }
     else     else
     {     {
 #ifdef PEGASUS_ENABLE_IPV6  
         char ipBuffer[PEGASUS_INET6_ADDRSTR_LEN];  
         int rc;  
         while ((rc = getnameinfo(accept_address, address_size, ipBuffer,  
             PEGASUS_INET6_ADDRSTR_LEN, 0, 0, NI_NUMERICHOST)) == EAI_AGAIN)  
             ;  
         if (rc)  
         {  
             Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,  
                 "HTTPAcceptor - getnameinfo() failure.  rc: $0", rc);  
   
             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,  
                 "HTTPAcceptor: getnameinfo() failed");  
             delete accept_address;  
             Socket::close(socket);  
             return;  
         }  
         ipAddress = ipBuffer;  
 #else  
         unsigned char* sa = reinterpret_cast<unsigned char*>(         unsigned char* sa = reinterpret_cast<unsigned char*>(
             &reinterpret_cast<struct sockaddr_in*>(             &reinterpret_cast<struct sockaddr_in*>(
                 accept_address)->sin_addr.s_addr);                 accept_address)->sin_addr.s_addr);
         char ipBuffer[32];         char ipBuffer[32];
         sprintf(ipBuffer, "%u.%u.%u.%u", sa[0], sa[1], sa[2], sa[3]);         sprintf(ipBuffer, "%u.%u.%u.%u", sa[0], sa[1], sa[2], sa[3]);
         ipAddress = ipBuffer;         ipAddress = ipBuffer;
 #endif  
     }     }
  
     delete accept_address;     delete accept_address;


Legend:
Removed from v.1.99.2.4  
changed lines
  Added in v.1.100

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2