(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.106 and 1.106.2.8

version 1.106, 2007/09/11 17:56:33 version 1.106.2.8, 2008/02/13 08:27:02
Line 131 
Line 131 
      _connectionType(connectionType),      _connectionType(connectionType),
      _portNumber(portNumber),      _portNumber(portNumber),
      _sslcontext(sslcontext),      _sslcontext(sslcontext),
      _sslContextObjectLock(sslContextObjectLock)       _sslContextObjectLock(sslContextObjectLock),
        _idleConnectionTimeoutSeconds(0)
 { {
    Socket::initializeInterface();    Socket::initializeInterface();
  
Line 388 
Line 389 
         MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_CREATE_SOCKET",         MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_CREATE_SOCKET",
             "Failed to create socket");             "Failed to create socket");
         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
             "HTTPAcceptor::_bind _rep->socket < 0");              "HTTPAcceptor::_bind:  createSocket() _rep->socket failed");
         throw BindFailedException(parms);         throw BindFailedException(parms);
     }     }
  
       Socket::disableBlocking(_rep->socket);
  
 // 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.
Line 440 
Line 442 
     //     //
     if (::bind(_rep->socket, _rep->address, _rep->address_size) < 0)     if (::bind(_rep->socket, _rep->address, _rep->address_size) < 0)
     {     {
           MessageLoaderParms parms(
               "Common.HTTPAcceptor.FAILED_BIND_SOCKET_DETAIL",
               "Failed to bind socket on port $0: $1.",
               _portNumber, PEGASUS_SYSTEM_NETWORK_ERRORMSG_NLS);
   
         Socket::close(_rep->socket);         Socket::close(_rep->socket);
         delete _rep;         delete _rep;
         _rep = 0;         _rep = 0;
         MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_BIND_SOCKET",  
             "Failed to bind socket");  
         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
             "HTTPAcceptor::_bind: Failed to bind socket.");             "HTTPAcceptor::_bind: Failed to bind socket.");
         throw BindFailedException(parms);         throw BindFailedException(parms);
Line 480 
Line 485 
                 S_IRGRP | S_IWGRP | S_IXGRP |                 S_IRGRP | S_IWGRP | S_IXGRP |
                 S_IROTH | S_IWOTH | S_IXOTH ) < 0 )                 S_IROTH | S_IWOTH | S_IXOTH ) < 0 )
         {         {
               MessageLoaderParms parms(
                   "Common.HTTPAcceptor.FAILED_SET_LDS_FILE_OPTION",
                   "Failed to set permission on local domain socket {0}: {1}.",
                   PEGASUS_LOCAL_DOMAIN_SOCKET_PATH,
                   PEGASUS_SYSTEM_ERRORMSG_NLS );
   
             Socket::close(_rep->socket);             Socket::close(_rep->socket);
             delete _rep;             delete _rep;
             _rep = 0;             _rep = 0;
             MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_BIND_SOCKET",  
                 "Failed to bind socket");  
             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,             PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
                 "HTTPAcceptor::_bind: Failed to set domain socket "                 "HTTPAcceptor::_bind: Failed to set domain socket "
                     "permissions.");                     "permissions.");
Line 497 
Line 506 
  
     //int const _maxConnectionQueueLength = 15;     //int const _maxConnectionQueueLength = 15;
  
     if (listen(_rep->socket, _maxConnectionQueueLength) < 0)      if (::listen(_rep->socket, _maxConnectionQueueLength) < 0)
     {     {
           MessageLoaderParms parms(
               "Common.HTTPAcceptor.FAILED_LISTEN_SOCKET",
               "Failed to listen on socket {0}: {1}.",
               (int)_rep->socket,PEGASUS_SYSTEM_NETWORK_ERRORMSG_NLS );
   
         Socket::close(_rep->socket);         Socket::close(_rep->socket);
         delete _rep;         delete _rep;
         _rep = 0;         _rep = 0;
         MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_BIND_SOCKET",  
             "Failed to bind socket");  
         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,         PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
             "HTTPAcceptor::_bind: Failed to bind socket(1).");             "HTTPAcceptor::_bind: Failed to bind socket(1).");
         throw BindFailedException(parms);         throw BindFailedException(parms);
Line 625 
Line 637 
     if (_rep)     if (_rep)
     {     {
         AutoMutex autoMut(_rep->_connection_mut);         AutoMutex autoMut(_rep->_connection_mut);
         if (_rep->connections.size() > 0)          for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++)
           {
               HTTPConnection* connection = _rep->connections[i];
               if (connection->isResponsePending())
         {         {
             HTTPConnection* connection = _rep->connections[0];                  count++;
             count = connection->getRequestCount();              }
         }         }
     }     }
     return count;     return count;
