issue with ServerSocket::accept

Simon gcj@gornall.net
Thu Jun 17 14:59:00 GMT 2004


Bryce McKinlay wrote:

> Vladimir Leven wrote:
>
>> Oops. It does seem to block -- my mistake. But there is still a 
>> problem. When I close the serverSocket, java generates a 
>> SocketException, but gcj does not appear to do so.
>
>
>
> Looks like we don't implement blocking I/O interruption with close().  
> I've set up a bug report to track this issue, with a self-contained 
> test case:
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15430
>
> Does anyone know of a good way to implement this? Can select() do it?
>
> Bryce
>
I think I've just run into the same bug when trying to compile the 
Apache.org XML-RPC library. Just creating a 'Webserver' (one of the 
supplied classes that nicely handles XML-RPC requests) is sufficient to 
cause the problem. The symptoms are that the sockets don't appear to be 
being closed properly, so are hanging around, and in 20 minutes or so, 
the program dies from lack of available file descriptors (per-process 
limit set to 1024 on the machine). It doesn't happen with the usual 
javac classes.

eg:

[root@cyclops tkcvs]# lsof -p 12720
COMMAND     PID  USER   FD   TYPE   DEVICE     SIZE     NODE NAME
stbserver 12720 simon  cwd    DIR      3,8     4096 12238874 
/home/simon/setTopBoxServer
stbserver 12720 simon  rtd    DIR      3,3     4096        2 /
stbserver 12720 simon  txt    REG      3,8  1645112 12238878 
/home/simon/setTopBoxServer/stbserver
stbserver 12720 simon  mem    REG      3,3   106400   144393 
/lib/ld-2.3.2.so
stbserver 12720 simon  mem    REG      3,5    21040  1158931 
/usr/lib/gconv/gconv-modules.cache
stbserver 12720 simon  mem    REG      3,5   222464   620191 
/usr/lib/mysql/libmysqlclient.so.10.0.0
stbserver 12720 simon  mem    REG      3,5    52616    65368 
/usr/lib/libz.so.1.1.4
stbserver 12720 simon  mem    REG      3,3    23688   144298 
/lib/libcrypt-2.3.2.so
stbserver 12720 simon  mem    REG      3,3    91624   144304 
/lib/libnsl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3   212020    32070 
/lib/i686/libm-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  3631142    99762 
/opt/gcc/lib/libstdc++.so.6.0.0
stbserver 12720 simon  mem    REG      3,3   165116    99722 
/opt/gcc/lib/libgcc_s.so.1
stbserver 12720 simon  mem    REG      3,3 42274266    99786 
/opt/gcc/lib/libgcj.so.5.0.0
stbserver 12720 simon  mem    REG      3,3    93412    32072 
/lib/i686/libpthread-0.10.so
stbserver 12720 simon  mem    REG      3,3    15900   144300 
/lib/libdl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  1552740    32691 
/lib/i686/libc-2.3.2.so
stbserver 12720 simon  mem    REG      3,5 31202800   198222 
/usr/lib/locale/locale-archive
stbserver 12720 simon  mem    REG      3,3    52492   144310 
/lib/libnss_files-2.3.2.so
stbserver 12720 simon    0u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    1u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    2u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    3r  FIFO      0,5          74950150 pipe
stbserver 12720 simon    4w  FIFO      0,5          74950150 pipe
stbserver 12720 simon    5u  IPv4 74950151               TCP *:3305 (LISTEN)
stbserver 12720 simon    6u  sock      0,0          74950152 can't 
identify protocol
stbserver 12720 simon    7u  sock      0,0          74950153 can't 
identify protocol
stbserver 12720 simon    8u  sock      0,0          74951244 can't 
identify protocol
stbserver 12720 simon    9u  sock      0,0          74951245 can't 
identify protocol
stbserver 12720 simon   10u  sock      0,0          74951621 can't 
identify protocol
stbserver 12720 simon   11u  sock      0,0          74952000 can't 
identify protocol

