version 1.81.8.4, 2006/06/10 21:54:05
|
version 1.81.8.6, 2006/06/15 10:08:17
|
|
|
{ | { |
NamedPipeMessage* namedPipeMessage = (NamedPipeMessage*)message; | NamedPipeMessage* namedPipeMessage = (NamedPipeMessage*)message; |
| |
// If this is a connection request: |
|
|
|
if (((namedPipeMessage->namedPipe.getPipe()) == ( _rep->namedPipeServer->getPipe())) && | if (((namedPipeMessage->namedPipe.getPipe()) == ( _rep->namedPipeServer->getPipe())) && |
(namedPipeMessage->events & NamedPipeMessage::READ)) | (namedPipeMessage->events & NamedPipeMessage::READ)) |
{ | { |
|
|
*/ | */ |
void HTTPAcceptor::_bind() | void HTTPAcceptor::_bind() |
{ | { |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind at the begining" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind at the begining" << PEGASUS_STD(endl); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before ASSERT" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before ASSERT" << PEGASUS_STD(endl); |
|
} |
PEGASUS_ASSERT(_rep != 0); | PEGASUS_ASSERT(_rep != 0); |
// Create address: | // Create address: |
| |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before memset" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before memset" << PEGASUS_STD(endl); |
|
} |
| |
| |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
|
|
memset(_rep->address, 0, sizeof(*_rep->address)); | memset(_rep->address, 0, sizeof(*_rep->address)); |
#endif | #endif |
| |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind After memset" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind After memset" << PEGASUS_STD(endl); |
|
} |
| |
if (_localConnection) | if (_localConnection) |
{ | { |
|
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
| |
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind before calling _createNamedPipe() " << PEGASUS_STD(endl); |
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
|
PEGASUS_STD(cout) |
|
<< "in HTTPAcceptor::_bind before calling _createNamedPipe() " |
|
<< PEGASUS_STD(endl); |
|
} |
// _rep->createNamedPipe(); | // _rep->createNamedPipe(); |
_createNamedPipe(); | _createNamedPipe(); |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind after calling _createNamedPipe() " << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind after calling _createNamedPipe() " << PEGASUS_STD(endl); |
// Not sure if we need to continue to bind non local domain sockets in windows..... |
} |
return; | return; |
// #else |
#else |
#endif |
|
|
|
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
|
|
|
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family = | reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_family = |
AF_UNIX; | AF_UNIX; |
strcpy(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path, |
strcpy( |
|
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path, |
PEGASUS_LOCAL_DOMAIN_SOCKET_PATH); | PEGASUS_LOCAL_DOMAIN_SOCKET_PATH); |
|
|
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM | #ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
AtoE(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); | AtoE(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
#endif | #endif |
::unlink(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); | ::unlink(reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
|
#endif |
|
|
#else | #else |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
#endif | #endif |
|
|
} | } |
| |
// Create socket: | // Create socket: |
|
|
if (_localConnection) | if (_localConnection) |
{ | { |
_rep->socket = socket(AF_UNIX, SOCK_STREAM, 0); | _rep->socket = socket(AF_UNIX, SOCK_STREAM, 0); |
|
|
"HTTPAcceptor::_bind: Failed to solicit socket messages(2)."); | "HTTPAcceptor::_bind: Failed to solicit socket messages(2)."); |
throw BindFailedException(parms); | throw BindFailedException(parms); |
} | } |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_bind at the End" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_bind at the End" << PEGASUS_STD(endl); |
|
} |
| |
} | } |
| |
|
|
// Unlink Local Domain Socket Bug# 3312 | // Unlink Local Domain Socket Bug# 3312 |
if (_localConnection) | if (_localConnection) |
{ | { |
|
#ifndef PEGASUS_OS_TYPE_WINDOWS |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_HTTP, Tracer::LEVEL2, |
"HTTPAcceptor::closeConnectionSocket Unlinking local connection." ); | "HTTPAcceptor::closeConnectionSocket Unlinking local connection." ); |
|
|
#else | #else |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
#endif | #endif |
|
#endif |
} | } |
| |
} | } |
|
|
if (_localConnection) | if (_localConnection) |
{ | { |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
|
#ifndef PEGASUS_OS_TYPE_WINDOWS |
|
|
::unlink( | ::unlink( |
reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); | reinterpret_cast<struct sockaddr_un*>(_rep->address)->sun_path); |
|
#endif |
#else | #else |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
#endif | #endif |
|
|
| |
if (_localConnection) | if (_localConnection) |
{ | { |
|
#ifndef PEGASUS_OS_TYPE_WINDOWS |
#ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_DISABLE_LOCAL_DOMAIN_SOCKET |
accept_address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); | accept_address = reinterpret_cast<struct sockaddr*>(new struct sockaddr_un); |
address_size = sizeof(struct sockaddr_un); | address_size = sizeof(struct sockaddr_un); |
#else | #else |
PEGASUS_ASSERT(false); | PEGASUS_ASSERT(false); |
#endif | #endif |
|
#endif |
} | } |
else | else |
{ | { |
|
|
#ifdef PEGASUS_OS_TYPE_WINDOWS | #ifdef PEGASUS_OS_TYPE_WINDOWS |
void HTTPAcceptor::_createNamedPipe() | void HTTPAcceptor::_createNamedPipe() |
{ | { |
PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() at the begining" << PEGASUS_STD(endl); |
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
|
PEGASUS_STD(cout) << "Entering HTTPAcceptor::_createNamedPipe()." << PEGASUS_STD(endl); |
|
} |
| |
_rep->namedPipeServer = new NamedPipeServer("\\\\.\\pipe\\MyNamedPipe"); | _rep->namedPipeServer = new NamedPipeServer("\\\\.\\pipe\\MyNamedPipe"); |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() after calling the pipe server constructor" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() after calling the pipe server constructor" << PEGASUS_STD(endl); |
|
} |
| |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
|
cout << "Named pipe...in _createNamedPipe..." << _rep->namedPipeServer->getPipe() << endl; |
|
} |
// Register to receive Messages on Connection pipe: | // Register to receive Messages on Connection pipe: |
| |
if ( -1 == ( _entry_index = _monitor->solicitPipeMessages( | if ( -1 == ( _entry_index = _monitor->solicitPipeMessages( |
|
|
PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, | PEG_TRACE_STRING(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
"HTTPAcceptor::_bind: Failed to solicit socket messages(2)."); | "HTTPAcceptor::_bind: Failed to solicit socket messages(2)."); |
throw BindFailedException(parms); | throw BindFailedException(parms); |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); //added |
PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() _monitor->solicitSocketMessages failed" << PEGASUS_STD(endl); | PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() _monitor->solicitSocketMessages failed" << PEGASUS_STD(endl); |
|
} |
| |
} | } |
| |
PEGASUS_STD(cout) << "in HTTPAcceptor::_createNamedPipe() at the end" << PEGASUS_STD(endl); |
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
|
PEGASUS_STD(cout) << "Leaving HTTPAcceptor::_createNamedPipe()." << PEGASUS_STD(endl); |
|
} |
return; | return; |
| |
} | } |
|
|
| |
if (!_rep) | if (!_rep) |
return; | return; |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
cout <<"In HTTPAcceptor::_acceptNamedPipeConnection " << endl; | cout <<"In HTTPAcceptor::_acceptNamedPipeConnection " << endl; |
|
} |
| |
// shouldnt we be using the private var.... | // shouldnt we be using the private var.... |
// _namedPipeServer->accept() | // _namedPipeServer->accept() |
| |
NamedPipeServerEndPiont nPSEndPoint = _rep->namedPipeServer->accept(); | NamedPipeServerEndPiont nPSEndPoint = _rep->namedPipeServer->accept(); |
// Registerpe to receive Messages on Connection pipe: | // Registerpe to receive Messages on Connection pipe: |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
cout << " In _acceptNamedPipeConnection -- after calling namedPipeServer->accept()" << endl; | cout << " In _acceptNamedPipeConnection -- after calling namedPipeServer->accept()" << endl; |
|
} |
HTTPConnection* connection = new HTTPConnection(_monitor, nPSEndPoint, | HTTPConnection* connection = new HTTPConnection(_monitor, nPSEndPoint, |
this, static_cast<MessageQueue *>(_outputMessageQueue), _exportConnection); | 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; |
| |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
cout << endl << connection->getNamedPipe().getName() << " has a this as a QueueID " << | cout << endl << connection->getNamedPipe().getName() << " has a this as a QueueID " << |
connection->getQueueId() << endl; | connection->getQueueId() << endl; |
|
} |
if (-1 == (index = _monitor->solicitPipeMessages( | if (-1 == (index = _monitor->solicitPipeMessages( |
connection->getNamedPipe(), | connection->getNamedPipe(), |
NamedPipeMessage::READ | NamedPipeMessage::EXCEPTION, | NamedPipeMessage::READ | NamedPipeMessage::EXCEPTION, |
|
|
AutoMutex autoMut(_rep->_connection_mut); | AutoMutex autoMut(_rep->_connection_mut); |
_rep->connections.append(connection); | _rep->connections.append(connection); |
| |
|
{ |
|
AutoMutex automut(Monitor::_cout_mut); |
PEGASUS_STD(cout) | PEGASUS_STD(cout) |
<< "in HTTPAcceptor::_acceptNamedPipeConnection() at the end" << PEGASUS_STD(endl); | << "in HTTPAcceptor::_acceptNamedPipeConnection() at the end" << PEGASUS_STD(endl); |
|
} |
| |
} | } |
#endif | #endif |