Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 1202 invoked from network); 30 Sep 2010 21:35:04 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 30 Sep 2010 21:35:04 -0000 Received: (qmail 48444 invoked by uid 500); 30 Sep 2010 21:35:04 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 48415 invoked by uid 500); 30 Sep 2010 21:35:04 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 48408 invoked by uid 99); 30 Sep 2010 21:35:04 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 21:35:04 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.22] (HELO thor.apache.org) (140.211.11.22) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 30 Sep 2010 21:35:02 +0000 Received: from thor (localhost [127.0.0.1]) by thor.apache.org (8.13.8+Sun/8.13.8) with ESMTP id o8ULYeNl004388 for ; Thu, 30 Sep 2010 21:34:40 GMT Message-ID: <21238737.486591285882480541.JavaMail.jira@thor> Date: Thu, 30 Sep 2010 17:34:40 -0400 (EDT) From: "Hudson (JIRA)" To: commits@harmony.apache.org Subject: [jira] Commented: (HARMONY-6662) Spin wait in StartTlsResponseImpl.java In-Reply-To: <23943331.435281285644770405.JavaMail.jira@thor> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/HARMONY-6662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12916683#action_12916683 ] Hudson commented on HARMONY-6662: --------------------------------- Integrated in Harmony-select-1.5-head-linux-x86_64 #126 (See [https://hudson.apache.org/hudson/job/Harmony-select-1.5-head-linux-x86_64/126/]) Apply fix for HARMONY-6662: Spin wait in StartTlsResponseImpl.java > Spin wait in StartTlsResponseImpl.java > -------------------------------------- > > Key: HARMONY-6662 > URL: https://issues.apache.org/jira/browse/HARMONY-6662 > Project: Harmony > Issue Type: Bug > Components: Classlib > Affects Versions: 6.0M1 > Environment: Windows XP > Reporter: Wendy Feng > Assignee: Regis Xu > Fix For: 5.0M16 > > Original Estimate: 7h > Remaining Estimate: 7h > > I found spin wait in modules/jndi/src/main/java/org/apache/harmony/jndi/provider/ldap/ext/StartTlsResponseImpl.java > public class StartTlsResponseImpl extends StartTlsResponse { > ... > public SSLSession negotiate(SSLSocketFactory factory) throws IOException { > ... > sslSocket.startHandshake(); > while (!isHandshaked) { > // Wait for handshake finish. > } > ... > } > ... > } > > Spin wait for isHandshaked is updated by other threads. > Consequence: > Bad performance due to exhaustive use of CPU time. > In current Java memory model, even if the isHandshaked field is updated by other threads, current thread that spins checking for isHandshaked may not see the up-to-date value, turn the code into an infinite loop. > I suggest to use wait/notify for synchronization as follow > public class StartTlsResponseImpl extends StartTlsResponse { > private static final Object monitor = new Object(): > ... > public SSLSession negotiate(SSLSocketFactory factory) throws IOException { > ... > sslSocket.startHandshake(); > synchronized(monitor){ > while (!isHandshaked) { > monitor.wait(); > } > } > ... > } > ... > } > Pls make sure to change the code that will update the value of isHandshaked correspondingly. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.