installed

This commit is contained in:
Jeff Hill
2000-09-07 01:41:31 +00:00
parent 58b5aa0256
commit 57143c27c7
4 changed files with 236 additions and 3 deletions
+81
View File
@@ -0,0 +1,81 @@
/*
* $Id$
*
*
* L O S A L A M O S
* Los Alamos National Laboratory
* Los Alamos, New Mexico 87545
*
* Copyright, 1986, The Regents of the University of California.
*
*
* Author Jeffrey O. Hill
* johill@lanl.gov
* 505 665 1831
*/
#include "iocinf.h"
cacPrivateListOfIO::cacPrivateListOfIO ( cac &cacIn ) :
cacCtx ( cacIn )
{
}
// Destroy all IO blocks attached.
// Care is taken here not to hold the lock while
// sending a subscription delete message (which
// would result in deadlocks)
void cacPrivateListOfIO::destroyAllIO ()
{
while ( true ) {
unsigned id;
bool done;
this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock ();
{
baseNMIU *pNMIU = this->eventq.first ();
if ( pNMIU ) {
id = pNMIU->getId ();
done = false;
}
else {
id = UINT_MAX;
done = true;
}
}
this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock ();
if ( done ) {
break;
}
// care is taken to not hold a lock when
// executing this
this->cacCtx.ioDestroy ( id );
}
}
// resubscribe for monitors from this channel
void cacPrivateListOfIO::subscribeAllIO ()
{
this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock ();
tsDLIterBD < baseNMIU > iter = this->eventq.first ();
while ( iter.valid () ) {
iter->subscriptionMsg ();
iter++;
}
this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock ();
}
// cancel IO operations and monitor subscriptions
void cacPrivateListOfIO::disconnectAllIO ( const char *pHostName )
{
this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock ();
tsDLIterBD < baseNMIU > iter = this->eventq.first ();
while ( iter.valid () ) {
tsDLIterBD < baseNMIU > next = iter.itemAfter ();
iter->disconnect ( pHostName );
iter = next;
}
this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock ();
}
+3 -3
View File
@@ -23,7 +23,7 @@ inline claimMsgCache::~claimMsgCache ()
}
}
inline int claimMsgCache::deliverMsg ( tcpiiu &iiu )
inline int claimMsgCache::deliverMsg ( netiiu &iiu )
{
if ( v44 ) {
return iiu.createChannelRequest ( this->clientId, this->pStr, this->currentStrLen );
@@ -33,7 +33,7 @@ inline int claimMsgCache::deliverMsg ( tcpiiu &iiu )
}
}
inline bool claimMsgCache::channelMatches ( class nciu &chan )
inline void claimMsgCache::connectChannel ( cac & cacRef )
{
return chan.id == this->clientId;
cacRef.connectChannel ( this->clientId );
}
+85
View File
@@ -0,0 +1,85 @@
/*
* $Id$
*
*
* L O S A L A M O S
* Los Alamos National Laboratory
* Los Alamos, New Mexico 87545
*
* Copyright, 1986, The Regents of the University of California.
*
*
* Author Jeffrey O. Hill
* johill@lanl.gov
* 505 665 1831
*/
#include "iocinf.h"
void ioCounter::decrementOutstandingIO ()
{
bool signalNeeded;
this->mutex.lock ();
if ( this->pndrecvcnt > 0u ) {
this->pndrecvcnt--;
if ( this->pndrecvcnt == 0u ) {
signalNeeded = true;
}
else {
signalNeeded = false;
}
}
else {
signalNeeded = true;
}
this->mutex.unlock ();
if ( signalNeeded ) {
this->ioDone.signal ();
}
}
void ioCounter::decrementOutstandingIO ( unsigned seqNumber )
{
bool signalNeeded;
this->mutex.lock ();
if ( this->readSeq == seqNumber ) {
if ( this->pndrecvcnt > 0u ) {
this->pndrecvcnt--;
if ( this->pndrecvcnt == 0u ) {
signalNeeded = true;
}
else {
signalNeeded = false;
}
}
else {
signalNeeded = true;
}
}
else {
signalNeeded = false;
}
this->mutex.unlock ();
if ( signalNeeded ) {
this->ioDone.signal ();
}
}
void ioCounter::showOutstandingIO ( unsigned level ) const
{
printf ( "ioCounter at %p\n", this );
printf ( "\tthere are %u unsatisfied IO operations blocking ca_pend_io()\n",
this->pndrecvcnt );
if ( level > 0u ) {
printf ( "\tthe current read sequence number is %u\n",
this->readSeq );
}
if ( level > 1u ) {
printf ( "IO done event:\n");
this->ioDone.show ( level - 2u );
}
}
+67
View File
@@ -0,0 +1,67 @@
/*
* $Id$
*
*
* L O S A L A M O S
* Los Alamos National Laboratory
* Los Alamos, New Mexico 87545
*
* Copyright, 1986, The Regents of the University of California.
*
*
* Author Jeffrey O. Hill
* johill@lanl.gov
* 505 665 1831
*/
inline ioCounter::ioCounter () : pndrecvcnt ( 0u ), readSeq ( 0u )
{
}
inline void ioCounter::incrementOutstandingIO ()
{
this->mutex.lock ();
if ( this->pndrecvcnt < UINT_MAX ) {
this->pndrecvcnt++;
}
this->mutex.unlock ();
}
inline void ioCounter::lockOutstandingIO () const
{
this->mutex.lock ();
}
inline void ioCounter::unlockOutstandingIO () const
{
this->mutex.unlock ();
}
inline unsigned ioCounter::readSequenceOfOutstandingIO () const
{
return this->readSeq;
}
inline unsigned ioCounter::currentOutstandingIOCount () const
{
return this->pndrecvcnt;
}
inline void ioCounter::waitForCompletionOfIO ( double delaySec )
{
this->ioDone.wait ( delaySec );
}
inline void ioCounter::cleanUpOutstandingIO ()
{
this->mutex.lock ();
this->readSeq++;
this->pndrecvcnt = 0u;
this->mutex.unlock ();
}