version 1.69, 2005/05/16 16:13:47
|
version 1.76, 2005/10/31 16:53:08
|
|
|
// 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, Symantec Corp. (david_dillard@symantec.com) |
// (david.dillard@veritas.com) |
|
// John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 | // John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
|
|
#endif | #endif |
Mutex _connection_mut; | Mutex _connection_mut; |
| |
Sint32 socket; |
PEGASUS_SOCKET socket; |
Array<HTTPConnection*> connections; | Array<HTTPConnection*> connections; |
}; | }; |
| |
|
|
| |
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(); |
|
|
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]; |
Sint32 socket = connection->getSocket(); |
PEGASUS_SOCKET socket = connection->getSocket(); |
| |
if (socket == closeConnectionMessage->socket) | if (socket == closeConnectionMessage->socket) |
{ | { |
|
|
if (_localConnection) | if (_localConnection) |
{ | { |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
"HTTPAcceptor::closeConnectionSocket Unlinking local connection." ); | "HTTPAcceptor::closeConnectionSocket Unlinking local connection." ); |
::unlink( | ::unlink( |
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); | reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
|
|
| |
void HTTPAcceptor::destroyConnections() | void HTTPAcceptor::destroyConnections() |
{ | { |
|
|
if (_rep) | if (_rep) |
{ | { |
// For each connection created by this object: | // For each connection created by this object: |
|
|
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]; |
Sint32 socket = connection->getSocket(); |
PEGASUS_SOCKET socket = connection->getSocket(); |
| |
// Unsolicit SocketMessages: | // Unsolicit SocketMessages: |
| |
|
|
| |
// Destroy the connection (causing it to close): | // Destroy the connection (causing it to close): |
| |
while (connection->refcount.value()) { } |
while (connection->refcount.get()) { } |
delete connection; | delete connection; |
} | } |
| |
|
|
address_size = sizeof(struct sockaddr_in); | address_size = sizeof(struct sockaddr_in); |
} | } |
| |
Sint32 socket = accept(_rep->socket, accept_address, &address_size); |
PEGASUS_SOCKET socket = accept(_rep->socket, accept_address, &address_size); |
| |
delete accept_address; | delete accept_address; |
| |
|
|
#endif | #endif |
| |
| |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::TRACE, |
PEG_LOGGER_TRACE((Logger::STANDARD_LOG, System::CIMSERVER, 0, |
"HTTPAcceptor - accept() success. Socket: $1" |
"HTTPAcceptor - accept() success. Socket: $1" ,socket)); |
,socket); |
|
| |
// Create a new conection and add it to the connection list: |
AutoPtr<MP_Socket> mp_socket(new MP_Socket( |
|
socket, _sslcontext, _sslContextObjectLock, _exportConnection)); |
| |
AutoPtr<MP_Socket> mp_socket(new MP_Socket(socket, _sslcontext, _exportConnection)); |
// Perform the SSL handshake, if applicable. Make the socket non-blocking |
|
// for this operation so we can send it back to the Monitor's select() loop |
|
// if it takes a while. |
| |
Sint32 retVal; |
mp_socket->disableBlocking(); |
|
Sint32 socketAcceptStatus = mp_socket->accept(); |
|
mp_socket->enableBlocking(); |
| |
if (_sslcontext) |
if (socketAcceptStatus < 0) |
{ |
|
// |
|
// For SSL connections, obtain read lock to SSLContext object before |
|
// calling the accept() method of MP_Socket. |
|
// |
|
ReadLock rlock(*_sslContextObjectLock); |
|
retVal = mp_socket->accept(); |
|
} |
|
else |
|
{ |
|
retVal = mp_socket->accept(); |
|
} |
|
|
|
if (retVal < 0) |
|
{ | { |
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
"HTTPAcceptor: SSL_accept() failed"); | "HTTPAcceptor: SSL_accept() failed"); |
|
|
return; | return; |
} | } |
| |
|
// Create a new connection and add it to the connection list: |
|
|
HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket, | HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket, |
this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection); | this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection); |
| |
|
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; |
| |