version 1.105.2.2, 2008/09/25 21:46:15
|
version 1.106, 2007/09/11 17:56:33
|
|
|
# include <Pegasus/Common/PaseCcsid.h> | # include <Pegasus/Common/PaseCcsid.h> |
#endif | #endif |
| |
#if defined(PEGASUS_OS_VXWORKS) |
|
# define HTTP_ACCEPTOR_MAX_CONNECTIONS 2 |
|
#else |
|
# define HTTP_ACCEPTOR_MAX_CONNECTIONS Uint32(0xFFFFFFFF) |
|
//# define HTTP_ACCEPTOR_MAX_CONNECTIONS 2 |
|
#endif |
|
|
|
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
PEGASUS_NAMESPACE_BEGIN | PEGASUS_NAMESPACE_BEGIN |
|
|
| |
void HTTPAcceptor::handleEnqueue(Message *message) | void HTTPAcceptor::handleEnqueue(Message *message) |
{ | { |
Uint32 numConnections = HTTP_ACCEPTOR_MAX_CONNECTIONS; |
|
|
|
if (!message) | if (!message) |
return; | return; |
| |
|
|
{ | { |
_monitor->unsolicitSocketMessages(socket); | _monitor->unsolicitSocketMessages(socket); |
_rep->connections.remove(i); | _rep->connections.remove(i); |
numConnections = _rep->connections.size(); |
|
delete connection; | delete connection; |
break; | break; |
} | } |
|
|
} | } |
| |
delete message; | delete message; |
|
|
// Re-enable connections if connection count falls below maximum. |
|
|
|
if (_entry_index == -1 && numConnections < HTTP_ACCEPTOR_MAX_CONNECTIONS) |
|
{ |
|
startAcceptingConnections(); |
|
} |
|
} | } |
| |
|
|
void HTTPAcceptor::handleEnqueue() | void HTTPAcceptor::handleEnqueue() |
{ | { |
Message* message = dequeue(); | Message* message = dequeue(); |
|
|
| |
// Accept the connection (populate the address): | // Accept the connection (populate the address): |
| |
struct sockaddr* accept_address = 0; |
struct sockaddr* accept_address; |
SocketLength address_size; | SocketLength address_size; |
| |
if (_connectionType == LOCAL_CONNECTION) | if (_connectionType == LOCAL_CONNECTION) |
|
|
#ifdef PEGASUS_ENABLE_IPV6 | #ifdef PEGASUS_ENABLE_IPV6 |
char ipBuffer[PEGASUS_INET6_ADDRSTR_LEN]; | char ipBuffer[PEGASUS_INET6_ADDRSTR_LEN]; |
int rc; | int rc; |
while ((rc = getnameinfo(accept_address, address_size, ipBuffer, |
if ((rc = System::getNameInfo(accept_address, |
PEGASUS_INET6_ADDRSTR_LEN, 0, 0, NI_NUMERICHOST)) == EAI_AGAIN) |
address_size, |
; |
ipBuffer, |
if (rc) |
PEGASUS_INET6_ADDRSTR_LEN, |
|
0, |
|
0, |
|
NI_NUMERICHOST))) |
{ | { |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
"HTTPAcceptor - getnameinfo() failure. rc: $0", rc); | "HTTPAcceptor - getnameinfo() failure. rc: $0", rc); |
|
|
| |
// Save the socket for cleanup later: | // Save the socket for cleanup later: |
connection->_entry_index = index; | connection->_entry_index = index; |
Uint32 numConnections; |
|
{ |
|
AutoMutex autoMut(_rep->_connection_mut); | AutoMutex autoMut(_rep->_connection_mut); |
_rep->connections.append(connection); | _rep->connections.append(connection); |
numConnections = _rep->connections.size(); |
|
} |
|
|
|
// Start accepting new connections when we exceeded maximum connections. |
|
|
|
if (numConnections >= HTTP_ACCEPTOR_MAX_CONNECTIONS) |
|
{ |
|
stopAcceptingConnections(); |
|
} |
|
} |
|
|
|
int HTTPAcceptor::startAcceptingConnections() |
|
{ |
|
if ((_entry_index = _monitor->solicitSocketMessages( |
|
_rep->socket, |
|
SocketMessage::READ | SocketMessage::EXCEPTION, |
|
getQueueId(), |
|
Monitor::ACCEPTOR)) == -1) |
|
{ |
|
return false; |
|
} |
|
|
|
return true; |
|
} |
|
|
|
void HTTPAcceptor::stopAcceptingConnections() |
|
{ |
|
_monitor->unsolicitSocketMessages(_rep->socket); |
|
_entry_index = -1; |
|
} | } |
| |
PEGASUS_NAMESPACE_END | PEGASUS_NAMESPACE_END |