The Assimilation Project  based on Assimilation version 0.5.1427325140
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
HbListener class.

Class for heartbeat Listeners - We listen for heartbeats and time out those which are late. More...

Collaboration diagram for HbListener class.:

Data Structures

struct  _HbListener
 This is the base HbListener class. object - which listens for heartbeats from a particular sender. More...
 

Macros

#define ONESEC   1000000
 

Functions

FSTATIC void _hblistener_addlist (HbListener *self)
 Add an HbListener to our global list of HBListeners, and unref (and neuter) any old HbListeners listening to this same address. More...
 
FSTATIC void _hblistener_dellist (HbListener *self)
 Remove an HbListener from our global list of HBListeners. More...
 
HbListenerhblistener_find_by_address (const NetAddr *which)
 Find the listener that's listening to a particular address. More...
 
FSTATIC void _hblistener_checktimeouts (gboolean urgent)
 Function called when it's time to see if anyone timed out... More...
 
FSTATIC gboolean _hblistener_gsourcefunc (gpointer ignored)
 A GSourceFunc to be used with g_timeout_add_seconds() More...
 
FSTATIC gboolean _hblistener_got_frameset (Listener *self,FrameSet *fs,NetAddr *srcaddr)
 Function called when a heartbeat FrameSet class (fs) arrived from the given NetAddr class (srcaddr) More...
 
FSTATIC void _hblistener_notify_function (gpointer ignored)
 We get called when our gSource gets removed. This function is probably unnecessary... More...
 
FSTATIC void hblistener_shutdown (void)
 Shuts down all our hblisteners... More...
 
FSTATIC void _hblistener_finalize (AssimObj *self)
 Finalize an HbListener. More...
 
HbListenerhblistener_new (NetAddr *listenaddr, ConfigContext *cfg, gsize objsize)
 Construct a new HbListener - setting up GSource and timeout data structures for it. More...
 
FSTATIC void _hblistener_set_deadtime (HbListener *self,guint64 deadtime)
 Set deadtime. More...
 
FSTATIC guint64 _hblistener_get_deadtime (HbListener *self)
 Return deadtime. More...
 
FSTATIC void _hblistener_set_warntime (HbListener *self,guint64 warntime)
 Set warntime. More...
 
FSTATIC guint64 _hblistener_get_warntime (HbListener *self)
 Return warntime. More...
 
FSTATIC void hblistener_unlisten (NetAddr *unlistenaddr)
 Stop expecting (listening for) heartbeats from a particular address. More...
 
FSTATIC void _hblistener_set_deadtime_callback (HbListener *self, void(*callback)(HbListener *who))
 Call to set a callback to be called when a node apparently dies. More...
 
FSTATIC void _hblistener_set_heartbeat_callback (HbListener *self, void(*callback)(HbListener *who))
 Call to set a callback to be called when a heartbeat is received. More...
 
FSTATIC void _hblistener_set_warntime_callback (HbListener *self, void(*callback)(HbListener *who, guint64 howlate))
 Call to set a callback to be called when a node passes warntime before heartbeating again. More...
 
FSTATIC void _hblistener_set_comealive_callback (HbListener *self, void(*callback)(HbListener *who, guint64 howlate))
 Call to set a callback to be called when a node passes deadtime but heartbeats again. More...
 
FSTATIC void hblistener_set_martian_callback (void(*callback)(NetAddr *who))
 Call to set a callback to be called when an unrecognized node sends us a heartbeat. More...
 

Detailed Description

Class for heartbeat Listeners - We listen for heartbeats and time out those which are late.

Macro Definition Documentation

#define ONESEC   1000000

Definition at line 62 of file hblistener.c.

Referenced by _hblistener_checktimeouts().

Function Documentation

FSTATIC void _hblistener_addlist ( HbListener self)

Add an HbListener to our global list of HBListeners, and unref (and neuter) any old HbListeners listening to this same address.

Todo:
start listening for packets...
Parameters
[in]selfThe listener to add

Definition at line 67 of file hblistener.c.

References _hblistener_dellist(), _hblistener_gsourcefunc(), _hblistener_notify_function(), hblistener_find_by_address(), and REF2.

