improved management of per channel IO list
This commit is contained in:
@@ -13,19 +13,34 @@
|
||||
#include "iocinf.h"
|
||||
#include "nciu_IL.h"
|
||||
|
||||
baseNMIU::baseNMIU ( nciu &chanIn ) : chan ( chanIn )
|
||||
osiMutex baseNMIU::mutex;
|
||||
|
||||
baseNMIU::baseNMIU ( nciu &chanIn ) :
|
||||
chan ( chanIn ), attachedToChannel ( true )
|
||||
{
|
||||
chanIn.ioInstall ( *this );
|
||||
}
|
||||
|
||||
baseNMIU::~baseNMIU ()
|
||||
{
|
||||
// private NOOP forces pool allocation
|
||||
this->uninstallFromChannel ();
|
||||
}
|
||||
|
||||
void baseNMIU::uninstallFromChannel ()
|
||||
{
|
||||
this->mutex.lock ();
|
||||
bool attached = this->attachedToChannel;
|
||||
this->attachedToChannel = false;
|
||||
this->mutex.unlock ();
|
||||
|
||||
if ( attached ) {
|
||||
this->chan.ioUninstall ( *this );
|
||||
}
|
||||
}
|
||||
|
||||
void baseNMIU::destroy ()
|
||||
{
|
||||
this->chan.ioDestroy ( this->getId () );
|
||||
delete this;
|
||||
}
|
||||
|
||||
int baseNMIU::subscriptionMsg ()
|
||||
@@ -35,5 +50,6 @@ int baseNMIU::subscriptionMsg ()
|
||||
|
||||
void baseNMIU::show ( unsigned /* level */ ) const
|
||||
{
|
||||
printf ( "CA IO primitive at %p for channel %s\n", this, chan.pName () );
|
||||
printf ( "CA IO primitive at %p for channel %s\n",
|
||||
this, this->chan.pName () );
|
||||
}
|
||||
|
||||
@@ -630,11 +630,17 @@ bool cac::ioComplete () const
|
||||
}
|
||||
}
|
||||
|
||||
void cac::ioInstall ( nciu &chan, baseNMIU &io )
|
||||
void cac::ioInstall ( baseNMIU &io )
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
this->ioTable.add ( io );
|
||||
chan.cacPrivateListOfIO::eventq.add ( io );
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
|
||||
void cac::ioUninstall ( unsigned id )
|
||||
{
|
||||
this->defaultMutex.lock ();
|
||||
this->ioTable.remove ( id );
|
||||
this->defaultMutex.unlock ();
|
||||
}
|
||||
|
||||
@@ -643,7 +649,7 @@ void cac::ioDestroy ( unsigned id )
|
||||
this->defaultMutex.lock ();
|
||||
baseNMIU * pmiu = this->ioTable.remove ( id );
|
||||
if ( pmiu ) {
|
||||
pmiu->chan.cacPrivateListOfIO::eventq.remove ( *pmiu );
|
||||
pmiu->uninstallFromChannel ();
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
// care is taken to not destroy with the cac lock
|
||||
@@ -703,7 +709,7 @@ void cac::ioCompletionNotifyAndDestroy ( unsigned id )
|
||||
this->defaultMutex.lock ();
|
||||
baseNMIU * pmiu = this->ioTable.remove ( id );
|
||||
if ( pmiu ) {
|
||||
pmiu->chan.cacPrivateListOfIO::eventq.remove ( *pmiu );
|
||||
pmiu->uninstallFromChannel ();
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
// care is taken to not destroy with the cac lock
|
||||
@@ -723,7 +729,7 @@ void cac::ioCompletionNotifyAndDestroy ( unsigned id,
|
||||
this->defaultMutex.lock ();
|
||||
baseNMIU * pmiu = this->ioTable.remove ( id );
|
||||
if ( pmiu ) {
|
||||
pmiu->chan.cacPrivateListOfIO::eventq.remove ( *pmiu );
|
||||
pmiu->uninstallFromChannel ();
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
// care is taken to not destroy with the cac lock
|
||||
@@ -742,7 +748,7 @@ void cac::ioExceptionNotifyAndDestroy ( unsigned id, int status, const char *pCo
|
||||
this->defaultMutex.lock ();
|
||||
baseNMIU * pmiu = this->ioTable.remove ( id );
|
||||
if ( pmiu ) {
|
||||
pmiu->chan.cacPrivateListOfIO::eventq.remove ( *pmiu );
|
||||
pmiu->uninstallFromChannel ();
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
// care is taken to not destroy with the cac lock
|
||||
@@ -762,7 +768,7 @@ void cac::ioExceptionNotifyAndDestroy ( unsigned id, int status,
|
||||
this->defaultMutex.lock ();
|
||||
baseNMIU * pmiu = this->ioTable.remove ( id );
|
||||
if ( pmiu ) {
|
||||
pmiu->chan.cacPrivateListOfIO::eventq.remove ( *pmiu );
|
||||
pmiu->uninstallFromChannel ();
|
||||
}
|
||||
this->defaultMutex.unlock ();
|
||||
// care is taken to not destroy with the cac lock
|
||||
|
||||
@@ -22,6 +22,20 @@ cacPrivateListOfIO::cacPrivateListOfIO ( cac &cacIn ) :
|
||||
{
|
||||
}
|
||||
|
||||
void cacPrivateListOfIO::addIO ( baseNMIU &io )
|
||||
{
|
||||
this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock ();
|
||||
this->eventq.add ( io );
|
||||
this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock ();
|
||||
}
|
||||
|
||||
void cacPrivateListOfIO::removeIO ( baseNMIU &io )
|
||||
{
|
||||
this->cacCtx.cacPrivateListOfIOPrivate::mutex.lock ();
|
||||
this->eventq.remove ( io );
|
||||
this->cacCtx.cacPrivateListOfIOPrivate::mutex.unlock ();
|
||||
}
|
||||
|
||||
// Destroy all IO blocks attached.
|
||||
// Care is taken here not to hold the lock while
|
||||
// sending a subscription delete message (which
|
||||
|
||||
@@ -241,6 +241,7 @@ private:
|
||||
};
|
||||
|
||||
class cac;
|
||||
class baseNMIU;
|
||||
|
||||
class cacPrivateListOfIO {
|
||||
public:
|
||||
@@ -248,15 +249,16 @@ public:
|
||||
void destroyAllIO ();
|
||||
void subscribeAllIO ();
|
||||
void disconnectAllIO ( const char *pHostName );
|
||||
void addIO ( baseNMIU &io );
|
||||
void removeIO ( baseNMIU &io );
|
||||
protected:
|
||||
cac &cacCtx;
|
||||
private:
|
||||
tsDLList < class baseNMIU > eventq;
|
||||
friend class cac;
|
||||
};
|
||||
|
||||
class nciu : public cacChannelIO, public tsDLNode < nciu >,
|
||||
public chronIntIdRes < nciu >, public cacPrivateListOfIO {
|
||||
public chronIntIdRes < nciu >, private cacPrivateListOfIO {
|
||||
public:
|
||||
nciu ( class cac &cac, cacChannel &chan, const char *pNameIn );
|
||||
void destroy ();
|
||||
@@ -301,7 +303,7 @@ public:
|
||||
void attachChanToIIU ( netiiu &iiu );
|
||||
void detachChanFromIIU ();
|
||||
void ioInstall ( class baseNMIU & );
|
||||
void ioDestroy ( unsigned id );
|
||||
void ioUninstall ( class baseNMIU & );
|
||||
bool setClaimMsgCache ( class claimMsgCache & );
|
||||
void show ( unsigned level ) const;
|
||||
|
||||
@@ -346,10 +348,12 @@ public:
|
||||
virtual void show ( unsigned level ) const;
|
||||
virtual int subscriptionMsg ();
|
||||
void destroy ();
|
||||
void uninstallFromChannel ();
|
||||
protected:
|
||||
virtual ~baseNMIU (); // must be allocated from pool
|
||||
nciu &chan;
|
||||
friend class cac;
|
||||
bool attachedToChannel;
|
||||
static osiMutex mutex;
|
||||
};
|
||||
|
||||
class netSubscription : private cacNotifyIO, private baseNMIU {
|
||||
@@ -1009,8 +1013,9 @@ public:
|
||||
|
||||
// IO management routines
|
||||
bool ioComplete () const;
|
||||
void ioInstall ( baseNMIU &io );
|
||||
void ioUninstall ( unsigned id );
|
||||
void ioDestroy ( unsigned id );
|
||||
void ioInstall ( nciu &chan, baseNMIU &io );
|
||||
void ioCompletionNotify ( unsigned id );
|
||||
void ioCompletionNotify ( unsigned id, unsigned type,
|
||||
unsigned long count, const void *pData );
|
||||
|
||||
@@ -161,11 +161,13 @@ inline bool nciu::connectionInProgress ( const osiSockAddr &addrIn )
|
||||
|
||||
inline void nciu::ioInstall ( class baseNMIU &nmiu )
|
||||
{
|
||||
this->cacCtx.ioInstall ( *this, nmiu );
|
||||
this->addIO ( nmiu );
|
||||
this->cacCtx.ioInstall ( nmiu );
|
||||
}
|
||||
|
||||
inline void nciu::ioDestroy ( unsigned idIn )
|
||||
inline void nciu::ioUninstall ( class baseNMIU &nmiu )
|
||||
{
|
||||
this->cacCtx.ioDestroy ( idIn );
|
||||
this->cacCtx.ioUninstall ( nmiu.getId () );
|
||||
this->removeIO ( nmiu );
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ void netReadCopyIO::completionNotify ( unsigned typeIn,
|
||||
memcpy ( this->pValue, pDataIn,
|
||||
dbr_size_n ( typeIn, countIn ) );
|
||||
# endif
|
||||
this->chan.decrementOutstandingIO (this->seqNumber);
|
||||
this->chan.decrementOutstandingIO ( this->seqNumber );
|
||||
}
|
||||
else {
|
||||
this->exceptionNotify ( ECA_INTERNAL, "bad data type in message" );
|
||||
|
||||
@@ -31,7 +31,7 @@ netSubscription::~netSubscription ()
|
||||
|
||||
void netSubscription::destroy()
|
||||
{
|
||||
this->baseNMIU::destroy ();
|
||||
delete this;
|
||||
}
|
||||
|
||||
int netSubscription::subscriptionMsg ()
|
||||
|
||||
Reference in New Issue
Block a user