optimizations suggested by quantify
This commit is contained in:
+1
-1
@@ -199,7 +199,7 @@ bool bhe::updatePeriod ( const epicsTime & programBeginTime,
|
||||
else if ( this->pIIU ) {
|
||||
// update state of health for active virtual circuits
|
||||
// if the beacon looks ok
|
||||
this->pIIU->beaconArrivalNotify ();
|
||||
this->pIIU->beaconArrivalNotify ( currentTime );
|
||||
}
|
||||
|
||||
// update a running average period
|
||||
|
||||
+23
-21
@@ -431,7 +431,7 @@ void cac::beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime,
|
||||
|
||||
this->beaconAnomalyCount++;
|
||||
|
||||
this->pudpiiu->beaconAnomalyNotify ();
|
||||
this->pudpiiu->beaconAnomalyNotify ( currentTime );
|
||||
|
||||
# if DEBUG
|
||||
{
|
||||
@@ -1088,19 +1088,19 @@ cac::subscriptionRequest ( nciu & chan, unsigned type, // X aCC 361
|
||||
}
|
||||
|
||||
bool cac::versionAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cac::echoRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cac::writeNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &hdr, void * /* pMsgBdy */ )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &hdr, void * /* pMsgBdy */ )
|
||||
{
|
||||
int caStatus = hdr.m_cid;
|
||||
if ( caStatus == ECA_NORMAL ) {
|
||||
@@ -1114,7 +1114,7 @@ bool cac::writeNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
}
|
||||
|
||||
bool cac::readNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &iiu,
|
||||
const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
{
|
||||
/*
|
||||
* the channel id field is abused for
|
||||
@@ -1154,7 +1154,7 @@ bool cac::readNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &iiu,
|
||||
}
|
||||
|
||||
bool cac::eventRespAction (epicsGuard < callbackMutex > &, tcpiiu &iiu,
|
||||
const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
{
|
||||
int caStatus;
|
||||
|
||||
@@ -1203,7 +1203,7 @@ bool cac::eventRespAction (epicsGuard < callbackMutex > &, tcpiiu &iiu,
|
||||
}
|
||||
|
||||
bool cac::readRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &hdr, void *pMsgBdy )
|
||||
{
|
||||
this->ioCompletionNotifyAndDestroy ( hdr.m_available,
|
||||
hdr.m_dataType, hdr.m_count, pMsgBdy );
|
||||
@@ -1211,7 +1211,7 @@ bool cac::readRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
}
|
||||
|
||||
bool cac::clearChannelRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void * /* pMsgBdy */ )
|
||||
{
|
||||
return true; // currently a noop
|
||||
}
|
||||
@@ -1278,7 +1278,7 @@ bool cac::writeNotifyExcep ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
}
|
||||
|
||||
bool cac::exceptionRespAction ( epicsGuard < callbackMutex > & cbMutexIn, tcpiiu & iiu,
|
||||
const caHdrLargeArray & hdr, void * pMsgBdy )
|
||||
const epicsTime & currentTime, const caHdrLargeArray & hdr, void * pMsgBdy )
|
||||
{
|
||||
const caHdr * pReq = reinterpret_cast < const caHdr * > ( pMsgBdy );
|
||||
unsigned bytesSoFar = sizeof ( *pReq );
|
||||
@@ -1318,8 +1318,8 @@ bool cac::exceptionRespAction ( epicsGuard < callbackMutex > & cbMutexIn, tcpiiu
|
||||
}
|
||||
|
||||
bool cac::accessRightsRespAction (
|
||||
epicsGuard < callbackMutex > & cbGuard, tcpiiu &, // X aCC 431
|
||||
const caHdrLargeArray &hdr, void * /* pMsgBdy */ )
|
||||
epicsGuard < callbackMutex > & cbGuard, tcpiiu &, // X aCC 431
|
||||
const epicsTime & currentTime, const caHdrLargeArray &hdr, void * /* pMsgBdy */ )
|
||||
{
|
||||
nciu * pChan;
|
||||
{
|
||||
@@ -1347,8 +1347,8 @@ bool cac::accessRightsRespAction (
|
||||
}
|
||||
|
||||
bool cac::claimCIURespAction (
|
||||
epicsGuard < callbackMutex > &cbGuard, tcpiiu & iiu, // X aCC 431
|
||||
const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
epicsGuard < callbackMutex > &cbGuard, tcpiiu & iiu, // X aCC 431
|
||||
const epicsTime & currentTime, const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
{
|
||||
nciu * pChan;
|
||||
|
||||
@@ -1381,19 +1381,20 @@ bool cac::claimCIURespAction (
|
||||
}
|
||||
|
||||
bool cac::verifyAndDisconnectChan (
|
||||
epicsGuard < callbackMutex > & cbGuard, tcpiiu & /* iiu */,
|
||||
const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
epicsGuard < callbackMutex > & cbGuard, tcpiiu & /* iiu */,
|
||||
const epicsTime & currentTime, const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
{
|
||||
epicsGuard < cacMutex > guard ( this->mutex );
|
||||
nciu * pChan = this->chanTable.lookup ( hdr.m_cid );
|
||||
if ( ! pChan ) {
|
||||
return true;
|
||||
}
|
||||
this->disconnectChannel ( cbGuard, guard, *pChan );
|
||||
this->disconnectChannel ( currentTime, cbGuard, guard, *pChan );
|
||||
return true;
|
||||
}
|
||||
|
||||
void cac::disconnectChannel (
|
||||
const epicsTime & currentTime,
|
||||
epicsGuard < callbackMutex > & cbGuard, // X aCC 431
|
||||
epicsGuard < cacMutex > & guard, nciu & chan )
|
||||
{
|
||||
@@ -1401,14 +1402,14 @@ void cac::disconnectChannel (
|
||||
this->disconnectAllIO ( guard, chan, true );
|
||||
chan.getPIIU()->uninstallChan ( guard, chan );
|
||||
chan.disconnect ( *this->pudpiiu );
|
||||
this->pudpiiu->installChannel ( chan );
|
||||
this->pudpiiu->installChannel ( currentTime, chan );
|
||||
epicsGuardRelease < cacMutex > autoMutexRelease ( guard );
|
||||
chan.connectStateNotify ( cbGuard );
|
||||
chan.accessRightsNotify ( cbGuard );
|
||||
}
|
||||
|
||||
bool cac::badTCPRespAction ( epicsGuard < callbackMutex > &, tcpiiu & iiu,
|
||||
const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
const epicsTime & currentTime, const caHdrLargeArray & hdr, void * /* pMsgBdy */ )
|
||||
{
|
||||
char hostName[64];
|
||||
iiu.hostName ( hostName, sizeof ( hostName ) );
|
||||
@@ -1418,7 +1419,7 @@ bool cac::badTCPRespAction ( epicsGuard < callbackMutex > &, tcpiiu & iiu,
|
||||
}
|
||||
|
||||
bool cac::executeResponse ( epicsGuard < callbackMutex > & cbLocker, tcpiiu & iiu,
|
||||
caHdrLargeArray & hdr, char * pMshBody )
|
||||
const epicsTime & currentTime, caHdrLargeArray & hdr, char * pMshBody )
|
||||
{
|
||||
// execute the response message
|
||||
pProtoStubTCP pStub;
|
||||
@@ -1428,7 +1429,7 @@ bool cac::executeResponse ( epicsGuard < callbackMutex > & cbLocker, tcpiiu & ii
|
||||
else {
|
||||
pStub = cac::tcpJumpTableCAC [hdr.m_cmmd];
|
||||
}
|
||||
return ( this->*pStub ) ( cbLocker, iiu, hdr, pMshBody );
|
||||
return ( this->*pStub ) ( cbLocker, iiu, currentTime, hdr, pMshBody );
|
||||
}
|
||||
|
||||
void cac::signal ( int ca_status, const char *pfilenm,
|
||||
@@ -1572,7 +1573,8 @@ double cac::beaconPeriod ( const nciu & chan ) const
|
||||
void cac::initiateConnect ( nciu & chan )
|
||||
{
|
||||
assert ( this->pudpiiu );
|
||||
this->pudpiiu->installChannel ( chan );
|
||||
this->pudpiiu->installChannel (
|
||||
epicsTime::getCurrent(), chan );
|
||||
}
|
||||
|
||||
void *cacComBufMemoryManager::allocate ( size_t size )
|
||||
|
||||
+21
-16
@@ -103,7 +103,9 @@ private:
|
||||
|
||||
class cacDisconnectChannelPrivate { // X aCC 655
|
||||
public:
|
||||
virtual void disconnectChannel ( epicsGuard < callbackMutex > &,
|
||||
virtual void disconnectChannel (
|
||||
const epicsTime & currentTime,
|
||||
epicsGuard < callbackMutex > &,
|
||||
epicsGuard < cacMutex > &, nciu & chan ) = 0;
|
||||
};
|
||||
|
||||
@@ -125,7 +127,7 @@ public:
|
||||
void waitUntilNoRecvThreadsPending ();
|
||||
epicsGuard < callbackMutex > callbackGuardFactory ();
|
||||
bool executeResponse ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
caHdrLargeArray &, char *pMsgBody );
|
||||
const epicsTime & currentTime, caHdrLargeArray &, char *pMsgBody );
|
||||
|
||||
// channel routines
|
||||
bool lookupChannelAndTransferToTCP (
|
||||
@@ -266,7 +268,9 @@ private:
|
||||
void recycleWriteNotifyIO ( netWriteNotifyIO &io );
|
||||
void recycleSubscription ( netSubscription &io );
|
||||
|
||||
void disconnectChannel ( epicsGuard < callbackMutex > &,
|
||||
void disconnectChannel (
|
||||
const epicsTime & currentTime,
|
||||
epicsGuard < callbackMutex > &,
|
||||
epicsGuard < cacMutex > &, nciu & chan );
|
||||
|
||||
void ioCompletionNotify ( unsigned id, unsigned type,
|
||||
@@ -289,32 +293,33 @@ private:
|
||||
|
||||
// recv protocol stubs
|
||||
bool versionAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool echoRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool writeNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool readNotifyRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool eventRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool readRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool clearChannelRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool exceptionRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool accessRightsRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool claimCIURespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool verifyAndDisconnectChan ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
bool badTCPRespAction ( epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
|
||||
typedef bool ( cac::*pProtoStubTCP ) (
|
||||
epicsGuard < callbackMutex > &, tcpiiu &,
|
||||
const caHdrLargeArray &, void *pMsgBdy );
|
||||
const epicsTime & currentTime, const caHdrLargeArray &, void *pMsgBdy );
|
||||
static const pProtoStubTCP tcpJumpTableCAC [];
|
||||
|
||||
bool defaultExcep ( epicsGuard < callbackMutex > &, tcpiiu &iiu, const caHdrLargeArray &hdr,
|
||||
|
||||
+39
-33
@@ -69,12 +69,12 @@ public:
|
||||
void clear ();
|
||||
unsigned copyInBytes ( const void *pBuf, unsigned nBytes );
|
||||
unsigned push ( comBuf & );
|
||||
bool push ( const epicsInt8 & value );
|
||||
bool push ( const epicsUInt8 & value );
|
||||
bool push ( const epicsInt16 & value );
|
||||
bool push ( const epicsUInt16 & value );
|
||||
bool push ( const epicsInt32 & value );
|
||||
bool push ( const epicsUInt32 & value );
|
||||
bool push ( const epicsInt8 value );
|
||||
bool push ( const epicsUInt8 value );
|
||||
bool push ( const epicsInt16 value );
|
||||
bool push ( const epicsUInt16 value );
|
||||
bool push ( const epicsInt32 value );
|
||||
bool push ( const epicsUInt32 value );
|
||||
bool push ( const epicsFloat32 & value );
|
||||
bool push ( const epicsFloat64 & value );
|
||||
bool push ( const epicsOldString & value );
|
||||
@@ -186,7 +186,7 @@ inline unsigned comBuf::unoccupiedElem ( unsigned elemSize, unsigned nElem )
|
||||
return nElem;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt8 & value )
|
||||
inline bool comBuf::push ( const epicsInt8 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -196,7 +196,7 @@ inline bool comBuf::push ( const epicsInt8 & value )
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt8 & value )
|
||||
inline bool comBuf::push ( const epicsUInt8 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
@@ -205,59 +205,63 @@ inline bool comBuf::push ( const epicsUInt8 & value )
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt16 & value )
|
||||
inline bool comBuf::push ( const epicsInt16 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
}
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 0u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 8u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 1u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 0u );
|
||||
this->nextWriteIndex += sizeof ( value );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt16 & value )
|
||||
inline bool comBuf::push ( const epicsUInt16 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
}
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 0u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 8u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 1u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 0u );
|
||||
this->nextWriteIndex += sizeof ( value );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsInt32 & value )
|
||||
inline bool comBuf::push ( const epicsInt32 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
}
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 0u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 24u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 1u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 16u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 2u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 8u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 3u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 0u );
|
||||
this->nextWriteIndex += sizeof ( value );
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool comBuf::push ( const epicsUInt32 & value )
|
||||
inline bool comBuf::push ( const epicsUInt32 value )
|
||||
{
|
||||
if ( this->unoccupiedBytes () < sizeof ( value ) ) {
|
||||
return false;
|
||||
}
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 0u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 24u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 1u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 16u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 2u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 8u );
|
||||
this->buf[this->nextWriteIndex++] =
|
||||
this->buf[ this->nextWriteIndex + 3u ] =
|
||||
static_cast < epicsUInt8 > ( value >> 0u );
|
||||
this->nextWriteIndex += sizeof ( value );
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -387,7 +391,7 @@ inline unsigned comBuf::removeBytes ( unsigned nBytes )
|
||||
|
||||
inline epicsUInt8 comBuf::popUInt8 ()
|
||||
{
|
||||
if ( this->occupiedBytes () < 1u ) {
|
||||
if ( this->occupiedBytes () < sizeof ( comBuf::popUInt8 () ) ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
}
|
||||
return this->buf[ this->nextReadIndex++ ];
|
||||
@@ -395,23 +399,25 @@ inline epicsUInt8 comBuf::popUInt8 ()
|
||||
|
||||
inline epicsUInt16 comBuf::popUInt16 ()
|
||||
{
|
||||
if ( this->occupiedBytes () < 2u ) {
|
||||
if ( this->occupiedBytes () < sizeof ( comBuf::popUInt16 () ) ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
}
|
||||
unsigned byte1 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte2 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte1 = this->buf[ this->nextReadIndex + 0 ];
|
||||
unsigned byte2 = this->buf[ this->nextReadIndex + 1 ];
|
||||
this->nextReadIndex += sizeof ( comBuf::popUInt16 () );
|
||||
return static_cast < epicsUInt16 > ( ( byte1 << 8u ) | byte2 );
|
||||
}
|
||||
|
||||
inline epicsUInt32 comBuf::popUInt32 ()
|
||||
{
|
||||
if ( this->occupiedBytes () < 4u ) {
|
||||
if ( this->occupiedBytes () < sizeof ( comBuf::popUInt32 () ) ) {
|
||||
comBuf::throwInsufficentBytesException ();
|
||||
}
|
||||
unsigned byte1 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte2 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte3 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte4 = this->buf[ this->nextReadIndex++ ];
|
||||
unsigned byte1 = this->buf[ this->nextReadIndex + 0 ];
|
||||
unsigned byte2 = this->buf[ this->nextReadIndex + 1 ];
|
||||
unsigned byte3 = this->buf[ this->nextReadIndex + 2 ];
|
||||
unsigned byte4 = this->buf[ this->nextReadIndex + 3 ];
|
||||
this->nextReadIndex += sizeof ( comBuf::popUInt32 () );
|
||||
return static_cast < epicsUInt32 >
|
||||
( ( byte1 << 24u ) | ( byte2 << 16u ) | //X aCC 392
|
||||
( byte3 << 8u ) | byte4 ); //X aCC 392
|
||||
|
||||
+1
-2
@@ -98,9 +98,8 @@ private:
|
||||
}
|
||||
while ( nElem > nCopied ) {
|
||||
comBuf * pComBuf = newComBuf ();
|
||||
unsigned nNew = pComBuf->push
|
||||
nCopied += pComBuf->push
|
||||
( &pVal[nCopied], nElem - nCopied );
|
||||
nCopied += nNew;
|
||||
this->pushComBuf ( *pComBuf );
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ public:
|
||||
void connect ();
|
||||
void connectStateNotify ( epicsGuard < callbackMutex > & ) const;
|
||||
void accessRightsNotify ( epicsGuard < callbackMutex > & ) const;
|
||||
void disconnect ( netiiu &newiiu );
|
||||
void disconnect ( netiiu & newiiu );
|
||||
bool searchMsg ( class udpiiu & iiu, unsigned & retryNoForThisChannel );
|
||||
void createChannelRequest ( class tcpiiu & iiu );
|
||||
bool identifierEquivelence ( unsigned idToMatch );
|
||||
|
||||
+13
-10
@@ -64,23 +64,25 @@ searchTimer::~searchTimer ()
|
||||
this->timer.destroy ();
|
||||
}
|
||||
|
||||
void searchTimer::newChannleNotify ( bool firstChannel )
|
||||
void searchTimer::newChannleNotify (
|
||||
const epicsTime & currentTime, bool firstChannel )
|
||||
{
|
||||
if ( firstChannel ) {
|
||||
{
|
||||
epicsGuard < searchTimerMutex > locker ( this->mutex );
|
||||
this->recomputeTimerPeriod ( 0 );
|
||||
}
|
||||
this->timer.start ( *this, this->period );
|
||||
this->timer.start ( *this, currentTime + this->period );
|
||||
}
|
||||
else {
|
||||
this->recomputeTimerPeriodAndStartTimer ( 0, 0.0 );
|
||||
this->recomputeTimerPeriodAndStartTimer ( currentTime, 0, 0.0 );
|
||||
}
|
||||
}
|
||||
|
||||
void searchTimer::beaconAnomalyNotify ( const double & delay )
|
||||
void searchTimer::beaconAnomalyNotify (
|
||||
const epicsTime & currentTime, const double & delay )
|
||||
{
|
||||
this->recomputeTimerPeriodAndStartTimer ( beaconAnomalyRetrySetpoint, delay );
|
||||
this->recomputeTimerPeriodAndStartTimer ( currentTime, beaconAnomalyRetrySetpoint, delay );
|
||||
}
|
||||
|
||||
// lock must be applied
|
||||
@@ -97,7 +99,8 @@ void searchTimer::recomputeTimerPeriod ( unsigned minRetryNew )
|
||||
this->period = tsMax ( minSearchPeriod, this->period );
|
||||
}
|
||||
|
||||
void searchTimer::recomputeTimerPeriodAndStartTimer ( unsigned minRetryNew, const double & initialDelay )
|
||||
void searchTimer::recomputeTimerPeriodAndStartTimer (
|
||||
const epicsTime & currentTime, unsigned minRetryNew, const double & initialDelay )
|
||||
{
|
||||
bool start = false;
|
||||
double totalDelay = initialDelay;
|
||||
@@ -117,7 +120,7 @@ void searchTimer::recomputeTimerPeriodAndStartTimer ( unsigned minRetryNew, cons
|
||||
if ( totalDelay < oldPeriod ) {
|
||||
epicsTimer::expireInfo info = this->timer.getExpireInfo ();
|
||||
if ( info.active ) {
|
||||
double delay = epicsTime::getCurrent() - info.expireTime;
|
||||
double delay = currentTime - info.expireTime;
|
||||
if ( delay > totalDelay ) {
|
||||
start = true;
|
||||
}
|
||||
@@ -128,7 +131,7 @@ void searchTimer::recomputeTimerPeriodAndStartTimer ( unsigned minRetryNew, cons
|
||||
}
|
||||
|
||||
if ( start ) {
|
||||
this->timer.start ( *this, totalDelay );
|
||||
this->timer.start ( *this, currentTime + totalDelay );
|
||||
}
|
||||
debugPrintf ( ( "changed search period to %f sec\n", this->period ) );
|
||||
}
|
||||
@@ -171,7 +174,7 @@ void searchTimer::notifySearchResponse ( ca_uint32_t respDatagramSeqNo,
|
||||
if ( reschedualNeeded ) {
|
||||
# if defined(DEBUG) && 0
|
||||
char buf[64];
|
||||
epicsTime ts = epicsTime::getCurrent();
|
||||
epicsTime ts = currentTime;
|
||||
ts.strftime ( buf, sizeof(buf), "%M:%S.%09f");
|
||||
# endif
|
||||
// debugPrintf ( ( "Response set timer delay to zero. ts=%s\n",
|
||||
@@ -338,7 +341,7 @@ epicsTimerNotify::expireStatus searchTimer::expire ( const epicsTime & currentTi
|
||||
|
||||
# ifdef DEBUG
|
||||
char buf[64];
|
||||
epicsTime ts = epicsTime::getCurrent();
|
||||
epicsTime ts = currentTime;
|
||||
ts.strftime ( buf, sizeof(buf), "%M:%S.%09f");
|
||||
debugPrintf ( ("sent %u delay sec=%f Rts=%s\n",
|
||||
nFrameSent, this->period, buf ) );
|
||||
|
||||
@@ -50,8 +50,10 @@ public:
|
||||
virtual ~searchTimer ();
|
||||
void notifySearchResponse ( ca_uint32_t respDatagramSeqNo,
|
||||
bool seqNumberIsValid, const epicsTime & currentTime );
|
||||
void newChannleNotify ( bool firstChannel );
|
||||
void beaconAnomalyNotify ( const double & delay );
|
||||
void newChannleNotify (
|
||||
const epicsTime & currentTime, bool firstChannel );
|
||||
void beaconAnomalyNotify (
|
||||
const epicsTime & currentTime, const double & delay );
|
||||
void show ( unsigned level ) const;
|
||||
private:
|
||||
class searchTimerMutex mutex;
|
||||
@@ -70,7 +72,9 @@ private:
|
||||
ca_uint32_t dgSeqNoAtTimerExpireEnd;
|
||||
expireStatus expire ( const epicsTime & currentTime );
|
||||
void recomputeTimerPeriod ( unsigned minRetryNew );
|
||||
void recomputeTimerPeriodAndStartTimer ( unsigned minRetryNew, const double & initialDelay );
|
||||
void recomputeTimerPeriodAndStartTimer (
|
||||
const epicsTime & currentTime, unsigned minRetryNew,
|
||||
const double & initialDelay );
|
||||
searchTimer ( const searchTimer & );
|
||||
searchTimer & operator = ( const searchTimer & );
|
||||
};
|
||||
|
||||
@@ -71,10 +71,10 @@ tcpRecvWatchdog::expire ( const epicsTime & /* currentTime */ ) // X aCC 361
|
||||
}
|
||||
}
|
||||
|
||||
void tcpRecvWatchdog::beaconArrivalNotify ()
|
||||
void tcpRecvWatchdog::beaconArrivalNotify ( const epicsTime & currentTime )
|
||||
{
|
||||
if ( ! this->beaconAnomaly && ! this->responsePending ) {
|
||||
this->timer.start ( *this, this->period );
|
||||
this->timer.start ( *this, currentTime + this->period );
|
||||
debugPrintf ( ("Saw a normal beacon - reseting TCP recv watchdog\n") );
|
||||
}
|
||||
}
|
||||
@@ -92,11 +92,11 @@ void tcpRecvWatchdog::beaconAnomalyNotify ()
|
||||
debugPrintf ( ("Saw an abnormal beacon\n") );
|
||||
}
|
||||
|
||||
void tcpRecvWatchdog::messageArrivalNotify ()
|
||||
void tcpRecvWatchdog::messageArrivalNotify ( const epicsTime & currentTime )
|
||||
{
|
||||
this->beaconAnomaly = false;
|
||||
this->responsePending = false;
|
||||
this->timer.start ( *this, this->period );
|
||||
this->timer.start ( *this, currentTime + this->period );
|
||||
debugPrintf ( ("received a message - reseting TCP recv watchdog\n") );
|
||||
}
|
||||
|
||||
|
||||
@@ -33,12 +33,15 @@ class tcpiiu;
|
||||
|
||||
class tcpRecvWatchdog : private epicsTimerNotify {
|
||||
public:
|
||||
tcpRecvWatchdog ( cac &, tcpiiu &, double periodIn, epicsTimerQueue & );
|
||||
tcpRecvWatchdog ( cac &, tcpiiu &,
|
||||
double periodIn, epicsTimerQueue & );
|
||||
virtual ~tcpRecvWatchdog ();
|
||||
void rescheduleRecvTimer ();
|
||||
void sendBacklogProgressNotify ();
|
||||
void messageArrivalNotify ();
|
||||
void beaconArrivalNotify ();
|
||||
void messageArrivalNotify (
|
||||
const epicsTime & currentTime );
|
||||
void beaconArrivalNotify (
|
||||
const epicsTime & currentTime );
|
||||
void beaconAnomalyNotify ();
|
||||
void connectNotify ();
|
||||
void cancel ();
|
||||
|
||||
+11
-6
@@ -314,12 +314,14 @@ void tcpRecvThread::run ()
|
||||
continue;
|
||||
}
|
||||
|
||||
epicsTime currentTime = epicsTime::getCurrent ();
|
||||
|
||||
// reschedule connection activity watchdog
|
||||
// but dont hold the lock for fear of deadlocking
|
||||
// because cancel is blocking for the completion
|
||||
// of the recvDog expire which takes the lock
|
||||
// - it take also the callback lock
|
||||
this->iiu.recvDog.messageArrivalNotify ();
|
||||
this->iiu.recvDog.messageArrivalNotify ( currentTime );
|
||||
|
||||
this->iiu.cacRef.messageArrivalNotify ();
|
||||
|
||||
@@ -350,7 +352,7 @@ void tcpRecvThread::run ()
|
||||
pComBuf = new ( this->iiu.comBufMemMgr ) comBuf;
|
||||
|
||||
// execute receive labor
|
||||
bool protocolOK = this->iiu.processIncoming ( guard );
|
||||
bool protocolOK = this->iiu.processIncoming ( currentTime, guard );
|
||||
if ( ! protocolOK ) {
|
||||
this->iiu.cacRef.initiateAbortShutdown ( this->iiu );
|
||||
break;
|
||||
@@ -738,7 +740,8 @@ bool tcpiiu::setEchoRequestPending () // X aCC 361
|
||||
//
|
||||
// tcpiiu::processIncoming()
|
||||
//
|
||||
bool tcpiiu::processIncoming ( epicsGuard < callbackMutex > & guard )
|
||||
bool tcpiiu::processIncoming (
|
||||
const epicsTime & currentTime, epicsGuard < callbackMutex > & guard )
|
||||
{
|
||||
while ( true ) {
|
||||
|
||||
@@ -814,7 +817,7 @@ bool tcpiiu::processIncoming ( epicsGuard < callbackMutex > & guard )
|
||||
}
|
||||
}
|
||||
bool msgOK = this->cacRef.executeResponse ( guard, *this,
|
||||
this->curMsg, this->pCurData );
|
||||
currentTime, this->curMsg, this->pCurData );
|
||||
if ( ! msgOK ) {
|
||||
return false;
|
||||
}
|
||||
@@ -1255,10 +1258,12 @@ const char * tcpiiu::pHostName () const
|
||||
return nameBuf; // ouch !!
|
||||
}
|
||||
|
||||
void tcpiiu::removeAllChannels ( epicsGuard < callbackMutex > & cbGuard,
|
||||
void tcpiiu::removeAllChannels (
|
||||
epicsGuard < callbackMutex > & cbGuard,
|
||||
epicsGuard < cacMutex > & guard,
|
||||
cacDisconnectChannelPrivate & dcp )
|
||||
{
|
||||
epicsTime currentTime = epicsTime::getCurrent ();
|
||||
while ( nciu *pChan = this->channelList.first() ) {
|
||||
// if the claim reply has not returned then we will issue
|
||||
// the clear channel request to the server when the claim reply
|
||||
@@ -1266,7 +1271,7 @@ void tcpiiu::removeAllChannels ( epicsGuard < callbackMutex > & cbGuard,
|
||||
if ( pChan->connected() ) {
|
||||
this->clearChannelRequest ( guard, pChan->getSID(), pChan->getCID() );
|
||||
}
|
||||
dcp.disconnectChannel ( cbGuard, guard, *pChan );
|
||||
dcp.disconnectChannel ( currentTime, cbGuard, guard, *pChan );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-4
@@ -980,7 +980,7 @@ void udpiiu::repeaterConfirmNotify ()
|
||||
this->pRepeaterSubscribeTmr->confirmNotify ();
|
||||
}
|
||||
|
||||
void udpiiu::beaconAnomalyNotify ()
|
||||
void udpiiu::beaconAnomalyNotify ( const epicsTime & currentTime )
|
||||
{
|
||||
{
|
||||
epicsGuard <udpMutex> guard ( this->mutex );
|
||||
@@ -1010,7 +1010,7 @@ void udpiiu::beaconAnomalyNotify ()
|
||||
double delay = ( this->localPort & portBasedDelayMask );
|
||||
delay /= portTicksPerSec;
|
||||
|
||||
this->pSearchTmr->beaconAnomalyNotify ( delay );
|
||||
this->pSearchTmr->beaconAnomalyNotify ( currentTime, delay );
|
||||
}
|
||||
|
||||
bool udpiiu::searchMsg ( unsigned & retryNoForThisChannel )
|
||||
@@ -1035,7 +1035,7 @@ bool udpiiu::searchMsg ( unsigned & retryNoForThisChannel )
|
||||
return success;
|
||||
}
|
||||
|
||||
void udpiiu::installChannel ( nciu & chan )
|
||||
void udpiiu::installChannel ( const epicsTime & currentTime, nciu & chan )
|
||||
{
|
||||
bool firstChannel = false;
|
||||
|
||||
@@ -1047,7 +1047,7 @@ void udpiiu::installChannel ( nciu & chan )
|
||||
}
|
||||
}
|
||||
|
||||
this->pSearchTmr->newChannleNotify ( firstChannel );
|
||||
this->pSearchTmr->newChannleNotify ( currentTime, firstChannel );
|
||||
}
|
||||
|
||||
int udpiiu::printf ( const char *pformat, ... )
|
||||
|
||||
+4
-3
@@ -84,7 +84,7 @@ class udpiiu : public netiiu {
|
||||
public:
|
||||
udpiiu ( class epicsTimerQueueActive &, callbackMutex &, class cac & );
|
||||
virtual ~udpiiu ();
|
||||
void installChannel ( nciu & );
|
||||
void installChannel ( const epicsTime & currentTime, nciu & );
|
||||
void repeaterRegistrationMessage ( unsigned attemptNumber );
|
||||
bool searchMsg ( unsigned & retryNoForThisChannel );
|
||||
void datagramFlush ( const epicsTime & currentTime );
|
||||
@@ -92,11 +92,12 @@ public:
|
||||
void show ( unsigned level ) const;
|
||||
bool wakeupMsg ();
|
||||
void repeaterConfirmNotify ();
|
||||
void beaconAnomalyNotify ();
|
||||
void beaconAnomalyNotify ( const epicsTime & currentTime );
|
||||
int printf ( const char *pformat, ... );
|
||||
unsigned channelCount () const;
|
||||
void uninstallChan ( epicsGuard < cacMutex > &, nciu & );
|
||||
bool pushDatagramMsg ( const caHdr &hdr, const void *pExt, ca_uint16_t extsize);
|
||||
bool pushDatagramMsg ( const caHdr & hdr,
|
||||
const void * pExt, ca_uint16_t extsize);
|
||||
void shutdown ();
|
||||
double roundTripDelayEstimate () const;
|
||||
|
||||
|
||||
+11
-7
@@ -101,7 +101,8 @@ public:
|
||||
epicsGuard <cacMutex > & );
|
||||
void disconnectNotify ( epicsGuard <cacMutex > & );
|
||||
void beaconAnomalyNotify ();
|
||||
void beaconArrivalNotify ();
|
||||
void beaconArrivalNotify (
|
||||
const epicsTime & currentTime );
|
||||
|
||||
void flushRequest ();
|
||||
bool flushBlockThreshold ( epicsGuard < cacMutex > & ) const;
|
||||
@@ -125,9 +126,10 @@ public:
|
||||
osiSockAddr getNetworkAddress () const;
|
||||
int printf ( const char *pformat, ... );
|
||||
unsigned channelCount ();
|
||||
void removeAllChannels ( epicsGuard < callbackMutex > & cbGuard,
|
||||
epicsGuard < cacMutex > & guard,
|
||||
class cacDisconnectChannelPrivate & );
|
||||
void removeAllChannels (
|
||||
epicsGuard < callbackMutex > & cbGuard,
|
||||
epicsGuard < cacMutex > & guard,
|
||||
class cacDisconnectChannelPrivate & );
|
||||
void installChannel ( epicsGuard < cacMutex > &, nciu & chan,
|
||||
unsigned sidIn, ca_uint16_t typeIn, arrayElementCount countIn );
|
||||
void uninstallChan ( epicsGuard < cacMutex > &, nciu & chan );
|
||||
@@ -173,7 +175,8 @@ private:
|
||||
bool recvProcessPostponedFlush;
|
||||
bool discardingPendingData;
|
||||
|
||||
bool processIncoming ( epicsGuard < callbackMutex > & );
|
||||
bool processIncoming (
|
||||
const epicsTime & currentTime, epicsGuard < callbackMutex > & );
|
||||
unsigned sendBytes ( const void *pBuf, unsigned nBytesInBuf );
|
||||
unsigned recvBytes ( void *pBuf, unsigned nBytesInBuf );
|
||||
void connect ();
|
||||
@@ -229,9 +232,10 @@ inline void tcpiiu::beaconAnomalyNotify ()
|
||||
this->recvDog.beaconAnomalyNotify ();
|
||||
}
|
||||
|
||||
inline void tcpiiu::beaconArrivalNotify ()
|
||||
inline void tcpiiu::beaconArrivalNotify (
|
||||
const epicsTime & currentTime )
|
||||
{
|
||||
this->recvDog.beaconArrivalNotify ();
|
||||
this->recvDog.beaconArrivalNotify ( currentTime );
|
||||
}
|
||||
|
||||
inline void tcpiiu::flushIfRecvProcessRequested ()
|
||||
|
||||
Reference in New Issue
Block a user