Referenced by hblistener_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_checktimeouts ( gboolean  urgent)

Function called when it's time to see if anyone timed out...

Parameters
[in]urgentTrue if you want it checked now anyway...

Definition at line 111 of file hblistener.c.

References __FUNCTION__, _HbListener::_deadtime_callback, _NetAddr::baseclass, CASTTOCLASS, FREE, g_get_real_time(), HbPacketsBeingReceived, HbPacketsTimedOut, _HbListener::listenaddr, obsolete_cma::listener, _HbListener::nexttime, ONESEC, _HbListener::status, and _AssimObj::toString.

Referenced by _hblistener_gsourcefunc().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_dellist ( HbListener self)

Remove an HbListener from our global list of HBListeners.

Parameters
[in]selfThe listener to remove from our list

Definition at line 84 of file hblistener.c.

References UNREF2.

Referenced by _hblistener_addlist(), and hblistener_unlisten().

Here is the caller graph for this function:

FSTATIC void _hblistener_finalize ( AssimObj self)

Finalize an HbListener.

Parameters
[in,out]selfListener to finalize

Definition at line 251 of file hblistener.c.

References __FUNCTION__, _listener_finalize(), CASTTOCLASS, DEBUGMSG3, _HbListener::listenaddr, and UNREF.

Referenced by hblistener_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC guint64 _hblistener_get_deadtime ( HbListener self)

Return deadtime.

Definition at line 330 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

FSTATIC guint64 _hblistener_get_warntime ( HbListener self)

Return warntime.

Definition at line 346 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

FSTATIC gboolean _hblistener_got_frameset ( Listener self,
FrameSet fs,
NetAddr srcaddr 
)

Function called when a heartbeat FrameSet class (fs) arrived from the given NetAddr class (srcaddr)

Parameters
selfOur 'self' Listener
fsFrameset received
srcaddrAddress 'fs' came from

Definition at line 154 of file hblistener.c.

References __FUNCTION__, _HbListener::_comealive_callback, _HbListener::_expected_interval, _HbListener::_heartbeat_callback, _HbListener::_warn_interval, _HbListener::_warntime_callback, _NetAddr::baseclass, DEBUG, FMT_64BIT, FREE, g_get_real_time(), hblistener_find_by_address(), HbPacketsBeingReceived, HbPacketsTimedOut, _HbListener::nexttime, _HbListener::status, _AssimObj::toString, UNREF, and _HbListener::warntime.

Referenced by hblistener_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC gboolean _hblistener_gsourcefunc ( gpointer  ignored)

A GSourceFunc to be used with g_timeout_add_seconds()

Parameters
ignored[ignored] Ignored

Definition at line 140 of file hblistener.c.

References _hblistener_checktimeouts().

Referenced by _hblistener_addlist().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_notify_function ( gpointer  ignored)

We get called when our gSource gets removed. This function is probably unnecessary...

Parameters
ignored[unused] Unused

Definition at line 214 of file hblistener.c.

References hblistener_shutdown().

Referenced by _hblistener_addlist().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_set_comealive_callback ( HbListener self,
void(*)(HbListener *who, guint64 howlate)  callback 
)

Call to set a callback to be called when a node passes deadtime but heartbeats again.

Definition at line 403 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

FSTATIC void _hblistener_set_deadtime ( HbListener self,
guint64  deadtime 
)

Set deadtime.

Parameters
[in,out]selfObject to set deadtime for
[in]deadtimedeadtime to set in seconds

Definition at line 319 of file hblistener.c.

References g_get_real_time().

Referenced by hblistener_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_set_deadtime_callback ( HbListener self,
void(*)(HbListener *who)  callback 
)

Call to set a callback to be called when a node apparently dies.

Definition at line 382 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

FSTATIC void _hblistener_set_heartbeat_callback ( HbListener self,
void(*)(HbListener *who)  callback 
)

Call to set a callback to be called when a heartbeat is received.

Definition at line 389 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

FSTATIC void _hblistener_set_warntime ( HbListener self,
guint64  warntime 
)

Set warntime.

