version 1.45.2.1, 2004/01/16 16:57:31
|
version 1.50, 2004/08/12 10:47:43
|
|
|
// Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) | // Nag Boranna, Hewlett-Packard Company (nagaraja_boranna@hp.com) |
// Dave Rosckes (rosckes@us.ibm.com) | // Dave Rosckes (rosckes@us.ibm.com) |
// Denise Eckstein (denise.eckstein@hp.com) | // Denise Eckstein (denise.eckstein@hp.com) |
|
// Alagaraja Ramasubramanian (alags_raj@in.ibm.com) for Bug#1090 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
|
|
MessageQueue* outputMessageQueue, | MessageQueue* outputMessageQueue, |
Boolean localConnection, | Boolean localConnection, |
Uint32 portNumber, | Uint32 portNumber, |
SSLContext * sslcontext) |
SSLContext * sslcontext, |
|
Boolean exportConnection) |
: Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), // ATTN: Need unique names? | : Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), // ATTN: Need unique names? |
_monitor(monitor), | _monitor(monitor), |
_outputMessageQueue(outputMessageQueue), | _outputMessageQueue(outputMessageQueue), |
|
|
_entry_index(-1), | _entry_index(-1), |
_localConnection(localConnection), | _localConnection(localConnection), |
_portNumber(portNumber), | _portNumber(portNumber), |
_sslcontext(sslcontext) |
_sslcontext(sslcontext), |
|
_exportConnection(exportConnection) |
{ | { |
Socket::initializeInterface(); | Socket::initializeInterface(); |
} | } |
|
|
CloseConnectionMessage* closeConnectionMessage | CloseConnectionMessage* closeConnectionMessage |
= (CloseConnectionMessage*)message; | = (CloseConnectionMessage*)message; |
| |
_rep->_connection_mut.lock(pegasus_thread_self()); |
AutoMutex autoMut(_rep->_connection_mut); |
| |
for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++) | for (Uint32 i = 0, n = _rep->connections.size(); i < n; i++) |
{ | { |
|
|
break; | break; |
} | } |
} | } |
_rep->_connection_mut.unlock(); |
|
break; | break; |
} | } |
| |
|
|
{ | { |
Uint32 count = 0; | Uint32 count = 0; |
| |
_rep->_connection_mut.lock(pegasus_thread_self()); |
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(); |
} | } |
_rep->_connection_mut.unlock(); |
|
return count; | return count; |
} | } |
| |
|
|
| |
// For each connection created by this object: | // For each connection created by this object: |
| |
_rep->_connection_mut.lock(pegasus_thread_self()); |
AutoMutex autoMut(_rep->_connection_mut); |
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]; |
|
|
} | } |
| |
_rep->connections.clear(); | _rep->connections.clear(); |
_rep->_connection_mut.unlock(); |
|
} | } |
| |
void HTTPAcceptor::_acceptConnection() | void HTTPAcceptor::_acceptConnection() |
|
|
| |
// Create a new conection and add it to the connection list: | // Create a new conection and add it to the connection list: |
| |
MP_Socket * mp_socket = new MP_Socket(socket, _sslcontext); |
AutoPtr<MP_Socket> mp_socket(new MP_Socket(socket, _sslcontext, _exportConnection)); |
if (mp_socket->accept() < 0) | if (mp_socket->accept() < 0) |
{ | { |
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
|
|
return; | return; |
} | } |
| |
HTTPConnection* connection = new HTTPConnection( |
HTTPConnection* connection = new HTTPConnection(_monitor, mp_socket, |
_monitor, mp_socket, this, static_cast<MessageQueue *>(_outputMessageQueue)); |
this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection); |
| |
// Solicit events on this new connection's socket: | // Solicit events on this new connection's socket: |
int index; | int index; |
|
|
return; | return; |
} | } |
| |
|
mp_socket.release(); |
|
|
// Save the socket for cleanup later: | // Save the socket for cleanup later: |
connection->_entry_index = index; | connection->_entry_index = index; |
_rep->_connection_mut.lock(pegasus_thread_self()); |
AutoMutex autoMut(_rep->_connection_mut); |
_rep->connections.append(connection); | _rep->connections.append(connection); |
_rep->_connection_mut.unlock(); |
|
} | } |
| |
AsyncDQueue<pegasus_acceptor> pegasus_acceptor::acceptors(true, 0); | AsyncDQueue<pegasus_acceptor> pegasus_acceptor::acceptors(true, 0); |
|
|
else if( _sslcontext != 0 ) { | else if( _sslcontext != 0 ) { |
#ifdef PEGASUS_HAS_SSL | #ifdef PEGASUS_HAS_SSL |
ssl_socket_factory sf; | ssl_socket_factory sf; |
|
pegasus_socket temp(&sf, _sslcontext); |
#else | #else |
bsd_socket_factory sf; | bsd_socket_factory sf; |
|
pegasus_socket temp(&sf); |
#endif | #endif |
pegasus_socket temp(&sf, _sslcontext); |
|
_listener = temp; | _listener = temp; |
_listener.socket(PF_INET, SOCK_STREAM, 0); | _listener.socket(PF_INET, SOCK_STREAM, 0); |
} | } |