You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2009/02/25 16:13:54 UTC

svn commit: r747813 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Author: hindessm
Date: Wed Feb 25 15:13:52 2009
New Revision: 747813

URL: http://svn.apache.org/viewvc?rev=747813&view=rev
Log:
This test often fails for me because if the client connect completes
before the server socket closes then the client socket is left in
CLOSE_WAIT state. The CLOSE_WAIT socket is then still using the port
so the SECOND_TIME bind fails.  Oddly it passes 100% of the time on
the RI because the close always seems to happen before the connect
completes and so the connect always fails with 0 return code.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=747813&r1=747812&r2=747813&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Wed Feb 25 15:13:52 2009
@@ -93,8 +93,8 @@
                 }
 
                 socket.setSoTimeout(5000);
-                socket.accept();
-
+                Socket client = socket.accept();
+                client.close();
                 socket.close();
             } catch (IOException e) {
                 e.printStackTrace();



Re: svn commit: r747813 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Regis <xu...@gmail.com>.
Mark Hindess wrote:
> In message <49...@gmail.com>, Regis writes:
>> Hi,
>>
>> It seems the same problem of HARMONY-6090 and discussed here [1].
> 
> Really there seem to be two problems.  I'll elaborate a little on what I
> wrote in the commit log.
> 
>> In Harmony, the SO_REUSEADDR's default value of ServerSocket is
>> false on Linux, while RI is true, that cause the bind failed. I have
>> attached a patch to fix it in Java code, you can try it :) I think
>> it's better if it could be done in native code.
> 
> When it passes on the RI, there is no client socket in CLOSE_WAIT
> because the server accept/close happens faster and the client connect
> fails.  So *nothing* is using the port so SO_REUSEADDR doesn't apply.
> We are effectively testing the execution order of the client and server
> threads.
> 
> In the Harmony case, you could say we are testing SO_REUSEADDR property
> when the test has failing but without testing to see if the client
> connect has succeeded we couldn't be sure were testing SO_REUSEADDR and
> not execution order.
> 
> So we should fix:
> 
>  1) the default SO_REUSEADDR state to match RI (yes, fix the natives would
>     be better), and
>  2) the test so that we are sure we are testing the behaviour we intend
>     to test.
Thanks the explanation, it's clear and I understood this make our test 
more robust.

the patch of SO_REUSEADDR problem already on HARMONY-6090, it works well 
although not the best way, we could consider to apply it.
> 
> Regards,
> -Mark.
>  
>> [1] 
>> http://harmony.markmail.org/search/?q=SO_REUSEADDR#query:SO_REUSEADDR+page:1+
>> mid:ylkmq4aaclmcr55b+state:results
> 
> FYI: If you click the 'Action' link at the top of the message panel in
> markmail you can copy/paste permalinks for the message or thread that
> are shorter and probably better for use in emails.  For example:
> 
>   http://markmail.org/thread/ylkmq4aaclmcr55b
Great, i'm looking for it, thanks!

> 
>> hindessm@apache.org wrote:
>>> Author: hindessm
>>> Date: Wed Feb 25 15:13:52 2009
>>> New Revision: 747813
>>>
>>> URL: http://svn.apache.org/viewvc?rev=747813&view=rev
>>> Log:
>>> This test often fails for me because if the client connect completes
>>> before the server socket closes then the client socket is left in
>>> CLOSE_WAIT state. The CLOSE_WAIT socket is then still using the port
>>> so the SECOND_TIME bind fails.  Oddly it passes 100% of the time on
>>> the RI because the close always seems to happen before the connect
>>> completes and so the connect always fails with 0 return code.
>>>
>>> Modified:
>>>     harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
>> ache/harmony/luni/tests/java/net/SocketTest.java
>>> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/
>> org/apache/harmony/luni/tests/java/net/SocketTest.java
>>> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/l
>> uni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.jav
>> a?rev=747813&r1=747812&r2=747813&view=diff
>>> ===========================================================================
>> ===
>>> --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
>> ache/harmony/luni/tests/java/net/SocketTest.java (original)
>>> +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
>> ache/harmony/luni/tests/java/net/SocketTest.java Wed Feb 25 15:13:52 2009
>>> @@ -93,8 +93,8 @@
>>>                  }
>>>  
>>>                  socket.setSoTimeout(5000);
>>> -                socket.accept();
>>> -
>>> +                Socket client = socket.accept();
>>> +                client.close();
>>>                  socket.close();
>>>              } catch (IOException e) {
>>>                  e.printStackTrace();
>>>
>>>
>>>
>>
>> -- 
>> Best Regards,
>> Regis.
>>
> 
> 
> 


-- 
Best Regards,
Regis.

Re: svn commit: r747813 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Mark Hindess <ma...@googlemail.com>.
In message <49...@gmail.com>, Regis writes:
>
> Hi,
> 
> It seems the same problem of HARMONY-6090 and discussed here [1].

Really there seem to be two problems.  I'll elaborate a little on what I
wrote in the commit log.

> In Harmony, the SO_REUSEADDR's default value of ServerSocket is
> false on Linux, while RI is true, that cause the bind failed. I have
> attached a patch to fix it in Java code, you can try it :) I think
> it's better if it could be done in native code.