Parameters
[in,out]selfObject to set warntime for
[in]warntimewarntime to set in seconds

Definition at line 337 of file hblistener.c.

References g_get_real_time().

Referenced by hblistener_new().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void _hblistener_set_warntime_callback ( HbListener self,
void(*)(HbListener *who, guint64 howlate)  callback 
)

Call to set a callback to be called when a node passes warntime before heartbeating again.

Definition at line 396 of file hblistener.c.

Referenced by hblistener_new().

Here is the caller graph for this function:

HbListener* hblistener_find_by_address ( const NetAddr which)

Find the listener that's listening to a particular address.

Definition at line 96 of file hblistener.c.

References CASTTOCLASS, _NetAddr::equal, _HbListener::listenaddr, and obsolete_cma::listener.

Referenced by _hblistener_addlist(), _hblistener_got_frameset(), and hblistener_unlisten().

Here is the caller graph for this function:

HbListener* hblistener_new ( NetAddr listenaddr,
ConfigContext cfg,
gsize  objsize 
)

Construct a new HbListener - setting up GSource and timeout data structures for it.

This can be used directly or by derived classes.

Parameters
[in]listenaddrAddress to listen to
[in,out]cfgConfiguration context
[in]objsizesize of HbListener structure (0 for sizeof(HbListener))

Definition at line 264 of file hblistener.c.

References __FUNCTION__, _HbListener::_expected_interval, _AssimObj::_finalize, _hblistener_addlist(), _hblistener_finalize(), _hblistener_get_deadtime(), _hblistener_get_warntime(), _hblistener_got_frameset(), _hblistener_set_comealive_callback(), _hblistener_set_deadtime(), _hblistener_set_deadtime_callback(), _hblistener_set_heartbeat_callback(), _hblistener_set_warntime(), _hblistener_set_warntime_callback(), _HbListener::_warn_interval, _Listener::baseclass, _NetAddr::baseclass, BINDDEBUG, CASTTOCLASS, CONFIGNAME_TIMEOUT, CONFIGNAME_WARNTIME, DEBUG, DEFAULT_DEADTIME, FMT_64BIT, FREE, _HbListener::get_deadtime, _HbListener::get_warntime, _ConfigContext::getint, _Listener::got_frameset, HbPacketsBeingReceived, _HbListener::listenaddr, listener_new(), proj_class_register_subclassed(), REF, _HbListener::set_comealive_callback, _HbListener::set_deadtime, _HbListener::set_deadtime_callback, _HbListener::set_heartbeat_callback, _HbListener::set_warntime, _HbListener::set_warntime_callback, _HbListener::status, and _AssimObj::toString.

Referenced by _real_hblistener_new(), and nanoobey_expecthb().

Here is the call graph for this function:

Here is the caller graph for this function:

FSTATIC void hblistener_set_martian_callback ( void(*)(NetAddr *who)  callback)

Call to set a callback to be called when an unrecognized node sends us a heartbeat.

Definition at line 410 of file hblistener.c.

Referenced by nano_start_full().

Here is the caller graph for this function:

FSTATIC void hblistener_shutdown ( void  )

Shuts down all our hblisteners...

Definition at line 222 of file hblistener.c.

References CASTTOCLASS, obsolete_cma::listener, and UNREF2.

Referenced by _hblistener_notify_function(), and nano_shutdown().

Here is the caller graph for this function:

FSTATIC void hblistener_unlisten ( NetAddr unlistenaddr)

Stop expecting (listening for) heartbeats from a particular address.

Todo:
  • this can cause a bug if the NetGSource object still has a reference to us and we delete ourselves - then it will have a bad reference to us. So, we ought to check for this case and replace ourselves with any other listener in the list – if any, and do something more drastic if we're the last listener in the list.
Parameters
[in,out]unlistenaddrListener to remove from list

Definition at line 358 of file hblistener.c.

References __FUNCTION__, _hblistener_dellist(), _NetAddr::baseclass, DEBUG, FREE, hblistener_find_by_address(), obsolete_cma::listener, and _AssimObj::toString.

Referenced by nanoobey_stopexpecthb().

Here is the call graph for this function:

Here is the caller graph for this function: