20 #define epicsAssertAuthor "Jeff Hill johill@lanl.gov" 32 double periodIn, epicsTimerQueue & queueIn ) :
33 period ( periodIn ),
timer ( queueIn.createTimer () ),
34 cbMutex ( cbMutexIn ), ctxNotify ( ctxNotifyIn ),
35 mutex ( mutexIn ), iiu ( iiuIn ),
36 probeResponsePending (
false ), beaconAnomaly (
true ),
37 probeTimeoutDetected (
false ), shuttingDown (
false )
46 epicsTimerNotify::expireStatus
47 tcpRecvWatchdog::expire (
const epicsTime & )
50 if ( this->shuttingDown ) {
53 if ( this->probeResponsePending ) {
55 return expireStatus ( restart, CA_ECHO_TIMEOUT );
61 this->iiu.
getHostName ( guard, hostName,
sizeof (hostName) );
62 debugPrintf ( (
"CA server \"%s\" unresponsive after %g inactive sec" 64 hostName, this->period ) );
77 this->probeTimeoutDetected =
true;
84 return expireStatus ( restart, this->period );
86 this->probeTimeoutDetected =
false;
88 debugPrintf ( (
"circuit timed out - sending echo request\n") );
89 return expireStatus ( restart, CA_ECHO_TIMEOUT );
97 if ( ! ( this->shuttingDown || this->beaconAnomaly || this->probeResponsePending ) ) {
99 debugPrintf ( (
"saw a normal beacon - reseting circuit receive watchdog\n") );
114 this->beaconAnomaly =
true;
123 if ( ! ( this->shuttingDown || this->probeResponsePending ) ) {
124 this->beaconAnomaly =
false;
126 debugPrintf ( (
"received a message - reseting circuit recv watchdog\n") );
133 bool restartNeeded =
false;
134 double restartDelay = DBL_MAX;
137 if ( this->probeResponsePending && ! this->shuttingDown ) {
138 restartNeeded =
true;
139 if ( this->probeTimeoutDetected ) {
140 this->probeTimeoutDetected =
false;
142 restartDelay = CA_ECHO_TIMEOUT;
143 debugPrintf ( (
"late probe response - sending another probe request\n") );
146 this->probeResponsePending =
false;
147 restartDelay = this->period;
149 debugPrintf ( (
"probe response on time - circuit was tagged reponsive if unresponsive\n") );
153 if ( restartNeeded ) {
155 debugPrintf ( (
"recv wd restarted with delay %f\n", restartDelay) );
182 if ( this->probeResponsePending && ! this->shuttingDown ) {
184 debugPrintf ( (
"saw heavy send backlog - reseting circuit recv watchdog\n") );
192 if ( this->shuttingDown ) {
196 debugPrintf ( (
"connected to the server - initiating circuit recv watchdog\n") );
205 bool restartNeeded =
false;
206 if ( ! ( this->probeResponsePending || this->shuttingDown ) ) {
208 restartNeeded =
true;
210 if ( restartNeeded ) {
213 debugPrintf ( (
"TCP send timed out - sending echo request\n") );
226 this->shuttingDown =
true;
234 return this->
timer.getExpireDelay ();
241 ::printf (
"Receive virtual circuit watchdog at %p, period %f\n",
242 static_cast <const void *> (
this ), this->period );
245 this->probeResponsePending ?
"probe-response-pending" :
"",
246 this->beaconAnomaly ?
"beacon-anomaly-detected" :
"",
247 this->probeTimeoutDetected ?
"probe-response-timeout" :
"" );
void sendTimeoutNotify(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
virtual ~tcpRecvWatchdog()
void assertIdenticalMutex(const T &) const
void receiveTimeoutNotify(callbackManager &, epicsGuard< epicsMutex > &)
void sendBacklogProgressNotify(epicsGuard< epicsMutex > &)
void responsiveCircuitNotify(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
void probeResponseNotify(epicsGuard< epicsMutex > &)
void show(unsigned level) const
void connectNotify(epicsGuard< epicsMutex > &)
void beaconAnomalyNotify(epicsGuard< epicsMutex > &)
void messageArrivalNotify(epicsGuard< epicsMutex > &guard)
bool receiveThreadIsBusy(epicsGuard< epicsMutex > &)
#define debugPrintf(argsInParen)
void beaconArrivalNotify(epicsGuard< epicsMutex > &)
tcpRecvWatchdog(epicsMutex &cbMutex, cacContextNotify &ctxNotify, epicsMutex &mutex, tcpiiu &, double periodIn, epicsTimerQueue &)
unsigned getHostName(epicsGuard< epicsMutex > &, char *pBuf, unsigned bufLength) const
void start(class epicsTimerNotify &, const epicsTime &)
bool setEchoRequestPending(epicsGuard< epicsMutex > &)