Line 648 
Line 663 
     _socketWriteTimeout = socketWriteTimeout;     _socketWriteTimeout = socketWriteTimeout;
 } }
  
   void HTTPAcceptor::setIdleConnectionTimeout(Uint32 idleConnectionTimeoutSeconds)
   {
       _idleConnectionTimeoutSeconds = idleConnectionTimeoutSeconds;
   }
   
 void HTTPAcceptor::unbind() void HTTPAcceptor::unbind()
 { {
     if (_rep)     if (_rep)
Line 736 
Line 756 
 #endif #endif
     }     }
  
     SocketHandle socket;      // It is not necessary to handle EINTR errors from this accept() call.
 #ifdef PEGASUS_OS_TYPE_WINDOWS      // An EINTR error should not occur on a non-blocking socket.  If the
     socket = accept(_rep->socket, accept_address, &address_size);      // listen socket is blocking and EINTR occurs, the new socket connection
 #else      // is not accepted here.
     while (  
         ((socket = accept(_rep->socket, accept_address, &address_size)) == -1)      // EAGAIN errors are also not handled here.  An EAGAIN error should not
         && (errno == EINTR))      // occur after select() indicates that the listen socket is available for
         ;      // reading.  If the accept() fails with an EAGAIN error code, a new
 #endif      // connection is not accepted here.
   
       SocketHandle socket = accept(_rep->socket, accept_address, &address_size);
  
     if (socket == PEGASUS_SOCKET_ERROR)     if (socket == PEGASUS_SOCKET_ERROR)
     {     {
Line 769 
Line 791 
             "HTTPAcceptor: accept() failed");             "HTTPAcceptor: accept() failed");
         return;         return;
     }     }
   #ifndef PEGASUS_OS_TYPE_WINDOWS
       // We need to ensure that the socket number is not higher than
       // what fits into FD_SETSIZE, because we else won't be able to select on it
       // and won't ever communicate correct on that socket.
       if (socket >= FD_SETSIZE)
       {
           // the remote connection is invalid, destroy client address.
           delete accept_address;
   
           Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE,
               "HTTPAcceptor out of available sockets. "
                   "Closing connection to the new client.");
   
           PEG_TRACE(
               (TRC_DISCARDED_DATA,
                Tracer::LEVEL2,
                "accept() returned too large socket number %d.",
                socket));
   
           // close the connection
           Socket::close(socket);
           return;
       }
   #endif
  
     String ipAddress;     String ipAddress;
  
Line 837 
Line 883 
     SharedPtr<MP_Socket> mp_socket(new MP_Socket(     SharedPtr<MP_Socket> mp_socket(new MP_Socket(
         socket, _sslcontext, _sslContextObjectLock, ipAddress));         socket, _sslcontext, _sslContextObjectLock, ipAddress));
  
       mp_socket->disableBlocking();
     mp_socket->setSocketWriteTimeout(_socketWriteTimeout);     mp_socket->setSocketWriteTimeout(_socketWriteTimeout);
  
     // Perform the SSL handshake, if applicable.  Make the socket non-blocking      // Perform the SSL handshake, if applicable.
     // for this operation so we can send it back to the Monitor's select() loop  
     // if it takes a while.  
  
     mp_socket->disableBlocking();  
     Sint32 socketAcceptStatus = mp_socket->accept();     Sint32 socketAcceptStatus = mp_socket->accept();
     mp_socket->enableBlocking();  
  
     if (socketAcceptStatus < 0)     if (socketAcceptStatus < 0)
     {     {
Line 860 
Line 903 
     HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket,     HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket,
         ipAddress, this, static_cast<MessageQueue *>(_outputMessageQueue));         ipAddress, this, static_cast<MessageQueue *>(_outputMessageQueue));
  
       if (_idleConnectionTimeoutSeconds)
       {
           connection->_idleConnectionTimeoutSeconds =
               _idleConnectionTimeoutSeconds;
           Time::gettimeofday(&connection->_idleStartTime);
       }
   
     if (socketAcceptStatus == 0)     if (socketAcceptStatus == 0)
     {     {
         PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,         PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL2,
             "HTTPAcceptor: SSL_accept() pending");             "HTTPAcceptor: SSL_accept() pending");
         connection->_acceptPending = true;         connection->_acceptPending = true;
           Time::gettimeofday(&connection->_acceptPendingStartTime);
     }     }
  
     // Solicit events on this new connection's socket:     // Solicit events on this new connection's socket:


Legend:
Removed from v.1.106  
changed lines
  Added in v.1.106.2.8

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2