When it passes on the RI, there is no client socket in CLOSE_WAIT
because the server accept/close happens faster and the client connect
fails.  So *nothing* is using the port so SO_REUSEADDR doesn't apply.
We are effectively testing the execution order of the client and server
threads.

In the Harmony case, you could say we are testing SO_REUSEADDR property
when the test has failing but without testing to see if the client
connect has succeeded we couldn't be sure were testing SO_REUSEADDR and
not execution order.

So we should fix:

 1) the default SO_REUSEADDR state to match RI (yes, fix the natives would
    be better), and
 2) the test so that we are sure we are testing the behaviour we intend
    to test.

Regards,
-Mark.
 
> [1] 
> http://harmony.markmail.org/search/?q=SO_REUSEADDR#query:SO_REUSEADDR+page:1+
> mid:ylkmq4aaclmcr55b+state:results

FYI: If you click the 'Action' link at the top of the message panel in
markmail you can copy/paste permalinks for the message or thread that
are shorter and probably better for use in emails.  For example:

  http://markmail.org/thread/ylkmq4aaclmcr55b

> hindessm@apache.org wrote:
> > Author: hindessm
> > Date: Wed Feb 25 15:13:52 2009
> > New Revision: 747813
> > 
> > URL: http://svn.apache.org/viewvc?rev=747813&view=rev
> > Log:
> > This test often fails for me because if the client connect completes
> > before the server socket closes then the client socket is left in
> > CLOSE_WAIT state. The CLOSE_WAIT socket is then still using the port
> > so the SECOND_TIME bind fails.  Oddly it passes 100% of the time on
> > the RI because the close always seems to happen before the connect
> > completes and so the connect always fails with 0 return code.
> > 
> > Modified:
> >     harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
> ache/harmony/luni/tests/java/net/SocketTest.java
> > 
> > Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/
> org/apache/harmony/luni/tests/java/net/SocketTest.java
> > URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/l
> uni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.jav
> a?rev=747813&r1=747812&r2=747813&view=diff
> > ===========================================================================
> ===
> > --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
> ache/harmony/luni/tests/java/net/SocketTest.java (original)
> > +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/ap
> ache/harmony/luni/tests/java/net/SocketTest.java Wed Feb 25 15:13:52 2009
> > @@ -93,8 +93,8 @@
> >                  }
> >  
> >                  socket.setSoTimeout(5000);
> > -                socket.accept();
> > -
> > +                Socket client = socket.accept();
> > +                client.close();
> >                  socket.close();
> >              } catch (IOException e) {
> >                  e.printStackTrace();
> > 
> > 
> > 
> 
> 
> -- 
> Best Regards,
> Regis.
> 



Re: svn commit: r747813 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java

Posted by Regis <xu...@gmail.com>.
Hi,

It seems the same problem of HARMONY-6090 and discussed here [1].

In Harmony, the SO_REUSEADDR's default value of ServerSocket is false on 
Linux, while RI is true, that cause the bind failed. I have attached a 
patch to fix it in Java code, you can try it :)
I think it's better if it could be done in native code.

[1] 
http://harmony.markmail.org/search/?q=SO_REUSEADDR#query:SO_REUSEADDR+page:1+mid:ylkmq4aaclmcr55b+state:results

hindessm@apache.org wrote:
> Author: hindessm
> Date: Wed Feb 25 15:13:52 2009
> New Revision: 747813
> 
> URL: http://svn.apache.org/viewvc?rev=747813&view=rev
> Log:
> This test often fails for me because if the client connect completes
> before the server socket closes then the client socket is left in
> CLOSE_WAIT state. The CLOSE_WAIT socket is then still using the port
> so the SECOND_TIME bind fails.  Oddly it passes 100% of the time on
> the RI because the close always seems to happen before the connect
> completes and so the connect always fails with 0 return code.
> 
> Modified:
>     harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
> 
> Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java
> URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java?rev=747813&r1=747812&r2=747813&view=diff
> ==============================================================================
> --- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java (original)
> +++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/net/SocketTest.java Wed Feb 25 15:13:52 2009
> @@ -93,8 +93,8 @@
>                  }
>  
>                  socket.setSoTimeout(5000);
> -                socket.accept();
> -
> +                Socket client = socket.accept();
> +                client.close();
>                  socket.close();
>              } catch (IOException e) {
>                  e.printStackTrace();
> 
> 
> 


-- 
Best Regards,
Regis.