version 1.117, 2007/02/14 05:13:59
|
version 1.120, 2007/06/05 09:36:36
|
|
|
{ | { |
uninitializeTickler(); | uninitializeTickler(); |
Socket::uninitializeInterface(); | Socket::uninitializeInterface(); |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, |
"returning from monitor destructor"); | "returning from monitor destructor"); |
} | } |
void Monitor::uninitializeTickler() | void Monitor::uninitializeTickler() |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, "uninitializing interface"); |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, "uninitializing interface"); |
| |
try | try |
{ | { |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, |
"Failed to close tickle sockets"); | "Failed to close tickle sockets"); |
} | } |
| |
|
|
| |
// initialize the address | // initialize the address |
memset(&_tickle_server_addr, 0, sizeof(_tickle_server_addr)); | memset(&_tickle_server_addr, 0, sizeof(_tickle_server_addr)); |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
|
#pragma convert(37) |
|
#endif |
|
_tickle_server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); | _tickle_server_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
|
#pragma convert(0) |
|
#endif |
|
_tickle_server_addr.sin_family = PF_INET; | _tickle_server_addr.sin_family = PF_INET; |
_tickle_server_addr.sin_port = 0; | _tickle_server_addr.sin_port = 0; |
| |
|
|
| |
// setup the address of the client | // setup the address of the client |
memset(&_tickle_client_addr, 0, sizeof(_tickle_client_addr)); | memset(&_tickle_client_addr, 0, sizeof(_tickle_client_addr)); |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
|
# pragma convert(37) |
|
#endif |
|
_tickle_client_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); | _tickle_client_addr.sin_addr.s_addr = inet_addr("127.0.0.1"); |
#ifdef PEGASUS_PLATFORM_OS400_ISERIES_IBM |
|
# pragma convert(0) |
|
#endif |
|
_tickle_client_addr.sin_family = PF_INET; | _tickle_client_addr.sin_family = PF_INET; |
_tickle_client_addr.sin_port = 0; | _tickle_client_addr.sin_port = 0; |
| |
|
|
| |
if (h._responsePending == true) | if (h._responsePending == true) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::run - Ignoring connection delete request " | "Monitor::run - Ignoring connection delete request " |
"because responses are still pending. " | "because responses are still pending. " |
"connection=0x%p, socket=%d\n", | "connection=0x%p, socket=%d\n", |
(void *)&h, h.getSocket()); |
(void *)&h, h.getSocket())); |
continue; | continue; |
} | } |
h._connectionClosePending = false; | h._connectionClosePending = false; |
|
|
| |
if (events == PEGASUS_SOCKET_ERROR) | if (events == PEGASUS_SOCKET_ERROR) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::run - errorno = %d has occurred on select.", errno); |
"Monitor::run - errorno = %d has occurred on select.", errno)); |
// The EBADF error indicates that one or more or the file | // The EBADF error indicates that one or more or the file |
// descriptions was not valid. This could indicate that | // descriptions was not valid. This could indicate that |
// the entries structure has been corrupted or that | // the entries structure has been corrupted or that |
|
|
} | } |
else if (events) | else if (events) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::run select event received events = %d, monitoring %d " | "Monitor::run select event received events = %d, monitoring %d " |
"idle entries", | "idle entries", |
events, _idleEntries); |
events, _idleEntries)); |
for (int indx = 0; indx < (int)entries.size(); indx++) | for (int indx = 0; indx < (int)entries.size(); indx++) |
{ | { |
// The Monitor should only look at entries in the table that are | // The Monitor should only look at entries in the table that are |
|
|
(FD_ISSET(entries[indx].socket, &fdread))) | (FD_ISSET(entries[indx].socket, &fdread))) |
{ | { |
MessageQueue *q = MessageQueue::lookup(entries[indx].queueId); | MessageQueue *q = MessageQueue::lookup(entries[indx].queueId); |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::run indx = %d, queueId = %d, q = %p", | "Monitor::run indx = %d, queueId = %d, q = %p", |
indx, entries[indx].queueId, q); |
indx, entries[indx].queueId, q)); |
PEGASUS_ASSERT(q !=0); | PEGASUS_ASSERT(q !=0); |
| |
try | try |
{ | { |
if (entries[indx]._type == Monitor::CONNECTION) | if (entries[indx]._type == Monitor::CONNECTION) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"entries[indx].type for indx = %d is " | "entries[indx].type for indx = %d is " |
"Monitor::CONNECTION", | "Monitor::CONNECTION", |
indx); |
indx)); |
static_cast<HTTPConnection *>(q)->_entry_index = indx; | static_cast<HTTPConnection *>(q)->_entry_index = indx; |
| |
// Do not update the entry just yet. The entry gets | // Do not update the entry just yet. The entry gets |
|
|
if (!MessageQueueService::get_thread_pool()-> | if (!MessageQueueService::get_thread_pool()-> |
allocate_and_awaken((void *)q, _dispatch)) | allocate_and_awaken((void *)q, _dispatch)) |
{ | { |
Tracer::trace(TRC_DISCARDED_DATA, Tracer::LEVEL2, |
PEG_TRACE_CSTRING(TRC_DISCARDED_DATA, |
|
Tracer::LEVEL2, |
"Monitor::run: Insufficient resources to " | "Monitor::run: Insufficient resources to " |
"process request."); | "process request."); |
entries[indx]._status = _MonitorEntry::IDLE; | entries[indx]._status = _MonitorEntry::IDLE; |
|
|
// Added for PEP 183 | // Added for PEP 183 |
HTTPConnection *dst = | HTTPConnection *dst = |
reinterpret_cast<HTTPConnection *>(q); | reinterpret_cast<HTTPConnection *>(q); |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: entering run() for " | "Monitor::_dispatch: entering run() for " |
"indx = %d, queueId = %d, q = %p", | "indx = %d, queueId = %d, q = %p", |
dst->_entry_index, | dst->_entry_index, |
dst->_monitor->_entries[dst->_entry_index].queueId, | dst->_monitor->_entries[dst->_entry_index].queueId, |
dst); |
dst)); |
| |
try | try |
{ | { |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: exception received"); | "Monitor::_dispatch: exception received"); |
} | } |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: exited run() for index %d", | "Monitor::_dispatch: exited run() for index %d", |
dst->_entry_index); |
dst->_entry_index)); |
| |
// It is possible the entry status may not be set to | // It is possible the entry status may not be set to |
// busy. The following will fail in that case. | // busy. The following will fail in that case. |
|
|
if (amt == PEGASUS_SOCKET_ERROR && | if (amt == PEGASUS_SOCKET_ERROR && |
getSocketError() == PEGASUS_NETWORK_TCPIP_STOPPED) | getSocketError() == PEGASUS_NETWORK_TCPIP_STOPPED) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, |
"Monitor::run: Tickler socket got an IO error. " | "Monitor::run: Tickler socket got an IO error. " |
"Going to re-create Socket and wait for " | "Going to re-create Socket and wait for " |
"TCP/IP restart."); | "TCP/IP restart."); |
|
|
} | } |
else | else |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Non-connection entry, indx = %d, has been " | "Non-connection entry, indx = %d, has been " |
"received.", | "received.", |
indx); |
indx)); |
int events = 0; | int events = 0; |
events |= SocketMessage::READ; | events |= SocketMessage::READ; |
Message* msg = new SocketMessage( | Message* msg = new SocketMessage( |
|
|
ThreadReturnType PEGASUS_THREAD_CDECL Monitor::_dispatch(void* parm) | ThreadReturnType PEGASUS_THREAD_CDECL Monitor::_dispatch(void* parm) |
{ | { |
HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(parm); | HTTPConnection *dst = reinterpret_cast<HTTPConnection *>(parm); |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: entering run() for indx = %d, queueId = %d, " | "Monitor::_dispatch: entering run() for indx = %d, queueId = %d, " |
"q = %p", | "q = %p", |
dst->_entry_index, | dst->_entry_index, |
dst->_monitor->_entries[dst->_entry_index].queueId, | dst->_monitor->_entries[dst->_entry_index].queueId, |
dst); |
dst)); |
| |
try | try |
{ | { |
|
|
} | } |
catch (...) | catch (...) |
{ | { |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE_CSTRING(TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: exception received"); | "Monitor::_dispatch: exception received"); |
} | } |
Tracer::trace(TRC_HTTP, Tracer::LEVEL4, |
PEG_TRACE((TRC_HTTP, Tracer::LEVEL4, |
"Monitor::_dispatch: exited run() for index %d", dst->_entry_index); |
"Monitor::_dispatch: exited run() for index %d", dst->_entry_index)); |
| |
PEGASUS_ASSERT(dst->_monitor->_entries[dst->_entry_index]._status.get() == | PEGASUS_ASSERT(dst->_monitor->_entries[dst->_entry_index]._status.get() == |
_MonitorEntry::BUSY); | _MonitorEntry::BUSY); |