[kaffe] [PATCH] fixing UDP receive timeout (makes mauve not hang on CVS head)
noa at resare.com
Wed Sep 8 14:26:09 PDT 2004
For some reason beyond my understanding I decided that I should devote
some of my very few hacking cycles to kaffe. However, being sort of a
newbie in the JVM hacking business I didn't feel comfortable doing
anything before I could regression test any contributions. So I had a
look at mauve and got it to work with kaffe-1.1.4. kaffe from cvs HEAD
on the other hand hang on a java.net.DatagramSocket test.
So, I thought, what better way to start my kaffe career than to have a
look at the failed test. Said and done, some investigation lead me to
jthreadedRecvfrom() in kaffevm/systems/unix-pthreads/syscalls.c
The code has a few problems preventing the timeout functionality from
1) The code checks for EAGAIN from recvfrom() but the socket doesn't
have O_NONBLOCK set.
2) The BREAK_IF_LATE macro sets errno to EINTR. EINTR makes
libraries/clib/net/PlainDatagramSocketImpl.c just call jthreadedRecvfrom
3) The code is a tight loop that will suck up available CPU if
O_NONBLOCK is set and the read operation blocks.
The attached patch attempts to fix these problems while minimizing the
risk of unwanted side effects. To summarize:
- O_NONBLOCK is set on the socket
- BREAK_IF_LATE sets errno to ETIMEDOUT instead, which is handled in
- poll() is used to prevent CPU hogging if the read would have blocked
- any socket options are restored to their previous state
- is poll() available on all relevant systems?
- should the socket be permanently non blocking?
The patch is only tested on i386 Fedora Core 2.90 (which means
please apply :)
And the lions ate the christians and the christians burned the witches,
and even I am out of explanations -- Ola Salo
gpg fingerprint: F3C4 AC90 B885 FE15 344B 4D05 220B 7662 A190 6F09
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1924 bytes
Desc: not available
Url : http://kaffe.org/pipermail/kaffe/attachments/20040908/41c300a7/attachment-0002.bin
More information about the kaffe