aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2012-06-14 15:11:48 +0200
committerErlang/OTP <[email protected]>2012-06-14 15:11:48 +0200
commit6fd5ecd1cb35cec9222be5227994bb386c74fa04 (patch)
tree23e73601f3e49c62eee5a5a41a6eb06cfec500ba
parentaff21f5dffc035dd97215ec1a2c281b84412f29f (diff)
parentad660455d333d2538473f5b7abf7ab1784027da0 (diff)
downloadotp-6fd5ecd1cb35cec9222be5227994bb386c74fa04.tar.gz
otp-6fd5ecd1cb35cec9222be5227994bb386c74fa04.tar.bz2
otp-6fd5ecd1cb35cec9222be5227994bb386c74fa04.zip
Merge branch 'pan/heart_and_times/r14/OTP-10111' into maint-r14
* pan/heart_and_times/r14/OTP-10111: Bump vsn Teach heart to use clock_gettime instead of times()
-rw-r--r--erts/etc/common/Makefile.in5
-rw-r--r--erts/etc/common/heart.c38
-rw-r--r--erts/vsn.mk2
3 files changed, 35 insertions, 10 deletions
diff --git a/erts/etc/common/Makefile.in b/erts/etc/common/Makefile.in
index 4754328c0b..250934656a 100644
--- a/erts/etc/common/Makefile.in
+++ b/erts/etc/common/Makefile.in
@@ -61,6 +61,9 @@ LD = @LD@
LIBS = @LIBS@
LDFLAGS = @LDFLAGS@
+# For clock_gettime in heart
+RTLIBS = @LIBRT@
+
ifeq ($(TARGET),win32)
ifeq ($(TYPE),debug)
CFLAGS = $(subst -O2,-g,@CFLAGS@ @DEFS@ $(TYPE_FLAGS) @WFLAGS@ -I$(SYSDIR) \
@@ -467,7 +470,7 @@ else
$(BINDIR)/heart@EXEEXT@: $(OBJDIR)/heart.o $(ENTRY_OBJ)
$(LD) $(LDFLAGS) $(ENTRY_LDFLAGS) -o $@ $(OBJDIR)/heart.o \
- $(ENTRY_OBJ) $(WINDSOCK)
+ $(RTLIBS) $(ENTRY_OBJ) $(WINDSOCK)
$(OBJDIR)/heart.o: heart.c
$(CC) $(CFLAGS) -o $@ -c heart.c
diff --git a/erts/etc/common/heart.c b/erts/etc/common/heart.c
index 7a5746e630..6d787ab773 100644
--- a/erts/etc/common/heart.c
+++ b/erts/etc/common/heart.c
@@ -102,9 +102,6 @@
* that can simulate gethrtime with clock_gettime, no use implementing
* a phony gethrtime in this file as the time questions are so infrequent.
*/
-#if defined(CORRET_USING_TIMES) || defined(GETHRTIME_WITH_CLOCK_GETTIME)
-# define HEART_CORRECT_USING_TIMES 1
-#endif
#include <stdio.h>
#include <stddef.h>
@@ -134,7 +131,7 @@
# include <sys/time.h>
# include <unistd.h>
# include <signal.h>
-# if defined(HEART_CORRECT_USING_TIMES)
+# if defined(CORRECT_USING_TIMES)
# include <sys/times.h>
# include <limits.h>
# endif
@@ -447,7 +444,8 @@ message_loop(erlin_fd, erlout_fd)
*/
timestamp(&now);
if (now > last_received + heart_beat_timeout) {
- print_error("heart-beat time-out.");
+ print_error("heart-beat time-out, no activity for %lu seconds",
+ (unsigned long) (now - last_received));
return R_TIMEOUT;
}
/*
@@ -1077,7 +1075,31 @@ time_t timestamp(time_t *res)
return r;
}
-#elif defined(HAVE_GETHRTIME)
+#elif defined(HAVE_GETHRTIME) || defined(GETHRTIME_WITH_CLOCK_GETTIME)
+
+#if defined(GETHRTIME_WITH_CLOCK_GETTIME)
+typedef long long SysHrTime;
+
+SysHrTime sys_gethrtime(void);
+
+SysHrTime sys_gethrtime(void)
+{
+ struct timespec ts;
+ long long result;
+ if (clock_gettime(CLOCK_MONOTONIC,&ts) != 0) {
+ print_error("Fatal, could not get clock_monotonic value, terminating! "
+ "errno = %d\n", errno);
+ exit(1);
+ }
+ result = ((long long) ts.tv_sec) * 1000000000LL +
+ ((long long) ts.tv_nsec);
+ return (SysHrTime) result;
+}
+#else
+typedef hrtime_t SysHrTime;
+#define sys_gethrtime() gethrtime()
+#endif
+
void init_timestamp(void)
{
@@ -1085,14 +1107,14 @@ void init_timestamp(void)
time_t timestamp(time_t *res)
{
- hrtime_t ht = gethrtime();
+ SysHrTime ht = sys_gethrtime();
time_t r = (time_t) (ht / 1000000000);
if (res != NULL)
*res = r;
return r;
}
-#elif defined(HEART_CORRECT_USING_TIMES)
+#elif defined(CORRECT_USING_TIMES)
# ifdef NO_SYSCONF
# include <sys/param.h>
diff --git a/erts/vsn.mk b/erts/vsn.mk
index 224727b094..0e755ad8c5 100644
--- a/erts/vsn.mk
+++ b/erts/vsn.mk
@@ -17,7 +17,7 @@
# %CopyrightEnd%
#
-VSN = 5.8.5.1
+VSN = 5.8.5.2
SYSTEM_VSN = R14B04
# Port number 4365 in 4.2