hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From y...@apache.org
Subject incubator-hawq git commit: HAWQ-1439. tolerate system time being changed to earlier point when checking resource context timeout
Date Thu, 27 Apr 2017 02:09:36 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master 97ace9cf8 -> e082d3adb


HAWQ-1439. tolerate system time being changed to earlier point when checking resource context
timeout


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/e082d3ad
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/e082d3ad
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/e082d3ad

Branch: refs/heads/master
Commit: e082d3adbb89a9e5ccb341da324ea9514cff5a35
Parents: 97ace9c
Author: Yi <yjin@pivotal.io>
Authored: Thu Apr 27 12:09:25 2017 +1000
Committer: Yi <yjin@pivotal.io>
Committed: Thu Apr 27 12:09:25 2017 +1000

----------------------------------------------------------------------
 .../resourcemanager/utils/network_utils.c       | 21 +++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/e082d3ad/src/backend/resourcemanager/utils/network_utils.c
----------------------------------------------------------------------
diff --git a/src/backend/resourcemanager/utils/network_utils.c b/src/backend/resourcemanager/utils/network_utils.c
index fbfe0a9..78a29cb 100644
--- a/src/backend/resourcemanager/utils/network_utils.c
+++ b/src/backend/resourcemanager/utils/network_utils.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include "storage/ipc.h"
 
 #include "dynrm.h"
 /*
@@ -41,9 +42,23 @@ static void cleanupSocketConnectionPool(int code, Datum arg);
 
 uint64_t gettime_microsec(void)
 {
-    static struct timeval t;
-    gettimeofday(&t,NULL);
-    return 1000000ULL * t.tv_sec + t.tv_usec;
+	struct timeval newTime;
+	int status = 1;
+	uint64_t t = 0;
+
+#if HAVE_LIBRT
+	struct timespec ts;
+	status = clock_gettime(CLOCK_MONOTONIC, &ts);
+	newTime.tv_sec = ts.tv_sec;
+	newTime.tv_usec = ts.tv_nsec / 1000;
+#endif
+
+	if (status != 0)
+	{
+		gettimeofday(&newTime, NULL);
+	}
+	t = ((uint64_t)newTime.tv_sec) * USECS_PER_SECOND + newTime.tv_usec;
+	return t;
 }
 
 int getHostIPV4AddressesByHostNameAsString(MCTYPE 	 		context,


Mime
View raw message