From 168c9c550302cff2b68b692ef808f71a1b86d947 Mon Sep 17 00:00:00 2001 From: Jeff Hill Date: Wed, 5 Feb 2003 22:08:54 +0000 Subject: [PATCH] added beacon anomaly count diagnostic --- src/ca/access.cpp | 17 ++++++++-- src/ca/acctst.c | 62 ++++++++++-------------------------- src/ca/ca_client_context.cpp | 6 ++-- src/ca/cac.cpp | 4 +++ src/ca/cac.h | 7 ++++ src/ca/cadef.h | 5 +-- src/ca/oldAccess.h | 6 ++++ 7 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/ca/access.cpp b/src/ca/access.cpp index 785916253..7f53a2ccf 100644 --- a/src/ca/access.cpp +++ b/src/ca/access.cpp @@ -1079,15 +1079,26 @@ double epicsShareAPI ca_beacon_period ( chid pChan ) // extern "C" unsigned epicsShareAPI ca_get_ioc_connection_count () { - ca_client_context *pcac; - int caStatus = fetchClientContext ( &pcac ); + ca_client_context * pcac; + int caStatus = fetchClientContext ( & pcac ); if ( caStatus != ECA_NORMAL ) { - return caStatus; + return 0u; } return pcac->connectionCount (); } +unsigned epicsShareAPI ca_beacon_anomaly_count () +{ + ca_client_context * pcac; + int caStatus = fetchClientContext ( & pcac ); + if ( caStatus != ECA_NORMAL ) { + return 0u; + } + + return pcac->beaconAnomaliesSinceProgramStart (); +} + // extern "C" int epicsShareAPI ca_channel_status ( epicsThreadId /* tid */ ) { diff --git a/src/ca/acctst.c b/src/ca/acctst.c index f720cdea6..b7cbd8aa0 100644 --- a/src/ca/acctst.c +++ b/src/ca/acctst.c @@ -1978,21 +1978,16 @@ void pend_event_delay_test ( dbr_double_t request ) assert ( fabs(accuracy) < 10.0 ); } -void caTaskExistTest () +void caTaskExistTest ( unsigned interestLevel ) { int status; - epicsTimeStamp end_time; - epicsTimeStamp start_time; - dbr_double_t delay; + showProgressBegin ( "caTaskExistTest", interestLevel ); - epicsTimeGetCurrent ( &start_time ); - printf ( "entering ca_task_exit()\n" ); status = ca_task_exit (); SEVCHK ( status, NULL ); - epicsTimeGetCurrent ( &end_time ); - delay = epicsTimeDiffInSeconds ( &end_time, &start_time ); - printf ( "in ca_task_exit() for %f sec\n", delay ); + + showProgressEnd ( interestLevel ); } void verifyDataTypeMacros () @@ -2221,43 +2216,20 @@ void monitorUpdateTest ( chid chan, unsigned interestLevel ) void verifyReasonableBeaconPeriod ( chid chan ) { - if ( ca_get_ioc_connection_count () > 0 ) { - double beaconPeriod, expectedBeaconPeriod, error, percentError; - unsigned attempts = 0u; + double beaconPeriod; + unsigned attempts = 0u; + int status; - int status; - if ( envGetConfigParamPtr ( & EPICS_CAS_BEACON_PERIOD ) ) { - status = envGetDoubleConfigParam ( & EPICS_CAS_BEACON_PERIOD, - & expectedBeaconPeriod ); - } - else { - status = envGetDoubleConfigParam ( & EPICS_CA_BEACON_PERIOD, - & expectedBeaconPeriod ); - } - assert ( status >=0 ); - - while ( 1 ) { - static const unsigned maxAttempts = 10u; - const double delay = ( expectedBeaconPeriod * 4 ) / maxAttempts; + assert ( ca_get_ioc_connection_count () > 0 ); - beaconPeriod = ca_beacon_period ( chan ); - if ( beaconPeriod >= 0.0 ) { - error = beaconPeriod - expectedBeaconPeriod; - percentError = fabs ( error ) / expectedBeaconPeriod; - if ( percentError < 0.1 ) { - break; - } - printf ( "Beacon period error estimate = %f sec.\n", error ); - } - else { - printf ( "Beacon period unavailable\n" ); - } - assert ( attempts++ < maxAttempts ); - printf ( "Waiting for a better beacon period estimate result (%f sec).\n", - attempts * delay ); - ca_pend_event ( delay ); - } - } + printf ( "Beacon anomalies detected since program start %u\n", + ca_beacon_anomaly_count () ); + + beaconPeriod = ca_beacon_period ( chan ); + assert ( beaconPeriod >= 0.0 ); + + printf ( "Estimated beacon period for channel %s = %f sec.\n", + ca_name ( chan ), beaconPeriod ); } void verifyOldPend ( unsigned interestLevel) @@ -2538,7 +2510,7 @@ int acctst ( char *pName, unsigned interestLevel, unsigned channelCount, /* status = ca_clear_channel ( chan ); */ /* SEVCHK ( status, NULL ); */ - caTaskExistTest (); + caTaskExistTest ( interestLevel ); free ( pChans ); diff --git a/src/ca/ca_client_context.cpp b/src/ca/ca_client_context.cpp index f806ce36f..52d47e4a5 100644 --- a/src/ca/ca_client_context.cpp +++ b/src/ca/ca_client_context.cpp @@ -230,8 +230,9 @@ void ca_client_context::fdWasDestroyed ( int fd ) void ca_client_context::show ( unsigned level ) const { - ::printf ( "ca_client_context at %p\n", - static_cast ( this ) ); + ::printf ( "ca_client_context at %p pndRecvCnt=%u ioSeqNo=%u\n", + static_cast ( this ), + this->pndRecvCnt, this->ioSeqNo ); if ( level > 0u ) { this->mutex.show ( level - 1u ); this->clientCtx.show ( level - 1u ); @@ -243,7 +244,6 @@ void ca_client_context::show ( unsigned level ) const this->ioSeqNo ); ::printf ( "IO done event:\n"); this->ioDone.show ( level - 1u ); - } } diff --git a/src/ca/cac.cpp b/src/ca/cac.cpp index 9fa6374b1..cf4bde88c 100644 --- a/src/ca/cac.cpp +++ b/src/ca/cac.cpp @@ -149,6 +149,8 @@ cac::cac ( cacNotify & notifyIn, bool enablePreemptiveCallbackIn ) : initializingThreadsId ( epicsThreadGetIdSelf() ), initializingThreadsPriority ( epicsThreadGetPrioritySelf() ), maxRecvBytesTCP ( MAX_TCP ), + nRecvThreadsPending ( 0u ), + beaconAnomalyCount ( 0u ), preemptiveCallbackEnabled ( enablePreemptiveCallbackIn ) { if ( ! osiSockAttach () ) { @@ -427,6 +429,8 @@ void cac::beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime, return; } + this->beaconAnomalyCount++; + this->pudpiiu->beaconAnomalyNotify (); # if DEBUG diff --git a/src/ca/cac.h b/src/ca/cac.h index d1becde71..805204f63 100644 --- a/src/ca/cac.h +++ b/src/ca/cac.h @@ -118,6 +118,7 @@ public: void beaconNotify ( const inetAddrID & addr, const epicsTime & currentTime, ca_uint32_t beaconNumber, unsigned protocolRevision ); void repeaterSubscribeConfirmNotify (); + unsigned beaconAnomaliesSinceProgramStart () const; // IO management void flushRequest (); @@ -254,6 +255,7 @@ private: unsigned initializingThreadsPriority; unsigned maxRecvBytesTCP; unsigned nRecvThreadsPending; + unsigned beaconAnomalyCount; bool preemptiveCallbackEnabled; void privateUninstallIIU ( epicsGuard < callbackMutex > &, tcpiiu &iiu ); @@ -404,6 +406,11 @@ inline bool cac::preemptiveCallbakIsEnabled () const return this->preemptiveCallbackEnabled; } +inline unsigned cac::beaconAnomaliesSinceProgramStart () const +{ + return this->beaconAnomalyCount; +} + inline epicsGuard < callbackMutex > cac::callbackGuardFactory () { // facilitate the return value optimization diff --git a/src/ca/cadef.h b/src/ca/cadef.h index 165f91fe0..ab48d2441 100644 --- a/src/ca/cadef.h +++ b/src/ca/cadef.h @@ -930,9 +930,11 @@ epicsShareFunc int epicsShareAPI ca_replace_printf_handler ( * (for testing purposes only) */ epicsShareFunc unsigned epicsShareAPI ca_get_ioc_connection_count (void); +epicsShareFunc int epicsShareAPI ca_preemtive_callback_is_enabled (void); +epicsShareFunc void epicsShareAPI ca_self_test (void); +epicsShareFunc unsigned epicsShareAPI ca_beacon_anomaly_count (void); epicsShareFunc unsigned epicsShareAPI ca_search_attempts (chid chan); epicsShareFunc double epicsShareAPI ca_beacon_period (chid chan); -epicsShareFunc int epicsShareAPI ca_preemtive_callback_is_enabled (); /* * used when an auxillary thread needs to join a CA client context started @@ -945,7 +947,6 @@ epicsShareFunc int epicsShareAPI ca_attach_context ( struct ca_client_context * epicsShareFunc int epicsShareAPI ca_client_status ( unsigned level ); epicsShareFunc int epicsShareAPI ca_context_status ( struct ca_client_context *, unsigned level ); -epicsShareFunc void epicsShareAPI ca_self_test (); /* * deprecated diff --git a/src/ca/oldAccess.h b/src/ca/oldAccess.h index e751eef40..c71c41111 100644 --- a/src/ca/oldAccess.h +++ b/src/ca/oldAccess.h @@ -242,6 +242,7 @@ public: void show ( unsigned level ) const; unsigned connectionCount () const; unsigned sequenceNumberOfOutstandingIO () const; + unsigned beaconAnomaliesSinceProgramStart () const; void incrementOutstandingIO ( unsigned ioSeqNo ); void decrementOutstandingIO ( unsigned ioSeqNo ); void exception ( int status, const char *pContext, @@ -536,6 +537,11 @@ inline unsigned ca_client_context::connectionCount () const return this->clientCtx.connectionCount (); } +inline unsigned ca_client_context::beaconAnomaliesSinceProgramStart () const +{ + return this->clientCtx.beaconAnomaliesSinceProgramStart (); +} + inline CASG * ca_client_context::lookupCASG ( unsigned id ) { return this->clientCtx.lookupCASG ( id );