Hi,
under the 2.1.x kernels, large write()'s to a socket never come
back if they block, unless I/O occurs on another socket. I've seen
this with 1.1.3 thru 1.1.6v2, with both the Steve Byrne and the Sergei
Nikitin ports under at least 2.1.65 and 2.1.114. The problem is VERY
reproducible and does not occur under the 2.0.x kernels.
Anyone care to comment on whether this is a java bug or a
kernel bug? I suspect jdk itself, since people have reported similar
(if not the same) bugs under Solaris, IRIX, etc. (Check bug parade.)
Under Solaris, sun's response was to tell people to upgrade from 5.4
to 5.5 ... under linux, it would be nice to not wind up having to tell
people to downgrade!
Attached is a little program to demonstrate the problem. It
runs for a while, and then gets stuck. The 1M buffer size makes sure it
gets stuck pretty quickly on my Pentium 66, but you can get the
problem using a buffer of 16k or less if you're patient. Oh, if you run this
under jdb, wait for it to get stuck, and hit return at the jdb prompt,
the write() will return and the program will run a little longer each
time you hit return.
I sure hope someone is reading these bug reports,
-Arup
import java.net.*;
import java.io.*;
public class WriteTest {
static final int bufsz = 1024 * 1024;
public static void main (String args[])
{
Socket s;
byte buf[] = new byte[bufsz];
for (int i = 0; i < bufsz; ++i)
buf[i] = (byte) (i % 256);
try {
s = new Socket ("localhost", 9);
OutputStream os = s.getOutputStream();
while (true) {
os.write(buf);
System.out.print (".");
System.out.flush();
}
} catch (Exception e) {
e.printStackTrace(System.err);
}
}
}