version 1.17, 2002/05/22 05:25:30
|
version 1.21, 2002/06/19 22:06:32
|
|
|
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001 BMC Software, Hewlett-Packard Company, IBM, |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Company, IBM, |
// The Open Group, Tivoli Systems | // The Open Group, Tivoli Systems |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
#include "TLS.h" | #include "TLS.h" |
#include "HTTPAcceptor.h" | #include "HTTPAcceptor.h" |
#include "HTTPConnection.h" | #include "HTTPConnection.h" |
|
#include "Tracer.h" |
| |
PEGASUS_USING_STD; | PEGASUS_USING_STD; |
| |
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
HTTPAcceptor::HTTPAcceptor(Monitor* monitor, MessageQueueService* outputMessageQueue) |
HTTPAcceptor::HTTPAcceptor(Monitor* monitor, MessageQueue* outputMessageQueue) |
: Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), | : Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), |
_monitor(monitor), _outputMessageQueue(outputMessageQueue), | _monitor(monitor), _outputMessageQueue(outputMessageQueue), |
_rep(0), _sslcontext(NULL) |
_rep(0), _sslcontext(NULL), _entry_index(-1) |
{ | { |
| |
Socket::initializeInterface(); | Socket::initializeInterface(); |
} | } |
| |
HTTPAcceptor::HTTPAcceptor(Monitor* monitor, MessageQueueService* outputMessageQueue, |
HTTPAcceptor::HTTPAcceptor(Monitor* monitor, MessageQueue* outputMessageQueue, |
SSLContext * sslcontext) | SSLContext * sslcontext) |
: Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), | : Base(PEGASUS_QUEUENAME_HTTPACCEPTOR), |
_monitor(monitor), _outputMessageQueue(outputMessageQueue), | _monitor(monitor), _outputMessageQueue(outputMessageQueue), |
_rep(0), | _rep(0), |
_sslcontext(sslcontext) |
_sslcontext(sslcontext), |
|
_entry_index(-1) |
{ | { |
Socket::initializeInterface(); | Socket::initializeInterface(); |
} | } |
|
|
{ | { |
_monitor->unsolicitSocketMessages(socket); | _monitor->unsolicitSocketMessages(socket); |
_rep->connections.remove(i); | _rep->connections.remove(i); |
while (connection->refcount.value()) { } |
|
delete connection; | delete connection; |
break; | break; |
} | } |
|
|
| |
// Register to receive SocketMessages on this socket: | // Register to receive SocketMessages on this socket: |
| |
if (!_monitor->solicitSocketMessages( |
if ( -1 == ( _entry_index = _monitor->solicitSocketMessages( |
_rep->socket, | _rep->socket, |
SocketMessage::READ | SocketMessage::EXCEPTION, | SocketMessage::READ | SocketMessage::EXCEPTION, |
getQueueId(), | getQueueId(), |
Monitor::ACCEPTOR)) |
Monitor::ACCEPTOR))) |
{ | { |
Socket::close(_rep->socket); | Socket::close(_rep->socket); |
delete _rep; | delete _rep; |
|
|
| |
if (socket < 0) | if (socket < 0) |
{ | { |
if (getenv("PEGASUS_TRACE")) |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
cerr <<"HTTPAcceptor: accept() failed" << endl; |
"HTTPAcceptor: accept() failed"); |
|
|
return; | return; |
} | } |
| |
// 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); | MP_Socket * mp_socket = new MP_Socket(socket, _sslcontext); |
if (mp_socket->accept() < 0) { |
if (mp_socket->accept() < 0) |
if (getenv("PEGASUS_TRACE")) |
{ |
cerr <<"HTTPAcceptor: SSL_accept() failed" << endl; |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
|
"HTTPAcceptor: SSL_accept() failed"); |
return; | return; |
} | } |
| |
|
|
_monitor, mp_socket, this, static_cast<MessageQueue *>(_outputMessageQueue)); | _monitor, mp_socket, this, static_cast<MessageQueue *>(_outputMessageQueue)); |
| |
// Solicit events on this new connection's socket: | // Solicit events on this new connection's socket: |
|
int index; |
| |
if (!_monitor->solicitSocketMessages( |
if (! (index = _monitor->solicitSocketMessages( |
socket, | socket, |
SocketMessage::READ | SocketMessage::EXCEPTION, | SocketMessage::READ | SocketMessage::EXCEPTION, |
connection->getQueueId(), Monitor::CONNECTION)) |
connection->getQueueId(), Monitor::CONNECTION)) ) |
{ | { |
delete connection; | delete connection; |
Socket::close(socket); | Socket::close(socket); |
} | } |
| |
// Save the socket for cleanup later: | // Save the socket for cleanup later: |
|
connection->_entry_index = index; |
| |
_rep->connections.append(connection); | _rep->connections.append(connection); |
} | } |