shm-stats-file heartbeat is derived from now_ms with an extra time added
to it, thus it should be handled using the same time as now_ms is.
Until now, we used to handle heartbeat using signed integer. This was not
found to cause severe harm but it could result in improper handling due
to early wrapping because of signedness for instance, so let's better fix
that before it becomes a real issue.
It should be backported in 3.3
*/
struct {
pid_t pid;
- int heartbeat; // last activity of this process + heartbeat timeout, in ticks
+ uint heartbeat; // last activity of this process + heartbeat timeout, in ticks
} slots[64];
int objects; /* actual number of objects stored in the shm */
int objects_slots; /* total available objects slots unless map is resized */
return 1;
}
-static inline int shm_hb_is_stale(int hb)
+static inline int shm_hb_is_stale(uint hb)
{
return (hb == TICK_ETERNITY || tick_is_expired(hb, now_ms));
}
*/
static int shm_stats_file_slot_isfree(struct shm_stats_file_hdr *hdr, int id)
{
- int hb;
+ uint hb;
hb = HA_ATOMIC_LOAD(&hdr->slots[id].heartbeat);
return shm_hb_is_stale(hb);
int shm_stats_file_get_free_slot(struct shm_stats_file_hdr *hdr)
{
int it = 0;
- int hb;
+ uint hb;
while (it < sizeof(hdr->slots) / sizeof(hdr->slots[0])) {
hb = HA_ATOMIC_LOAD(&hdr->slots[it].heartbeat);