Thanks for the bug report.

I think somebody else pointed this already out (with a reproducible testcase
like yours), but I didn't have the time to debug it yet.  If somebody wants 
to beat me to it, go ahead.
Please also enter this bug in the bug database @ www.kaffe.org
if you haven't already.

        - Godmar

> 
> 
> I have detected a sort of deadlock problem using a Thread.sleep() during
> a timered Socket read; this problem happens randomly, but in my system
> it's easy to reproduce in less than 30 secs. I am currently using the
> Kaffe version 1.0b4 compiled with Cygwin32 under WinNT, and running the
> following sample :
> 
> import java.net.*;
> import java.io.*;
> 
> class Loop
> {
>     public static void main(String av[]) throws Exception {
>   final int LOOP_MAX = 10000000;
>   final int port = 45054;
>   ServerSocket server = null;
> 
>   try {
>    server = new ServerSocket(port);
>   } catch (IOException e) { System.out.println(e); }
> 
>         Thread t = new Thread() {
>             public void run() {
>     try {
>      Socket s = new Socket(InetAddress.getLocalHost(), port);
>      BufferedOutputStream out = new
> BufferedOutputStream(s.getOutputStream());
>      byte btx[]= new byte[10];
>      for (int i=0; i<LOOP_MAX; i++) {
>       try {
>        out.write(btx, 0, 10);
>       } catch (IOException e) { System.out.println(e); }
>       System.out.print("#");
>       try {
>        out.flush();
>       } catch (IOException e) { System.out.println(e); }
> //      System.out.print("$");
>       try {
>        Thread.sleep(30);
>       } catch (Exception e) {}
> //      System.out.print("%");
>      }
>      out.close();
>     } catch (Exception e) { System.out.println("Failure " + e); }
>       }
>   };
> 
>   t.start();
>         server.setSoTimeout(5000);
>         Socket rsocket = null;
>   try {
>    rsocket = server.accept();
>   } catch (InterruptedIOException e) { System.out.println(e); }
>   BufferedInputStream in = new
> BufferedInputStream(rsocket.getInputStream());
> 
>         rsocket.setSoTimeout(20);
>   byte brx[]= new byte[10];
> 
>   for (int i=0; i<LOOP_MAX; i++) {
>    int len=0;
>    try {
> //    System.out.print("^");
>     len = in.read(brx, 0, 10);
>    } catch (InterruptedIOException e) {}
>    if (len > 0)
>     System.out.print("@");
>    else
>     System.out.print(".");
>   }
>  }
> }
> 
> 
> 

Reply via email to