harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mikhail Markov" <mikhail.a.mar...@gmail.com>
Subject Re: [classlib] Intermittent failures of UDP tests
Date Tue, 13 Feb 2007 18:59:07 GMT
> I don't quite get it. Is it operating system to be blamed or the code
> for ServerSocket(0) which returns a port that is still used by some
socket?

No, the code for obtaining the available port is the following (
tests.support.Support_PortManager):
    ServerSocket ss = new ServerSocket(0);
    int port = ss.getLocalPort();
    ss.close();
    return port;
It works ok: creates a ServerSocket on a not-busy port, but when we try to
use this port number somewhere in the test for creating a new Sockets, we
get the mentioned "Address already in use" exception. Seems like the
ServerSocket is not fully closed at the moment we're trying to use the
generated port.

Regards,
Mikhail

On 2/13/07, Gregory Shimansky <gshimansky@gmail.com> wrote:
>
> Mikhail Markov wrote:
> > Hi!
> >
> > As you've probably noticed, sometimes we have a failures in Datagram*
> tests
> > (i.e. tests using UDP protocol like DatagramChannelTest,
> DatagramSocketTest
> > etc.)
> > See the beginning of the story here:
> > http://issues.apache.org/jira/browse/HARMONY-2338 and the discussion
> here:
> > http://comments.gmane.org/gmane.comp.java.harmony.devel/20884.
> >
> > Now we have the following scheme for random (not-busy) ports generation
> for
> > java.net tests: use ServerSocket(0);
> > It works for TCP sockets, but for UDP sockets it sometimes fails as
> > operating system sometimes closes this ServerSocket too slowly so the
> code
> > trying to use this port gets "The address is already in use" kind of
> > exception (HARMONY-2860, HARMONY-3046, HARMONY-3156).
>
> I don't quite get it. Is it operating system to be blamed or the code
> for ServerSocket(0) which returns a port that is still used by some
> socket?
>
> > I've tried to implement the same approach but use new DatagramSocket()
> for
> > obtaining random port number for UDP tests (added it as a patch for
> > HARMONY-2860), but it also fails sometimes.
> >
> > So, based on the previous discussions, we'll probably have 2 options of
> > fixing UDP tests without their re-writing:
> >  - Reserve several ports numbers and use them in cycle
> >  - Add the delay after obtaining the not-busy port (and hope that other
> > processes will not take this port while we're sleeping :-))
> >
> > The 1-st from the above seems the most attractive choice.
> > The related questions:
> >  1) How may reserved ports do we need? IMHO, 3 for the beginning will be
> > enough
> >  2) What are exact numbers: Alexey Petrenko suggested starting from
> 63527
> > :-) Other options?
> >
> > Thoughts?
> >
> > If nobody objects i'll try to implement this scheme for port obtaining
> for
> > UDP tests.
> >
> > Regards,
> > Mikhail
> >
>
>
> --
> Gregory
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message