From 773c12becce4f055f633b321a1c8a86dc1db3a7b Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Thu, 3 Jul 2003 15:07:51 +0000 Subject: [PATCH] improved disconnect search interval --- src/ca/cac.cpp | 4 ++-- src/ca/nciu.cpp | 2 +- src/ca/searchTimer.cpp | 8 +++++--- src/ca/searchTimer.h | 3 ++- src/ca/udpiiu.cpp | 8 +++++--- src/ca/udpiiu.h | 22 ++++++++++++++++++---- 6 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index b5259ad7d..6e92d2a37 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -1407,7 +1407,7 @@ void cac::disconnectChannel ( this->disconnectAllIO ( guard, chan, true ); chan.getPIIU()->uninstallChan ( guard, chan ); chan.disconnect ( *this->pudpiiu ); - this->pudpiiu->installChannel ( currentTime, chan ); + this->pudpiiu->installDisconnectedChannel ( currentTime, chan ); epicsGuardRelease < cacMutex > autoMutexRelease ( guard ); chan.connectStateNotify ( cbGuard ); chan.accessRightsNotify ( cbGuard ); @@ -1575,7 +1575,7 @@ double cac::beaconPeriod ( const nciu & chan ) const void cac::initiateConnect ( nciu & chan ) { assert ( this->pudpiiu ); - this->pudpiiu->installChannel ( + this->pudpiiu->installNewChannel ( epicsTime::getCurrent(), chan ); } diff --git a/src/ca/nciu.cpp b/src/ca/nciu.cpp index 93442ff89..4c7df82d6 100644 --- a/src/ca/nciu.cpp +++ b/src/ca/nciu.cpp @@ -149,7 +149,7 @@ void nciu::connect ( unsigned nativeType, void nciu::disconnect ( netiiu & newiiu ) { this->piiu = & newiiu; - this->retry = 0u; + this->retry = disconnectRetrySetpoint; this->typeCode = USHRT_MAX; this->count = 0u; this->sid = UINT_MAX; diff --git a/src/ca/searchTimer.cpp b/src/ca/searchTimer.cpp index 5600e2fea..ebd3e6ce6 100644 --- a/src/ca/searchTimer.cpp +++ b/src/ca/searchTimer.cpp @@ -67,10 +67,11 @@ searchTimer::~searchTimer () } void searchTimer::newChannelNotify ( - epicsGuard < udpMutex > & guard, const epicsTime & currentTime, bool firstChannel ) + epicsGuard < udpMutex > & guard, const epicsTime & currentTime, + bool firstChannel, unsigned minRetryNo ) { if ( firstChannel ) { - this->recomputeTimerPeriod ( guard, 0 ); + this->recomputeTimerPeriod ( guard, minRetryNo ); double newPeriod = this->period; { // avoid timer cancel block deadlock @@ -79,7 +80,8 @@ void searchTimer::newChannelNotify ( } } else { - this->recomputeTimerPeriodAndStartTimer ( guard, currentTime, 0, 0.0 ); + this->recomputeTimerPeriodAndStartTimer ( guard, + currentTime, minRetryNo, 0.0 ); } } diff --git a/src/ca/searchTimer.h b/src/ca/searchTimer.h index cea0132f8..01d3be8f7 100644 --- a/src/ca/searchTimer.h +++ b/src/ca/searchTimer.h @@ -53,7 +53,8 @@ public: ca_uint32_t respDatagramSeqNo, bool seqNumberIsValid, const epicsTime & currentTime ); void newChannelNotify ( epicsGuard < udpMutex > &, - const epicsTime & currentTime, bool firstChannel ); + const epicsTime &, bool firstChannel, + unsigned minRetryNo ); void beaconAnomalyNotify ( epicsGuard < udpMutex > &, const epicsTime & currentTime, const double & delay ); void show ( unsigned level ) const; diff --git a/src/ca/udpiiu.cpp b/src/ca/udpiiu.cpp index da28b51aa..46fe71417 100644 --- a/src/ca/udpiiu.cpp +++ b/src/ca/udpiiu.cpp @@ -1044,11 +1044,12 @@ bool udpiiu::searchMsg ( epicsGuard < udpMutex > & /* guard */, return success; } -void udpiiu::installChannel ( const epicsTime & currentTime, nciu & chan ) +void installChannel ( const epicsTime & currentTime, + nciu & chan, unsigned minRetryNo ) { bool firstChannel = false; - epicsGuard < udpMutex> guard ( this->mutex ); + epicsGuard < udpMutex > guard ( this->mutex ); // add it to the front of the list so that // a search request is sent immediately, and // so that the new channel's retry count is @@ -1058,7 +1059,8 @@ void udpiiu::installChannel ( const epicsTime & currentTime, nciu & chan ) if ( this->channelList.count() == 1 ) { firstChannel = true; } - this->pSearchTmr->newChannelNotify ( guard, currentTime, firstChannel ); + this->pSearchTmr->newChannelNotify ( guard, currentTime, + firstChannel, minRetryNo ); } int udpiiu::printf ( const char *pformat, ... ) diff --git a/src/ca/udpiiu.h b/src/ca/udpiiu.h index c2ad01861..2357d5d24 100644 --- a/src/ca/udpiiu.h +++ b/src/ca/udpiiu.h @@ -84,7 +84,8 @@ class udpiiu : public netiiu { public: udpiiu ( class epicsTimerQueueActive &, callbackMutex &, class cac & ); virtual ~udpiiu (); - void installChannel ( const epicsTime & currentTime, nciu & ); + void installNewChannel ( const epicsTime & currentTime, nciu & ); + void installDisconnectedChannel ( const epicsTime & currentTime, nciu & ); void repeaterRegistrationMessage ( unsigned attemptNumber ); bool searchMsg ( epicsGuard < udpMutex > &, unsigned & retryNoForThisChannel ); void datagramFlush ( epicsGuard < udpMutex > &, const epicsTime & currentTime ); @@ -183,6 +184,7 @@ private: void requestRecvProcessPostponedFlush (); osiSockAddr getNetworkAddress () const; double receiveWatchdogDelay () const; + void installChannel ( const epicsTime & currentTime, nciu &, unsigned minRetryNo ); udpiiu ( const udpiiu & ); udpiiu & operator = ( const udpiiu & ); @@ -190,9 +192,11 @@ private: // This impacts the exponential backoff delay between search messages. // This delay is two to the power of the minimum channel retry count -// times the estimated round trip time. So this results in about a -// one second delay. -static const unsigned beaconAnomalyRetrySetpoint = 10u; +// times the estimated round trip time or the OS's delay quantum +// whichever is greater. So this results in about a one second delay. +// +static const unsigned beaconAnomalyRetrySetpoint = 6u; +static const unsigned disconnectRetrySetpoint = 6u; inline void udpMutex::lock () { @@ -227,5 +231,15 @@ inline double udpiiu::roundTripDelayEstimate ( return this->rtteMean; } +inline void udpiiu::installNewChannel ( const epicsTime & currentTime, nciu & chan ) +{ + this->installChannel ( currentTime, chan, 0 ); +} + +inline void udpiiu::installDisconnectedChannel ( const epicsTime & currentTime, nciu & chan ) +{ + this->installChannel ( currentTime, chan, disconnectRetrySetpoint ); +} + #endif // udpiiuh