This is Unofficial EPICS BASE Doxygen Site
tcpRecvWatchdog Class Reference

#include "tcpRecvWatchdog.h"

+ Inheritance diagram for tcpRecvWatchdog:
+ Collaboration diagram for tcpRecvWatchdog:

Public Member Functions

 tcpRecvWatchdog (epicsMutex &cbMutex, cacContextNotify &ctxNotify, epicsMutex &mutex, tcpiiu &, double periodIn, epicsTimerQueue &)
 
virtual ~tcpRecvWatchdog ()
 
void sendBacklogProgressNotify (epicsGuard< epicsMutex > &)
 
void messageArrivalNotify (epicsGuard< epicsMutex > &guard)
 
void probeResponseNotify (epicsGuard< epicsMutex > &)
 
void beaconArrivalNotify (epicsGuard< epicsMutex > &)
 
void beaconAnomalyNotify (epicsGuard< epicsMutex > &)
 
void connectNotify (epicsGuard< epicsMutex > &)
 
void sendTimeoutNotify (epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
 
void cancel ()
 
void shutdown ()
 
void show (unsigned level) const
 
double delay () const
 

Detailed Description

Definition at line 34 of file tcpRecvWatchdog.h.

Constructor & Destructor Documentation

tcpRecvWatchdog::tcpRecvWatchdog ( epicsMutex &  cbMutex,
cacContextNotify ctxNotify,
epicsMutex &  mutex,
tcpiiu iiuIn,
double  periodIn,
epicsTimerQueue &  queueIn 
)

Definition at line 30 of file tcpRecvWatchdog.cpp.

32  :
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 )
38 {
39 }
tcpRecvWatchdog::~tcpRecvWatchdog ( )
virtual

Definition at line 41 of file tcpRecvWatchdog.cpp.

42 {
43  this->timer.destroy ();
44 }
void destroy()
Definition: timer.cpp:47

Member Function Documentation

void tcpRecvWatchdog::beaconAnomalyNotify ( epicsGuard< epicsMutex > &  guard)

Definition at line 110 of file tcpRecvWatchdog.cpp.

