The Assimilation Project
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups 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 _HbListener::_deadtime_callback, CASTTOCLASS, g_get_real_time(), HbPacketsBeingReceived, HbPacketsTimedOut, obsolete_cma::listener, _HbListener::nexttime, ONESEC, and _HbListener::status.

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 235 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 305 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 321 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 
)
FSTATIC gboolean _hblistener_gsourcefunc ( gpointer  ignored)

A GSourceFunc to be used with g_timeout_add_seconds()

Parameters
ignored[ignored] Ignored

Definition at line 135 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 198 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 366 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 294 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 345 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 352 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 312 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 359 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:

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 373 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 206 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 333 of file hblistener.c.

References _hblistener_dellist(), hblistener_find_by_address(), and obsolete_cma::listener.

Referenced by nanoobey_stopexpecthb().

Here is the call graph for this function:

Here is the caller graph for this function: