(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.81.8.9 and 1.81.8.12

version 1.81.8.9, 2006/07/21 18:17:51 version 1.81.8.12, 2006/10/18 04:24:42
Line 63 
Line 63 
 # include <netinet/tcp.h> # include <netinet/tcp.h>
 # include <arpa/inet.h> # include <arpa/inet.h>
 # include <sys/socket.h> # include <sys/socket.h>
   
 # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET # ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
 # include <unistd.h> # include <unistd.h>
 #  include <sys/un.h> #  include <sys/un.h>
Line 101 
Line 102 
     {     {
         if (local)         if (local)
         {         {
   
 #ifndef PEGASUS_OS_TYPE_WINDOWS #ifndef PEGASUS_OS_TYPE_WINDOWS
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
  
Line 128 
Line 130 
     Mutex _connection_mut;     Mutex _connection_mut;
  
     PEGASUS_SOCKET socket;     PEGASUS_SOCKET socket;
 #ifdef PEGASUS_OS_TYPE_WINDOWS  
   // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
     NamedPipeServer* namedPipeServer;     NamedPipeServer* namedPipeServer;
 #endif #endif
     Array<HTTPConnection*> connections;     Array<HTTPConnection*> connections;
  /*  
 #ifdef PEGASUS_OS_TYPE_WINDOWS  
       // This method creates and connects to a named pipe  
     void createNamedPipe();  
     NamedPipeServer* namedPipeServer;  
     void _acceptNamedPipeConnection(NamedPipeMessage* namedPipeMessage);  
 #endif  
 */  
   
   
 }; };
  
 //------------------------------------------------------------------------------ //------------------------------------------------------------------------------
Line 262 
Line 256 
  
          break;          break;
       }       }
  #ifdef PEGASUS_OS_TYPE_WINDOWS  
   // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
       case NAMEDPIPE_MESSAGE:       case NAMEDPIPE_MESSAGE:
       {       {
          NamedPipeMessage* namedPipeMessage = (NamedPipeMessage*)message;          NamedPipeMessage* namedPipeMessage = (NamedPipeMessage*)message;
Line 278 
Line 274 
             Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,             Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
               "HTTPAcceptor::handleEnqueue: Invalid NAMEDPIPE_MESSAGE received.");               "HTTPAcceptor::handleEnqueue: Invalid NAMEDPIPE_MESSAGE received.");
          }          }
   
          break;          break;
   
       }       }
 #endif #endif
      // may Need to close connection for Named Pipe too.....??      // may Need to close connection for Named Pipe too.....??
Line 294 
Line 288 
         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];
   // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
             if(!connection->isNamedPipeConnection())             if(!connection->isNamedPipeConnection())
             {             {
   #endif
                 PEGASUS_SOCKET socket = connection->getSocket();                 PEGASUS_SOCKET socket = connection->getSocket();
  
                 if (socket == closeConnectionMessage->socket)                 if (socket == closeConnectionMessage->socket)
Line 306 
Line 302 
                     delete connection;                     delete connection;
                     break;                     break;
                  }                  }
   // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
           }           }
           else           else
              {              {
Line 320 
Line 318 
                      break;                      break;
                  }                  }
             }             }
   #endif
          }          }
  
       break;       break;
