version 1.62, 2005/03/21 09:53:43
|
version 1.64, 2005/05/03 13:05:05
|
|
|
// 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@veritas.com) |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
# include <netinet/in.h> | # include <netinet/in.h> |
# include <arpa/inet.h> | # include <arpa/inet.h> |
# include <sys/socket.h> | # include <sys/socket.h> |
# ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
# ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
# include <unistd.h> | # include <unistd.h> |
# include <sys/un.h> | # include <sys/un.h> |
# endif | # endif |
|
|
{ | { |
if (local) | if (local) |
{ | { |
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); | address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); |
address_size = sizeof(struct sockaddr_un); | address_size = sizeof(struct sockaddr_un); |
#else | #else |
|
|
| |
/** | /** |
_bind - creates a new server socket and bind socket to the port address. | _bind - creates a new server socket and bind socket to the port address. |
If PEGASUS_LOCAL_DOMAIN_SOCKET is defined, the port number is ignored and |
If PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET is not defined, the port number is ignored and |
a domain socket is bound. | a domain socket is bound. |
*/ | */ |
void HTTPAcceptor::_bind() | void HTTPAcceptor::_bind() |
|
|
| |
if (_localConnection) | if (_localConnection) |
{ | { |
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
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, |
|
|
throw BindFailedException(parms); | throw BindFailedException(parms); |
} | } |
| |
// Bind socket to port: |
|
| |
|
// |
|
// Bind socket to port: |
|
// |
if (::bind(_rep->socket, _rep->address, _rep->address_size) < 0) | if (::bind(_rep->socket, _rep->address, _rep->address_size) < 0) |
{ | { |
Socket::close(_rep->socket); | Socket::close(_rep->socket); |
|
|
throw BindFailedException(parms); | throw BindFailedException(parms); |
} | } |
| |
|
|
|
// |
|
// Get the actual port value used if the caller specified a port value of 0. |
|
// |
|
if ( _portNumber == 0 ) |
|
{ |
|
sockaddr_in buf; |
|
int bufSize = sizeof(buf); |
|
if ( getsockname(_rep->socket, reinterpret_cast<sockaddr *>(&buf), &bufSize) == 0 ) |
|
{ |
|
_portNumber = ntohs(buf.sin_port); |
|
} |
|
} |
|
|
|
|
// | // |
// Change permissions on Linux local domain socket to allow writes by others. | // Change permissions on Linux local domain socket to allow writes by others. |
// | // |
#if defined(PEGASUS_LOCAL_DOMAIN_SOCKET) && defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
#if !defined(PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET) && defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) |
if (_localConnection) | if (_localConnection) |
{ | { |
if (::chmod( PEGASUS_LOCAL_DOMAIN_SOCKET_PATH, | if (::chmod( PEGASUS_LOCAL_DOMAIN_SOCKET_PATH, |
|
|
/** | /** |
getOutstandingRequestCount - returns the number of outstanding requests. | getOutstandingRequestCount - returns the number of outstanding requests. |
*/ | */ |
Uint32 HTTPAcceptor::getOutstandingRequestCount() |
Uint32 HTTPAcceptor::getOutstandingRequestCount() const |
{ | { |
Uint32 count = 0; | Uint32 count = 0; |
| |
|
|
return count; | return count; |
} | } |
| |
|
|
|
/** |
|
getPortNumber - returns the port number used for the connection |
|
*/ |
|
Uint32 HTTPAcceptor::getPortNumber() const |
|
{ |
|
return _portNumber; |
|
} |
|
|
void HTTPAcceptor::unbind() | void HTTPAcceptor::unbind() |
{ | { |
if (_rep) | if (_rep) |
{ | { |
|
_portNumber = 0; |
Socket::close(_rep->socket); | Socket::close(_rep->socket); |
| |
if (_localConnection) | if (_localConnection) |
{ | { |
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
::unlink( | ::unlink( |
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); | reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
#else | #else |
|
|
| |
if (_localConnection) | if (_localConnection) |
{ | { |
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
accept_address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); | accept_address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); |
address_size = sizeof(struct sockaddr_un); | address_size = sizeof(struct sockaddr_un); |
#else | #else |
|
|
connection->_entry_index = index; | connection->_entry_index = index; |
AutoMutex autoMut(_rep->_connection_mut); | AutoMutex autoMut(_rep->_connection_mut); |
_rep->connections.append(connection); | _rep->connections.append(connection); |
|
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |