You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Wendy Feng (JIRA)" <ji...@apache.org> on 2010/09/28 05:32:50 UTC

[jira] Created: (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


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.


[jira] Assigned: (HARMONY-6662) Spin wait in StartTlsResponseImpl.java

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu reassigned HARMONY-6662:
---------------------------------

    Assignee: Regis Xu

> 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
>   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.


[jira] Commented: (HARMONY-6662) Spin wait in StartTlsResponseImpl.java

Posted by "Hudson (JIRA)" <ji...@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.


[jira] Resolved: (HARMONY-6662) Spin wait in StartTlsResponseImpl.java

Posted by "Regis Xu (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-6662?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Regis Xu resolved HARMONY-6662.
-------------------------------

    Fix Version/s: 5.0M16
       Resolution: Fixed

The fix was applied to trunk at r1002480, please verify if it resolve your problem. Thanks.

> 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.


[jira] Commented: (HARMONY-6662) Spin wait in StartTlsResponseImpl.java

Posted by "Hudson (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-6662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12916702#action_12916702 ] 

Hudson commented on HARMONY-6662:
---------------------------------

Integrated in Harmony-1.5-head-linux-x86_64 #973 (See [https://hudson.apache.org/hudson/job/Harmony-1.5-head-linux-x86_64/973/])
    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.