Line 397 
Line 396 
 #endif #endif
  
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS  #if defined PEGASUS_OS_TYPE_WINDOWS
    if (!_localConnection)    if (!_localConnection)
    {    {
   #endif
        memset(_rep->address, 0, sizeof(*_rep->address));        memset(_rep->address, 0, sizeof(*_rep->address));
   #if defined PEGASUS_OS_TYPE_WINDOWS
    }    }
 #else  
    memset(_rep->address, 0, sizeof(*_rep->address));  
 #endif #endif
  
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
Line 415 
Line 414 
  
    if (_localConnection)    if (_localConnection)
    {    {
   // Added for NamedPipe implementation for windows
 #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS #ifdef PEGASUS_OS_TYPE_WINDOWS
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
        {        {
         AutoMutex automut(Monitor::_cout_mut);         AutoMutex automut(Monitor::_cout_mut);
        PEGASUS_STD(cout)             PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before calling _createNamedPipe() "
            << "in HTTPAcceptor::_bind before calling _createNamedPipe() "  
            << PEGASUS_STD(endl);            << PEGASUS_STD(endl);
        }        }
 #endif #endif
      // _rep->createNamedPipe();  
        _createNamedPipe();        _createNamedPipe();
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
        {        {
Line 435 
Line 433 
        }        }
 #endif #endif
        return;        return;
 #else  # else // Other than Windows platform
        reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family =        reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family =
            AF_UNIX;            AF_UNIX;
        strcpy(        strcpy(
Line 508 
Line 506 
    }    }
 #endif #endif
  
   
    //    //
    // Set the socket option SO_REUSEADDR to reuse the socket address so    // Set the socket option SO_REUSEADDR to reuse the socket address so
    // that we can rebind to a new socket using the same address when we    // that we can rebind to a new socket using the same address when we
Line 531 
Line 528 
       throw BindFailedException(parms);       throw BindFailedException(parms);
    }    }
  
   
    //    //
    // Bind socket to port:    // Bind socket to port:
    //    //
Line 549 
Line 545 
       throw BindFailedException(parms);       throw BindFailedException(parms);
    }    }
  
   
    //    //
    // Get the actual port value used if the caller specified a port value of 0.    // Get the actual port value used if the caller specified a port value of 0.
    //    //
Line 563 
Line 558 
       }       }
    }    }
  
   
    //    //
    //  Change permissions on Linux local domain socket to allow writes by others.    //  Change permissions on Linux local domain socket to allow writes by others.
    //    //
Line 590 
Line 584 
 #endif #endif
  
    // Set up listening on the given socket:    // Set up listening on the given socket:
   
    //int const MAX_CONNECTION_QUEUE_LENGTH = 15;    //int const MAX_CONNECTION_QUEUE_LENGTH = 15;
  
    if (listen(_rep->socket, MAX_CONNECTION_QUEUE_LENGTH) < 0)    if (listen(_rep->socket, MAX_CONNECTION_QUEUE_LENGTH) < 0)
Line 756 
Line 749 
      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];
   // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
         if(!connection->isNamedPipeConnection())         if(!connection->isNamedPipeConnection())
         {         {
   #endif
             PEGASUS_SOCKET socket = connection->getSocket();             PEGASUS_SOCKET socket = connection->getSocket();
  
            // Unsolicit SocketMessages:            // Unsolicit SocketMessages:
  
            _monitor->unsolicitSocketMessages(socket);            _monitor->unsolicitSocketMessages(socket);
  
   // Added for NamedPipe implementation for windows
            // Destroy the connection (causing it to close):            // Destroy the connection (causing it to close):
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
         }         }
         else         else
         {         {
             NamedPipe namedPipe = connection->getNamedPipe();             NamedPipe namedPipe = connection->getNamedPipe();
             _monitor->unsolicitPipeMessages(namedPipe);             _monitor->unsolicitPipeMessages(namedPipe);
   
             ::FlushFileBuffers(namedPipe.getPipe());  
             ::DisconnectNamedPipe(namedPipe.getPipe());  
             ::CloseHandle(namedPipe.getPipe());  
         }         }
   #endif
         while (connection->refcount.get()) { }         while (connection->refcount.get()) { }
         delete connection;         delete connection;
      }      }
Line 795 
Line 788 
       return;       return;
  
    // Accept the connection (populate the address):    // Accept the connection (populate the address):
   
    struct sockaddr* accept_address;    struct sockaddr* accept_address;
    PEGASUS_SOCKLEN_T address_size;    PEGASUS_SOCKLEN_T address_size;
  
