zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1682823 - in /zookeeper/trunk: CHANGES.txt src/c/src/zookeeper.c
Date Mon, 01 Jun 2015 06:45:12 GMT
Author: michim
Date: Mon Jun  1 06:45:11 2015
New Revision: 1682823

URL: http://svn.apache.org/r1682823
Log:
ZOOKEEPER-2178 Native client fails compilation on Windows. (Chris Nauroth via michim)

Modified:
    zookeeper/trunk/CHANGES.txt
    zookeeper/trunk/src/c/src/zookeeper.c

Modified: zookeeper/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/trunk/CHANGES.txt?rev=1682823&r1=1682822&r2=1682823&view=diff
==============================================================================
--- zookeeper/trunk/CHANGES.txt (original)
+++ zookeeper/trunk/CHANGES.txt Mon Jun  1 06:45:11 2015
@@ -106,6 +106,8 @@ BUGFIXES:
 
   ZOOKEEPER-2179: Typo in Watcher.java (Archana T via rgs)
 
+  ZOOKEEPER-2178 Native client fails compilation on Windows. (Chris Nauroth via michim)
+
 IMPROVEMENTS:
   ZOOKEEPER-1660 Documentation for Dynamic Reconfiguration (Reed Wanderman-Milne via shralex)
 
 

Modified: zookeeper/trunk/src/c/src/zookeeper.c
URL: http://svn.apache.org/viewvc/zookeeper/trunk/src/c/src/zookeeper.c?rev=1682823&r1=1682822&r2=1682823&view=diff
==============================================================================
--- zookeeper/trunk/src/c/src/zookeeper.c (original)
+++ zookeeper/trunk/src/c/src/zookeeper.c Mon Jun  1 06:45:11 2015
@@ -40,7 +40,6 @@
 #include <assert.h>
 #include <stdarg.h>
 #include <limits.h>
-#include <unistd.h> // needed for _POSIX_MONOTONIC_CLOCK
 
 #ifndef _WIN32
 #include <sys/time.h>
@@ -50,7 +49,7 @@
 #include <netinet/tcp.h>
 #include <arpa/inet.h>
 #include <netdb.h>
-#include <unistd.h>
+#include <unistd.h> // needed for _POSIX_MONOTONIC_CLOCK
 #include "config.h"
 #else
 #include "winstdint.h"
@@ -250,7 +249,7 @@ typedef ssize_t sendsize_t;
 static void zookeeper_set_sock_nodelay(zhandle_t *, socket_t);
 static void zookeeper_set_sock_noblock(zhandle_t *, socket_t);
 static void zookeeper_set_sock_timeout(zhandle_t *, socket_t, int);
-static int zookeeper_connect(zhandle_t *, struct sockaddr_storage *, socket_t);
+static socket_t zookeeper_connect(zhandle_t *, struct sockaddr_storage *, socket_t);
 
 
 static sendsize_t zookeeper_send(socket_t s, const void* buf, size_t len)
@@ -287,6 +286,18 @@ void get_system_time(struct timeval *tv)
   ret = clock_gettime(CLOCK_MONOTONIC, &ts);
   tv->tv_sec = ts.tv_sec;
   tv->tv_usec = ts.tv_nsec / 1000;
+#elif _WIN32
+  LARGE_INTEGER counts, countsPerSecond, countsPerMicrosecond;
+  if (QueryPerformanceFrequency(&countsPerSecond) &&
+      QueryPerformanceCounter(&counts)) {
+    countsPerMicrosecond.QuadPart = countsPerSecond.QuadPart / 1000000;
+    tv->tv_sec = (long)(counts.QuadPart / countsPerSecond.QuadPart);
+    tv->tv_usec = (long)((counts.QuadPart % countsPerSecond.QuadPart) /
+        countsPerMicrosecond.QuadPart);
+    ret = 0;
+  } else {
+    ret = gettimeofday(tv, NULL);
+  }
 #else
   ret = gettimeofday(tv, NULL);
 #endif



Mime
View raw message