(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.69 and 1.78

version 1.69, 2005/05/16 16:13:47 version 1.78, 2005/11/29 20:06:14
Line 39 
Line 39 
 //          Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com) //          Roger Kumpf, Hewlett-Packard Company (roger_kumpf@hp.com)
 //          Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com) //          Sean Keenan, Hewlett-Packard Company (sean.keenan@hp.com)
 //          Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2065 //          Josephine Eskaline Joyce, IBM (jojustin@in.ibm.com) for Bug#2065
 //          David Dillard, VERITAS Software Corp.  //          David Dillard, Symantec Corp. (david_dillard@symantec.com)
 //              (david.dillard@veritas.com)  
 //          John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 //          John Alex, IBM (johnalex@us.ibm.com) for Bug#3312
 // //
 //%///////////////////////////////////////////////////////////////////////////// //%/////////////////////////////////////////////////////////////////////////////
Line 50 
Line 49 
 #include <iostream> #include <iostream>
 #include "Socket.h" #include "Socket.h"
  
 #ifdef PEGASUS_PLATFORM_WIN32_IX86_MSVC  #ifdef PEGASUS_OS_TYPE_WINDOWS
 #include <windows.h> #include <windows.h>
 #else #else
 # include <cctype> # include <cctype>
Line 83 
Line 82 
 PEGASUS_NAMESPACE_BEGIN PEGASUS_NAMESPACE_BEGIN
  
  
 //  
 // Determine the correct type to use for the length passed to getsockname().  
 // The default is to use the 'socklen_t'.  
 //  
   
 #if defined(PEGASUS_OS_TYPE_WINDOWS) || defined(PEGASUS_OS_OS400)  
 #define PEGASUS_SOCKLEN_T   int  
 #endif  
   
 #if defined(PEGASUS_OS_HPUX) && !defined(_XOPEN_SOURCE_EXTENDED)  
 #define PEGASUS_SOCKLEN_T   int  
 #endif  
   
   
 #if defined(PEGASUS_OS_VMS) || defined(PEGASUS_OS_ZOS)  
 #define PEGASUS_SOCKLEN_T   unsigned  
 #endif  
   
 #ifndef PEGASUS_SOCKLEN_T  
 #define PEGASUS_SOCKLEN_T   socklen_t  
 #endif  
   
 static int MAX_CONNECTION_QUEUE_LENGTH = -1; static int MAX_CONNECTION_QUEUE_LENGTH = -1;
  
   
 //////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
 // //
 // HTTPAcceptorRep // HTTPAcceptorRep
Line 140 
Line 116 
     }     }
     struct sockaddr* address;     struct sockaddr* address;
  
 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_VMS)      PEGASUS_SOCKLEN_T address_size;
    size_t address_size;  
 #elif defined(PEGASUS_PLATFORM_AIX_RS_IBMCXX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || (defined(PEGASUS_PLATFORM_SOLARIS_SPARC_CC) && !defined(SUNOS_5_6))  
    socklen_t address_size;  
 #else  
    int address_size;  
 #endif  
       Mutex _connection_mut;       Mutex _connection_mut;
  
       Sint32 socket;      PEGASUS_SOCKET socket;
       Array<HTTPConnection*> connections;       Array<HTTPConnection*> connections;
 }; };
  