112 {
113  guard.assertIdenticalMutex ( this->mutex );
114  this->beaconAnomaly = true;
115  debugPrintf ( ("Saw an abnormal beacon\n") );
116 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void tcpRecvWatchdog::beaconArrivalNotify ( epicsGuard< epicsMutex > &  guard)

Definition at line 93 of file tcpRecvWatchdog.cpp.

95 {
96  guard.assertIdenticalMutex ( this->mutex );
97  if ( ! ( this->shuttingDown || this->beaconAnomaly || this->probeResponsePending ) ) {
98  this->timer.start ( *this, this->period );
99  debugPrintf ( ("saw a normal beacon - reseting circuit receive watchdog\n") );
100  }
101 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
void tcpRecvWatchdog::cancel ( )

Definition at line 216 of file tcpRecvWatchdog.cpp.

217 {
218  this->timer.cancel ();
219  debugPrintf ( ("canceling TCP recv watchdog\n") );
220 }
void cancel()
Definition: timer.cpp:135
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void tcpRecvWatchdog::connectNotify ( epicsGuard< epicsMutex > &  guard)

Definition at line 188 of file tcpRecvWatchdog.cpp.

190 {
191  guard.assertIdenticalMutex ( this->mutex );
192  if ( this->shuttingDown ) {
193  return;
194  }
195  this->timer.start ( *this, this->period );
196  debugPrintf ( ("connected to the server - initiating circuit recv watchdog\n") );
197 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
double tcpRecvWatchdog::delay ( ) const

Definition at line 232 of file tcpRecvWatchdog.cpp.

233 {
234  return this->timer.getExpireDelay ();
235 }
void tcpRecvWatchdog::messageArrivalNotify ( epicsGuard< epicsMutex > &  guard)

Definition at line 118 of file tcpRecvWatchdog.cpp.

120 {
121  guard.assertIdenticalMutex ( this->mutex );
122 
123  if ( ! ( this->shuttingDown || this->probeResponsePending ) ) {
124  this->beaconAnomaly = false;
125  this->timer.start ( *this, this->period );
126  debugPrintf ( ("received a message - reseting circuit recv watchdog\n") );
127  }
128 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
void tcpRecvWatchdog::probeResponseNotify ( epicsGuard< epicsMutex > &  cbGuard)

Definition at line 130 of file tcpRecvWatchdog.cpp.

132 {
133  bool restartNeeded = false;
134  double restartDelay = DBL_MAX;
135  {
136  epicsGuard < epicsMutex > guard ( this->mutex );
137  if ( this->probeResponsePending && ! this->shuttingDown ) {
138  restartNeeded = true;
139  if ( this->probeTimeoutDetected ) {
140  this->probeTimeoutDetected = false;
141  this->probeResponsePending = this->iiu.setEchoRequestPending ( guard );
142  restartDelay = CA_ECHO_TIMEOUT;
143  debugPrintf ( ("late probe response - sending another probe request\n") );
144  }
145  else {
146  this->probeResponsePending = false;
147  restartDelay = this->period;
148  this->iiu.responsiveCircuitNotify ( cbGuard, guard );
149  debugPrintf ( ("probe response on time - circuit was tagged reponsive if unresponsive\n") );
150  }
151  }
152  }
153  if ( restartNeeded ) {
154  this->timer.start ( *this, restartDelay );
155  debugPrintf ( ("recv wd restarted with delay %f\n", restartDelay) );
156  }
157 }
void responsiveCircuitNotify(epicsGuard< epicsMutex > &cbGuard, epicsGuard< epicsMutex > &guard)
Definition: tcpiiu.cpp:860
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
bool setEchoRequestPending(epicsGuard< epicsMutex > &)
Definition: tcpiiu.cpp:1121
void tcpRecvWatchdog::sendBacklogProgressNotify ( epicsGuard< epicsMutex > &  guard)

Definition at line 173 of file tcpRecvWatchdog.cpp.

175 {
176  guard.assertIdenticalMutex ( this->mutex );
177 
178  // We dont set "beaconAnomaly" to be false here because, after we see a
179  // beacon anomaly (which could be transiently detecting a reboot) we will
180  // not trust the beacon as an indicator of a healthy server until we
181  // receive at least one message from the server.
182  if ( this->probeResponsePending && ! this->shuttingDown ) {
183  this->timer.start ( *this, CA_ECHO_TIMEOUT );
184  debugPrintf ( ("saw heavy send backlog - reseting circuit recv watchdog\n") );
185  }
186 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
void tcpRecvWatchdog::sendTimeoutNotify ( epicsGuard< epicsMutex > &  cbGuard,
epicsGuard< epicsMutex > &  guard 
)

Definition at line 199 of file tcpRecvWatchdog.cpp.

202 {
203  guard.assertIdenticalMutex ( this->mutex );
204 
205  bool restartNeeded = false;
206  if ( ! ( this->probeResponsePending || this->shuttingDown ) ) {
207  this->probeResponsePending = this->iiu.setEchoRequestPending ( guard );
208  restartNeeded = true;
209  }
210  if ( restartNeeded ) {
211  this->timer.start ( *this, CA_ECHO_TIMEOUT );
212  }
213  debugPrintf ( ("TCP send timed out - sending echo request\n") );
214 }
void assertIdenticalMutex(const T &) const
Definition: epicsGuard.h:80
#define debugPrintf(argsInParen)
Definition: iocinf.h:30
void start(class epicsTimerNotify &, const epicsTime &)
Definition: timer.cpp:59
bool setEchoRequestPending(epicsGuard< epicsMutex > &)
Definition: tcpiiu.cpp:1121
void tcpRecvWatchdog::show ( unsigned  level) const

Definition at line 237 of file tcpRecvWatchdog.cpp.

238 {
239  epicsGuard < epicsMutex > guard ( this->mutex );
240 
241  ::printf ( "Receive virtual circuit watchdog at %p, period %f\n",
242  static_cast <const void *> ( this ), this->period );
243  if ( level > 0u ) {
244  ::printf ( "\t%s %s %s\n",
245  this->probeResponsePending ? "probe-response-pending" : "",
246  this->beaconAnomaly ? "beacon-anomaly-detected" : "",
247  this->probeTimeoutDetected ? "probe-response-timeout" : "" );
248  }
249 }
#define printf
Definition: epicsStdio.h:41
void tcpRecvWatchdog::shutdown ( )

Definition at line 222 of file tcpRecvWatchdog.cpp.

223 {
224  {
225  epicsGuard < epicsMutex > guard ( this->mutex );
226  this->shuttingDown = true;
227  }
228  this->timer.cancel ();
229  debugPrintf ( ("canceling TCP recv watchdog\n") );
230 }
void cancel()
Definition: timer.cpp:135
#define debugPrintf(argsInParen)
Definition: iocinf.h:30

The documentation for this class was generated from the following files: