Return-Path: X-Original-To: apmail-zookeeper-commits-archive@www.apache.org Delivered-To: apmail-zookeeper-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 05B3111296 for ; Fri, 16 May 2014 23:57:29 +0000 (UTC) Received: (qmail 53098 invoked by uid 500); 16 May 2014 22:51:27 -0000 Delivered-To: apmail-zookeeper-commits-archive@zookeeper.apache.org Received: (qmail 22753 invoked by uid 500); 16 May 2014 22:38:39 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 12224 invoked by uid 99); 16 May 2014 22:32:42 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 22:32:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 May 2014 22:32:41 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id C116323889BB; Fri, 16 May 2014 22:32:21 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@zookeeper.apache.org From: michim@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140516223221.C116323889BB@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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; }