version 1.64, 2005/05/03 13:05:05
|
version 1.71, 2005/07/01 21:29:24
|
|
|
// 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, VERITAS Software Corp. |
// (david.dillard@veritas.com) | // (david.dillard@veritas.com) |
|
// John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
| |
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; |
| |
| |
|
|
address_size = sizeof(struct sockaddr_in); | address_size = sizeof(struct sockaddr_in); |
} | } |
} | } |
|
~HTTPAcceptorRep() |
|
{ |
|
delete address; |
|
} |
struct sockaddr* address; | struct sockaddr* address; |
| |
#if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_VMS) | #if defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) || defined(PEGASUS_OS_VMS) |
|
|
| |
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(); |
|
|
if (! message) | if (! message) |
return; | return; |
| |
|
PEGASUS_ASSERT(_rep != 0); |
switch (message->getType()) | switch (message->getType()) |
{ | { |
case SOCKET_MESSAGE: | case SOCKET_MESSAGE: |
|
|
void HTTPAcceptor::_bind() | void HTTPAcceptor::_bind() |
{ | { |
| |
|
PEGASUS_ASSERT(_rep != 0); |
// Create address: | // Create address: |
| |
memset(_rep->address, 0, sizeof(*_rep->address)); | memset(_rep->address, 0, sizeof(*_rep->address)); |
|
|
if ( _portNumber == 0 ) | if ( _portNumber == 0 ) |
{ | { |
sockaddr_in buf; | sockaddr_in buf; |
int bufSize = sizeof(buf); |
PEGASUS_SOCKLEN_T bufSize = sizeof(buf); |
if ( getsockname(_rep->socket, reinterpret_cast<sockaddr *>(&buf), &bufSize) == 0 ) | if ( getsockname(_rep->socket, reinterpret_cast<sockaddr *>(&buf), &bufSize) == 0 ) |
{ | { |
_portNumber = ntohs(buf.sin_port); | _portNumber = ntohs(buf.sin_port); |
|
|
| |
// close the socket | // close the socket |
Socket::close(_rep->socket); | Socket::close(_rep->socket); |
|
// Unlink Local Domain Socket Bug# 3312 |
|
if (_localConnection) |
|
{ |
|
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
|
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
|
"HTTPAcceptor::closeConnectionSocket Unlinking local connection." ); |
|
::unlink( |
|
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
|
#else |
|
PEGASUS_ASSERT(false); |
|
#endif |
|
} |
|
|
} | } |
else | else |
{ | { |
|
|
Uint32 HTTPAcceptor::getOutstandingRequestCount() const | Uint32 HTTPAcceptor::getOutstandingRequestCount() const |
{ | { |
Uint32 count = 0; | Uint32 count = 0; |
|
if (_rep) |
|
{ |
AutoMutex autoMut(_rep->_connection_mut); | AutoMutex autoMut(_rep->_connection_mut); |
if (_rep->connections.size() > 0) | if (_rep->connections.size() > 0) |
{ | { |
HTTPConnection* connection = _rep->connections[0]; | HTTPConnection* connection = _rep->connections[0]; |
count = connection->getRequestCount(); | count = connection->getRequestCount(); |
} | } |
|
} |
return count; | return count; |
} | } |
| |
|
|
| |
void HTTPAcceptor::destroyConnections() | void HTTPAcceptor::destroyConnections() |
{ | { |
|
if (_rep) |
|
{ |
// For each connection created by this object: | // For each connection created by this object: |
| |
AutoMutex autoMut(_rep->_connection_mut); | AutoMutex autoMut(_rep->_connection_mut); |
|
|
} | } |
| |
_rep->connections.clear(); | _rep->connections.clear(); |
|
} |
} | } |
| |
void HTTPAcceptor::_acceptConnection() | void HTTPAcceptor::_acceptConnection() |