Line 217 
Line 187 
  
 HTTPAcceptor::~HTTPAcceptor() HTTPAcceptor::~HTTPAcceptor()
 { {
      destroyConnections();
    unbind();    unbind();
    // ATTN: Is this correct in a multi-HTTPAcceptor server?    // ATTN: Is this correct in a multi-HTTPAcceptor server?
    Socket::uninitializeInterface();    Socket::uninitializeInterface();
Line 261 
Line 232 
      for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++)      for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++)
      {      {
         HTTPConnection* connection = _rep->connections[i];         HTTPConnection* connection = _rep->connections[i];
         Sint32 socket = connection->getSocket();          PEGASUS_SOCKET socket = connection->getSocket();
  
         if (socket == closeConnectionMessage->socket)         if (socket == closeConnectionMessage->socket)
         {         {
Line 388 
Line 359 
  
 // set the close-on-exec bit for this file handle. // set the close-on-exec bit for this file handle.
 // any unix that forks needs this bit set. // any unix that forks needs this bit set.
 #if !defined PEGASUS_PLATFORM_WIN32_IX86_MSVC && !defined(PEGASUS_OS_VMS)  #if !defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_OS_VMS)
    int sock_flags;    int sock_flags;
  if( (sock_flags = fcntl(_rep->socket, F_GETFD, 0)) < 0)  if( (sock_flags = fcntl(_rep->socket, F_GETFD, 0)) < 0)
    {    {
Line 545 
Line 516 
       if (_localConnection)       if (_localConnection)
       {       {
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
           PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,            PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2,
                         "HTTPAcceptor::closeConnectionSocket Unlinking local connection." );                         "HTTPAcceptor::closeConnectionSocket Unlinking local connection." );
          ::unlink(          ::unlink(
              reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path);              reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path);
Line 634 
Line 605 
  
 void HTTPAcceptor::destroyConnections() void HTTPAcceptor::destroyConnections()
 { {
   
    if (_rep)    if (_rep)
    {    {
      // For each connection created by this object:      // For each connection created by this object:
Line 643 
Line 613 
      for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++)      for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++)
      {      {
         HTTPConnection* connection = _rep->connections[i];         HTTPConnection* connection = _rep->connections[i];
         Sint32 socket = connection->getSocket();          PEGASUS_SOCKET socket = connection->getSocket();
  
         // Unsolicit SocketMessages:         // Unsolicit SocketMessages:
  
Line 651 
Line 621 
  
         // Destroy the connection (causing it to close):         // Destroy the connection (causing it to close):
  
         while (connection->refcount.value()) { }          while (connection->refcount.get()) { }
         delete connection;         delete connection;
      }      }
  
Line 671 
Line 641 
    // Accept the connection (populate the address):    // Accept the connection (populate the address):
  
    struct sockaddr* accept_address;    struct sockaddr* accept_address;
 #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_VMS)     PEGASUS_SOCKLEN_T address_size;
    size_t address_size;  
 #elif defined(PEGASUS_PLATFORM_AIX_RS_IBMCXX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || (defined(PEGASUS_OS_SOLARIS) && !defined(SUNOS_5_6))  
    socklen_t address_size;  
 #else  
    int address_size;  
 #endif  
  
    if (_localConnection)    if (_localConnection)
    {    {
Line 694 
Line 658 
        address_size = sizeof(struct sockaddr_in);        address_size = sizeof(struct sockaddr_in);
    }    }
  
    Sint32 socket = accept(_rep->socket, accept_address, &address_size);     PEGASUS_SOCKET socket = accept(_rep->socket, accept_address, &address_size);
  
    delete accept_address;    delete accept_address;
  
Line 711 
Line 675 
    }    }
  
 // set the close on exec flag // set the close on exec flag
 #if !defined PEGASUS_PLATFORM_WIN32_IX86_MSVC && !defined(PEGASUS_OS_VMS)  #if !defined(PEGASUS_OS_TYPE_WINDOWS) && !defined(PEGASUS_OS_VMS)
    int sock_flags;    int sock_flags;
  if( (sock_flags = fcntl(socket, F_GETFD, 0)) < 0)  if( (sock_flags = fcntl(socket, F_GETFD, 0)) < 0)
    {    {
Line 730 
Line 694 
 #endif #endif
  
  
    Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,     PEG_LOGGER_TRACE((Logger::STANDARD_LOG, System::CIMSERVER, 0,
            "HTTPAcceptor - accept() success.  Socket: $1"         "HTTPAcceptor - accept() success.  Socket: $1" ,socket));
            ,socket);  
   
    // Create a new conection and add it to the connection list:  
  
    AutoPtr<MP_Socket> mp_socket(new MP_Socket(socket, _sslcontext, _exportConnection));     AutoPtr<MP_Socket> mp_socket(new MP_Socket(
          socket, _sslcontext, _sslContextObjectLock, _exportConnection));
  
    Sint32 retVal;     // Perform the SSL handshake, if applicable.  Make the socket non-blocking
      // for this operation so we can send it back to the Monitor's select() loop
      // if it takes a while.
  
    if (_sslcontext)     mp_socket->disableBlocking();
    {     Sint32 socketAcceptStatus = mp_socket->accept();
        //     mp_socket->enableBlocking();
        // For SSL connections, obtain read lock to SSLContext object before  
        // calling the accept() method of MP_Socket.  
        //  
        ReadLock rlock(*_sslContextObjectLock);  
        retVal = mp_socket->accept();  
    }  
    else  
    {  
        retVal = mp_socket->accept();  
    }  
  
    if (retVal < 0)     if (socketAcceptStatus < 0)
    {    {
        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                         "HTTPAcceptor: SSL_accept() failed");                         "HTTPAcceptor: SSL_accept() failed");
Line 762 
Line 716 
        return;        return;
    }    }
  
      // Create a new connection and add it to the connection list:
   
    HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket,    HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket,
        this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection);        this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection);
  
      if (socketAcceptStatus == 0)
      {
          PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2,
              "HTTPAcceptor: SSL_accept() pending");
          connection->_acceptPending = true;
      }
   
    // Solicit events on this new connection's socket:    // Solicit events on this new connection's socket:
    int index;    int index;
  


Legend:
Removed from v.1.69  
changed lines
  Added in v.1.78

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2