Line 909 
Line 901 
    _rep->connections.append(connection);    _rep->connections.append(connection);
 } }
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS  // Added for NamedPipe implementation for windows
   #if defined PEGASUS_OS_TYPE_WINDOWS && !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET)
 void HTTPAcceptor::_createNamedPipe() void HTTPAcceptor::_createNamedPipe()
 { {
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
Line 918 
Line 911 
     PEGASUS_STD(cout) << "Entering  HTTPAcceptor::_createNamedPipe()." << PEGASUS_STD(endl);     PEGASUS_STD(cout) << "Entering  HTTPAcceptor::_createNamedPipe()." << PEGASUS_STD(endl);
     }     }
 #endif #endif
     _rep->namedPipeServer = new NamedPipeServer("\\\\.\\pipe\\MyNamedPipe");      _rep->namedPipeServer = new NamedPipeServer(PEGASUS_NAMEDPIPE_PATH);
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
     {     {
      AutoMutex automut(Monitor::_cout_mut);      AutoMutex automut(Monitor::_cout_mut);
Line 942 
Line 935 
        delete _rep;        delete _rep;
        _rep = 0;        _rep = 0;
        //l10n        //l10n
        //throw BindFailedException("Failed to solicit socket messaeges");  
        MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_SOLICIT_SOCKET_MESSAGES",        MessageLoaderParms parms("Common.HTTPAcceptor.FAILED_SOLICIT_SOCKET_MESSAGES",
                     "Failed to solicit socket messaeges");                     "Failed to solicit socket messaeges");
        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,        PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2,
Line 951 
Line 943 
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
        {        {
         AutoMutex automut(Monitor::_cout_mut); //added         AutoMutex automut(Monitor::_cout_mut); //added
        PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() _monitor->solicitSocketMessages failed" << PEGASUS_STD(endl);             PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() _monitor->solicitSocketMessages failed"
                                << PEGASUS_STD(endl);
        }        }
 #endif #endif
    }    }
Line 962 
Line 955 
    }    }
 #endif #endif
    return;    return;
   
 } }
 #endif  
   
  
 #ifdef PEGASUS_OS_TYPE_WINDOWS  
 void HTTPAcceptor::_acceptNamedPipeConnection() void HTTPAcceptor::_acceptNamedPipeConnection()
 { {
     PEGASUS_ASSERT(_rep != 0);     PEGASUS_ASSERT(_rep != 0);
  
     if (!_rep)     if (!_rep)
        return;        return;
     {  
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
       {
         AutoMutex automut(Monitor::_cout_mut);         AutoMutex automut(Monitor::_cout_mut);
         cout <<"In HTTPAcceptor::_acceptNamedPipeConnection " << endl;         cout <<"In HTTPAcceptor::_acceptNamedPipeConnection " << endl;
 #endif  
     }     }
   #endif
  
    // shouldnt we be using the private var....  
      //                 _namedPipeServer->accept()  
  
     NamedPipeServerEndPiont nPSEndPoint = _rep->namedPipeServer->accept();     NamedPipeServerEndPiont nPSEndPoint = _rep->namedPipeServer->accept();
     // Registerpe to receive Messages on Connection pipe:      // Register to receive Messages on Connection pipe:
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
     {     {
         AutoMutex automut(Monitor::_cout_mut);         AutoMutex automut(Monitor::_cout_mut);
Line 995 
Line 982 
     HTTPConnection* connection = new HTTPConnection(_monitor, nPSEndPoint,     HTTPConnection* connection = new HTTPConnection(_monitor, nPSEndPoint,
         this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection);         this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection);
  
     /*  NOT SURE WHAT TO DO HERE  ....  
     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;
 #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG #ifdef PEGASUS_LOCALDOMAINSOCKET_DEBUG
Line 1024 
Line 1001 
        Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,        Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2,
            "HTTPAcceptor::_acceptPipeConnection: Attempt to allocate entry in _entries table failed.");            "HTTPAcceptor::_acceptPipeConnection: Attempt to allocate entry in _entries table failed.");
        delete connection;        delete connection;
        //  May have to close the PIPE here...  
        //Socket::close(socket);  
        return;        return;
     }     }
  


Legend:
Removed from v.1.81.8.9  
changed lines
  Added in v.1.81.8.12

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2