now there can be multiple tcpiiu per BHE
This commit is contained in:
+28
-18
@@ -38,6 +38,15 @@ bhe::~bhe ()
|
||||
{
|
||||
}
|
||||
|
||||
void bhe::beaconAnomalyNotify ()
|
||||
{
|
||||
tsDLIterBD < tcpiiu > iter = this->iiuList.firstIter ();
|
||||
while ( iter.valid() ) {
|
||||
iter->beaconAnomalyNotify ();
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* update beacon period
|
||||
*
|
||||
@@ -51,9 +60,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
|
||||
if ( this->timeStamp == epicsTime () ) {
|
||||
|
||||
if ( this->piiu ) {
|
||||
this->piiu->beaconAnomalyNotify ();
|
||||
}
|
||||
this->beaconAnomalyNotify ();
|
||||
|
||||
/*
|
||||
* this is the 1st beacon seen - the beacon time stamp
|
||||
@@ -73,9 +80,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
if ( this->averagePeriod < 0.0 ) {
|
||||
double totalRunningTime;
|
||||
|
||||
if ( this->piiu ) {
|
||||
this->piiu->beaconAnomalyNotify ();
|
||||
}
|
||||
this->beaconAnomalyNotify ();
|
||||
|
||||
/*
|
||||
* this is the 2nd beacon seen. We cant tell about
|
||||
@@ -112,9 +117,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
* trigger on any missing beacon
|
||||
* if connected to this server
|
||||
*/
|
||||
if ( this->piiu ) {
|
||||
this->piiu->beaconAnomalyNotify ();
|
||||
}
|
||||
this->beaconAnomalyNotify ();
|
||||
|
||||
if ( currentPeriod >= this->averagePeriod * 3.25 ) {
|
||||
/*
|
||||
@@ -137,9 +140,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
* that the server is available
|
||||
*/
|
||||
else if ( currentPeriod <= this->averagePeriod * 0.80 ) {
|
||||
if ( this->piiu ) {
|
||||
this->piiu->beaconAnomalyNotify ();
|
||||
}
|
||||
this->beaconAnomalyNotify ();
|
||||
netChange = true;
|
||||
}
|
||||
else {
|
||||
@@ -147,8 +148,10 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
* update state of health for active virtual circuits
|
||||
* if the beacon looks ok
|
||||
*/
|
||||
if ( this->piiu ) {
|
||||
piiu->beaconArrivalNotify (); // reset connection activity watchdog
|
||||
tsDLIterBD < tcpiiu > iter = this->iiuList.firstIter ();
|
||||
while ( iter.valid() ) {
|
||||
iter->beaconArrivalNotify ();
|
||||
iter++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,10 +178,6 @@ void bhe::show ( unsigned level ) const
|
||||
{
|
||||
::printf ( "CA beacon hash entry at %p with average period %f\n",
|
||||
static_cast <const void *> ( this ), this->averagePeriod );
|
||||
if ( level > 0u ) {
|
||||
::printf ( "network IO pointer %p\n",
|
||||
static_cast <void *> ( this->piiu ) );
|
||||
}
|
||||
}
|
||||
|
||||
void bhe::destroy ()
|
||||
@@ -191,4 +190,15 @@ double bhe::period () const
|
||||
return this->averagePeriod;
|
||||
}
|
||||
|
||||
void bhe::registerIIU ( tcpiiu & iiu )
|
||||
{
|
||||
this->iiuList.add ( iiu );
|
||||
}
|
||||
|
||||
void bhe::unregisterIIU ( tcpiiu & iiu )
|
||||
{
|
||||
this->iiuList.remove ( iiu );
|
||||
this->timeStamp = epicsTime();
|
||||
this->averagePeriod = - DBL_MAX;
|
||||
}
|
||||
|
||||
|
||||
+8
-28
@@ -24,6 +24,7 @@
|
||||
#endif
|
||||
|
||||
#include "tsSLList.h"
|
||||
#include "tsDLList.h"
|
||||
#include "tsFreeList.h"
|
||||
#include "epicsTime.h"
|
||||
|
||||
@@ -38,22 +39,22 @@ class tcpiiu;
|
||||
class bhe : public tsSLNode < bhe >, public inetAddrID {
|
||||
public:
|
||||
epicsShareFunc bhe ( const epicsTime &initialTimeStamp, const inetAddrID &addr );
|
||||
tcpiiu *getIIU () const;
|
||||
void bindToIIU ( tcpiiu & );
|
||||
void unbindFromIIU ();
|
||||
epicsShareFunc void destroy ();
|
||||
epicsShareFunc bool updatePeriod ( const epicsTime &programBeginTime,
|
||||
epicsShareFunc bool updatePeriod ( const epicsTime & programBeginTime,
|
||||
const epicsTime & currentTime );
|
||||
epicsShareFunc double period () const;
|
||||
epicsShareFunc void show ( unsigned level) const;
|
||||
epicsShareFunc void registerIIU ( tcpiiu & );
|
||||
epicsShareFunc void unregisterIIU ( tcpiiu & );
|
||||
epicsShareFunc void * operator new ( size_t size );
|
||||
epicsShareFunc void operator delete ( void *pCadaver, size_t size );
|
||||
protected:
|
||||
epicsShareFunc ~bhe (); // force allocation from freeList
|
||||
private:
|
||||
tcpiiu *piiu;
|
||||
tsDLList < tcpiiu > iiuList;
|
||||
epicsTime timeStamp;
|
||||
double averagePeriod;
|
||||
void beaconAnomalyNotify ();
|
||||
static tsFreeList < class bhe, 1024 > freeList;
|
||||
static epicsMutex freeListMutex;
|
||||
};
|
||||
@@ -72,9 +73,8 @@ private:
|
||||
* zero (so we can correctly compute the period
|
||||
* between the 1st and 2nd beacons)
|
||||
*/
|
||||
inline bhe::bhe ( const epicsTime &initialTimeStamp, const inetAddrID &addr ) :
|
||||
inetAddrID ( addr ), piiu ( 0 ),
|
||||
timeStamp ( initialTimeStamp ), averagePeriod ( - DBL_MAX )
|
||||
inline bhe::bhe ( const epicsTime & initialTimeStamp, const inetAddrID & addr ) :
|
||||
inetAddrID ( addr ), timeStamp ( initialTimeStamp ), averagePeriod ( - DBL_MAX )
|
||||
{
|
||||
# ifdef DEBUG
|
||||
{
|
||||
@@ -85,26 +85,6 @@ inline bhe::bhe ( const epicsTime &initialTimeStamp, const inetAddrID &addr ) :
|
||||
# endif
|
||||
}
|
||||
|
||||
inline tcpiiu *bhe::getIIU ()const
|
||||
{
|
||||
return this->piiu;
|
||||
}
|
||||
|
||||
inline void bhe::bindToIIU ( tcpiiu &iiuIn )
|
||||
{
|
||||
if ( this->piiu != &iiuIn ) {
|
||||
assert ( this->piiu == 0 );
|
||||
this->piiu = &iiuIn;
|
||||
}
|
||||
}
|
||||
|
||||
inline void bhe::unbindFromIIU ()
|
||||
{
|
||||
this->piiu = 0;
|
||||
this->timeStamp = epicsTime();
|
||||
this->averagePeriod = - DBL_MAX;
|
||||
}
|
||||
|
||||
#endif // ifdef bheh
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user