zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mic...@apache.org
Subject svn commit: r1595375 - in /zookeeper/branches/branch-3.4: CHANGES.txt src/contrib/zkperl/ZooKeeper.xs
Date Fri, 16 May 2014 22:32:21 GMT
Author: michim
Date: Fri May 16 22:32:21 2014
New Revision: 1595375

URL: http://svn.apache.org/r1595375
Log:
ZOOKEEPER-1062. Net-ZooKeeper: Net::ZooKeeper consumes 100% cpu on wait (Botond Hejj via michim)

Modified:
    zookeeper/branches/branch-3.4/CHANGES.txt
    zookeeper/branches/branch-3.4/src/contrib/zkperl/ZooKeeper.xs

Modified: zookeeper/branches/branch-3.4/CHANGES.txt
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/CHANGES.txt?rev=1595375&r1=1595374&r2=1595375&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/CHANGES.txt (original)
+++ zookeeper/branches/branch-3.4/CHANGES.txt Fri May 16 22:32:21 2014
@@ -25,6 +25,9 @@ BUGFIXES:
   ZOOKEEPER-1926. Unit tests should only use build/test/data for data (Enis
   Soztutar via michim)
 
+  ZOOKEEPER-1062. Net-ZooKeeper: Net::ZooKeeper consumes 100% cpu on wait
+  (Botond Hejj via michim)
+
 IMPROVEMENTS:
 
   ZOOKEEPER-1575. adding .gitattributes to prevent CRLF and LF mismatches for

Modified: zookeeper/branches/branch-3.4/src/contrib/zkperl/ZooKeeper.xs
URL: http://svn.apache.org/viewvc/zookeeper/branches/branch-3.4/src/contrib/zkperl/ZooKeeper.xs?rev=1595375&r1=1595374&r2=1595375&view=diff
==============================================================================
--- zookeeper/branches/branch-3.4/src/contrib/zkperl/ZooKeeper.xs (original)
+++ zookeeper/branches/branch-3.4/src/contrib/zkperl/ZooKeeper.xs Fri May 16 22:32:21 2014
@@ -2604,6 +2604,7 @@ zkw_wait(zkwh, ...)
         unsigned int timeout;
         struct timeval end_timeval;
         int i, done;
+        struct timespec wait_timespec;
     PPCODE:
         watch = _zkw_get_handle_outer(aTHX_ zkwh, NULL);
 
@@ -2630,25 +2631,19 @@ zkw_wait(zkwh, ...)
         end_timeval.tv_sec += timeout / 1000;
         end_timeval.tv_usec += (timeout % 1000) * 1000;
 
+        wait_timespec.tv_sec = end_timeval.tv_sec;
+        wait_timespec.tv_nsec = end_timeval.tv_usec * 1000;
+
         pthread_mutex_lock(&watch->mutex);
 
         while (!watch->done) {
             struct timeval curr_timeval;
-            struct timespec wait_timespec;
 
             gettimeofday(&curr_timeval, NULL);
 
-            wait_timespec.tv_sec = end_timeval.tv_sec - curr_timeval.tv_sec;
-            wait_timespec.tv_nsec =
-                (end_timeval.tv_usec - curr_timeval.tv_usec) * 1000;
-
-            if (wait_timespec.tv_nsec < 0) {
-                --wait_timespec.tv_sec;
-                wait_timespec.tv_nsec += 1000000000;
-            }
-
-            if (wait_timespec.tv_sec < 0 ||
-                (wait_timespec.tv_sec == 0 && wait_timespec.tv_nsec <= 0)) {
+            if (end_timeval.tv_sec < curr_timeval.tv_sec ||
+                (end_timeval.tv_sec == curr_timeval.tv_sec &&
+                 end_timeval.tv_usec <= curr_timeval.tv_usec)) {
                 break;
             }
 



Mime
View raw message