version 1.80, 2006/01/30 16:17:04
|
version 1.80.2.3, 2008/01/02 21:07:59
|
|
|
// John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 | // John Alex, IBM (johnalex@us.ibm.com) for Bug#3312 |
// | // |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
|
//NOCHKSRC |
| |
#include "Config.h" | #include "Config.h" |
#include "Constants.h" | #include "Constants.h" |
|
|
_portNumber(portNumber), | _portNumber(portNumber), |
_sslcontext(sslcontext), | _sslcontext(sslcontext), |
_exportConnection(exportConnection), | _exportConnection(exportConnection), |
_sslContextObjectLock(sslContextObjectLock) |
_sslContextObjectLock(sslContextObjectLock), |
|
_idleConnectionTimeoutSeconds(0) |
{ | { |
Socket::initializeInterface(); | Socket::initializeInterface(); |
| |
|
|
throw BindFailedException(parms); | throw BindFailedException(parms); |
} | } |
| |
|
Socket::disableBlocking(_rep->socket); |
| |
// set the close-on-exec bit for this file handle. | // set the close-on-exec bit for this file handle. |
// any unix that forks needs this bit set. | // any unix that forks needs this bit set. |
|
|
return _portNumber; | return _portNumber; |
} | } |
| |
|
void HTTPAcceptor::setSocketWriteTimeout(Uint32 socketWriteTimeout) |
|
{ |
|
_socketWriteTimeout = socketWriteTimeout; |
|
} |
|
|
|
void HTTPAcceptor::setIdleConnectionTimeout(Uint32 idleConnectionTimeoutSeconds) |
|
{ |
|
_idleConnectionTimeoutSeconds = idleConnectionTimeoutSeconds; |
|
} |
|
|
void HTTPAcceptor::unbind() | void HTTPAcceptor::unbind() |
{ | { |
if (_rep) | if (_rep) |
|
|
address_size = sizeof(struct sockaddr_in); | address_size = sizeof(struct sockaddr_in); |
} | } |
| |
|
// It is not necessary to handle EINTR errors from this accept() call. |
|
// An EINTR error should not occur on a non-blocking socket. If the |
|
// listen socket is blocking and EINTR occurs, the new socket connection |
|
// is not accepted here. |
|
|
|
// EAGAIN errors are also not handled here. An EAGAIN error should not |
|
// occur after select() indicates that the listen socket is available for |
|
// reading. If the accept() fails with an EAGAIN error code, a new |
|
// connection is not accepted here. |
|
|
PEGASUS_SOCKET socket = accept(_rep->socket, accept_address, &address_size); | PEGASUS_SOCKET socket = accept(_rep->socket, accept_address, &address_size); |
| |
delete accept_address; | delete accept_address; |
|
|
AutoPtr<MP_Socket> mp_socket(new MP_Socket( | AutoPtr<MP_Socket> mp_socket(new MP_Socket( |
socket, _sslcontext, _sslContextObjectLock, _exportConnection)); | socket, _sslcontext, _sslContextObjectLock, _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. |
|
|
|
mp_socket->disableBlocking(); | mp_socket->disableBlocking(); |
|
mp_socket->setSocketWriteTimeout(_socketWriteTimeout); |
|
|
|
// Perform the SSL handshake, if applicable. |
|
|
Sint32 socketAcceptStatus = mp_socket->accept(); | Sint32 socketAcceptStatus = mp_socket->accept(); |
mp_socket->enableBlocking(); |
|
| |
if (socketAcceptStatus < 0) | if (socketAcceptStatus < 0) |
{ | { |
|
|
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 (_idleConnectionTimeoutSeconds) |
|
{ |
|
connection->_idleConnectionTimeoutSeconds = |
|
_idleConnectionTimeoutSeconds; |
|
connection->_idleStartTime = TimeValue::getCurrentTime(); |
|
} |
|
|
if (socketAcceptStatus == 0) | if (socketAcceptStatus == 0) |
{ | { |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
"HTTPAcceptor: SSL_accept() pending"); | "HTTPAcceptor: SSL_accept() pending"); |
connection->_acceptPending = true; | connection->_acceptPending = true; |
|
connection->_acceptPendingStartTime = TimeValue::getCurrentTime(); |
} | } |
| |
// Solicit events on this new connection's socket: | // Solicit events on this new connection's socket: |