(wait 5 secs)

[root@cyclops tkcvs]# lsof -p 12720
COMMAND     PID  USER   FD   TYPE   DEVICE     SIZE     NODE NAME
stbserver 12720 simon  cwd    DIR      3,8     4096 12238874 
/home/simon/setTopBoxServer
stbserver 12720 simon  rtd    DIR      3,3     4096        2 /
stbserver 12720 simon  txt    REG      3,8  1645112 12238878 
/home/simon/setTopBoxServer/stbserver
stbserver 12720 simon  mem    REG      3,3   106400   144393 
/lib/ld-2.3.2.so
stbserver 12720 simon  mem    REG      3,5    21040  1158931 
/usr/lib/gconv/gconv-modules.cache
stbserver 12720 simon  mem    REG      3,5   222464   620191 
/usr/lib/mysql/libmysqlclient.so.10.0.0
stbserver 12720 simon  mem    REG      3,5    52616    65368 
/usr/lib/libz.so.1.1.4
stbserver 12720 simon  mem    REG      3,3    23688   144298 
/lib/libcrypt-2.3.2.so
stbserver 12720 simon  mem    REG      3,3    91624   144304 
/lib/libnsl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3   212020    32070 
/lib/i686/libm-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  3631142    99762 
/opt/gcc/lib/libstdc++.so.6.0.0
stbserver 12720 simon  mem    REG      3,3   165116    99722 
/opt/gcc/lib/libgcc_s.so.1
stbserver 12720 simon  mem    REG      3,3 42274266    99786 
/opt/gcc/lib/libgcj.so.5.0.0
stbserver 12720 simon  mem    REG      3,3    93412    32072 
/lib/i686/libpthread-0.10.so
stbserver 12720 simon  mem    REG      3,3    15900   144300 
/lib/libdl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  1552740    32691 
/lib/i686/libc-2.3.2.so
stbserver 12720 simon  mem    REG      3,5 31202800   198222 
/usr/lib/locale/locale-archive
stbserver 12720 simon  mem    REG      3,3    52492   144310 
/lib/libnss_files-2.3.2.so
stbserver 12720 simon    0u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    1u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    2u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    3r  FIFO      0,5          74950150 pipe
stbserver 12720 simon    4w  FIFO      0,5          74950150 pipe
stbserver 12720 simon    5u  IPv4 74950151               TCP *:3305 (LISTEN)
stbserver 12720 simon    6u  sock      0,0          74950152 can't 
identify protocol
stbserver 12720 simon    7u  sock      0,0          74950153 can't 
identify protocol
stbserver 12720 simon    8u  sock      0,0          74951244 can't 
identify protocol
stbserver 12720 simon    9u  sock      0,0          74951245 can't 
identify protocol
stbserver 12720 simon   10u  sock      0,0          74951621 can't 
identify protocol
stbserver 12720 simon   11u  sock      0,0          74952000 can't 
identify protocol
stbserver 12720 simon   12u  sock      0,0          74952382 can't 
identify protocol

(wait another 60 secs or so)

