MXS-1506: Make heartbeat reads atomic

The old hkheartbeat variable was changed to the mxs_clock() function that
simply wraps an atomic load of the variable. This allows it to be
correctly read by MaxScale as well as opening up the possibility of
converting the value load to a relaxed memory order read.

Renamed the header and associated macros. Removed inclusion of the
heartbeat header from the housekeeper header and added it to the files
that were missing it.
This commit is contained in:
Markus Mäkelä
2018-04-02 14:12:25 +03:00
parent 761fda2806
commit b33f464eea
16 changed files with 63 additions and 51 deletions

View File

@ -17,20 +17,24 @@
MXS_BEGIN_DECLS
/**
* The global housekeeper heartbeat value. This value is incremented
* every 100 milliseconds and may be used for crude timing etc.
* The global clock
*
* This value is incremented roughly every 100 milliseconds and may be used for
* very crude timing. The crudeness is due to the fact that the housekeeper
* thread does the updating of this value.
*
* @return The current clock tick
*/
extern int64_t hkheartbeat;
int64_t mxs_clock();
/**
* Convert heartbeats to seconds
*/
#define HB_TO_SEC(a) ((int64_t)a / 10)
#define MXS_CLOCK_TO_SEC(a) ((int64_t)a / 10)
/**
* Convert seconds to heartbeats
*/
#define SEC_TO_HB(a) ((int64_t)a * 10)
#define MXS_SEC_TO_CLOCK(a) ((int64_t)a * 10)
MXS_END_DECLS

View File

@ -19,7 +19,6 @@
#include <maxscale/cdefs.h>
#include <time.h>
#include <maxscale/dcb.h>
#include <maxscale/hk_heartbeat.h>
MXS_BEGIN_DECLS