[root@cyclops tkcvs]# lsof -p 12720
COMMAND     PID  USER   FD   TYPE   DEVICE     SIZE     NODE NAME
stbserver 12720 simon  cwd    DIR      3,8     4096 12238874 
/home/simon/setTopBoxServer
stbserver 12720 simon  rtd    DIR      3,3     4096        2 /
stbserver 12720 simon  txt    REG      3,8  1645112 12238878 
/home/simon/setTopBoxServer/stbserver
stbserver 12720 simon  mem    REG      3,3   106400   144393 
/lib/ld-2.3.2.so
stbserver 12720 simon  mem    REG      3,5    21040  1158931 
/usr/lib/gconv/gconv-modules.cache
stbserver 12720 simon  mem    REG      3,5   222464   620191 
/usr/lib/mysql/libmysqlclient.so.10.0.0
stbserver 12720 simon  mem    REG      3,5    52616    65368 
/usr/lib/libz.so.1.1.4
stbserver 12720 simon  mem    REG      3,3    23688   144298 
/lib/libcrypt-2.3.2.so
stbserver 12720 simon  mem    REG      3,3    91624   144304 
/lib/libnsl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3   212020    32070 
/lib/i686/libm-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  3631142    99762 
/opt/gcc/lib/libstdc++.so.6.0.0
stbserver 12720 simon  mem    REG      3,3   165116    99722 
/opt/gcc/lib/libgcc_s.so.1
stbserver 12720 simon  mem    REG      3,3 42274266    99786 
/opt/gcc/lib/libgcj.so.5.0.0
stbserver 12720 simon  mem    REG      3,3    93412    32072 
/lib/i686/libpthread-0.10.so
stbserver 12720 simon  mem    REG      3,3    15900   144300 
/lib/libdl-2.3.2.so
stbserver 12720 simon  mem    REG      3,3  1552740    32691 
/lib/i686/libc-2.3.2.so
stbserver 12720 simon  mem    REG      3,5 31202800   198222 
/usr/lib/locale/locale-archive
stbserver 12720 simon  mem    REG      3,3    52492   144310 
/lib/libnss_files-2.3.2.so
stbserver 12720 simon    0u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    1u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    2u   CHR    136,4                 6 /dev/pts/4
stbserver 12720 simon    3r  FIFO      0,5          74950150 pipe
stbserver 12720 simon    4w  FIFO      0,5          74950150 pipe
stbserver 12720 simon    5u  IPv4 74950151               TCP *:3305 (LISTEN)
stbserver 12720 simon    6u  sock      0,0          74950152 can't 
identify protocol
stbserver 12720 simon    7u  sock      0,0          74950153 can't 
identify protocol
stbserver 12720 simon    8u  sock      0,0          74951244 can't 
identify protocol
stbserver 12720 simon    9u  sock      0,0          74951245 can't 
identify protocol
stbserver 12720 simon   10u  sock      0,0          74951621 can't 
identify protocol
stbserver 12720 simon   11u  sock      0,0          74952000 can't 
identify protocol
stbserver 12720 simon   12u  sock      0,0          74952382 can't 
identify protocol
stbserver 12720 simon   13u  sock      0,0          74952767 can't 
identify protocol
stbserver 12720 simon   14u  sock      0,0          74952768 can't 
identify protocol
stbserver 12720 simon   15u  sock      0,0          74952770 can't 
identify protocol
stbserver 12720 simon   16u  sock      0,0          74952771 can't 
identify protocol
stbserver 12720 simon   17u  sock      0,0          74952772 can't 
identify protocol
stbserver 12720 simon   18u  sock      0,0          74952773 can't 
identify protocol
stbserver 12720 simon   19u  sock      0,0          74952774 can't 
identify protocol
stbserver 12720 simon   20u  sock      0,0          74952775 can't 
identify protocol
stbserver 12720 simon   21u  sock      0,0          74952776 can't 
identify protocol
stbserver 12720 simon   22u  sock      0,0          74952777 can't 
identify protocol
stbserver 12720 simon   23u  sock      0,0          74952778 can't 
identify protocol
stbserver 12720 simon   24u  sock      0,0          74952779 can't 
identify protocol
stbserver 12720 simon   25u  sock      0,0          74952780 can't 
identify protocol

This is running with gcj 3.4.0 (as shipped with RH9.0). I can't see 
anything on the bug reports or in the mailing list, but thought I'd ask 
to see if anyone has a solution, or if there's one in CVS ? (The machine 
'cyclops' is a 600MHz VIA Nehemiah, so downloading and compiling gcc/gcj 
from CVS will take a few days...)

ATB,
    Simon



More information about the Java mailing list