[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#415110: marked as done (/usr/bin/gij-wrapper-4.1: SocketChannel.get(ByteBuffer) does not detect EOF on a non-blocking socket)



Your message dated Mon, 23 Jul 2007 09:29:09 +0200
with message-id <18084.22725.753955.513650@gargle.gargle.HOWL>
and subject line Bug#415110: /usr/bin/gij-wrapper-4.1: SocketChannel.get(ByteBuffer) does not detect EOF on a non-blocking socket
has caused the attached Bug report to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere.  Please contact me immediately.)

Debian bug tracking system administrator
(administrator, Debian Bugs database)

--- Begin Message ---
Package: gij-4.1
Version: 4.1.1-20
Severity: normal
File: /usr/bin/gij-wrapper-4.1

This bug report is a variation of bug:
  http://bugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=281602
I've confirmed that bug 281602 was fixed... the source code in that
example used a blocking socket, this example uses a non-blocking socket.


To run:
===
# compile
javac test.java  

# start server
java test

# connect a client, send "foo" and close after 3 seconds
echo "foo" | nc -q 3 localhost 2003
===


If you strace the java test process you should see a bunch of this after
the socket is closed:
===
ioctl(6, FIONREAD, [0])                 = 0
ioctl(6, FIONREAD, [0])                 = 0
ioctl(6, FIONREAD, [0])                 = 0
===

GIJ never actually calls read to determine if the socket was closed,
it just assumes that because no bytes are available to read now, that
it can return 0 to caller.


sample source code:
===
import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.Iterator;

public class test {
    public static void main(String[] args) {
        try {
            Selector serverSelector;

            serverSelector = Selector.open();
            ServerSocketChannel ssc = ServerSocketChannel.open();
            ssc.configureBlocking(true);
            ssc.socket().bind(new InetSocketAddress(2003));
            SocketChannel sc = ssc.accept();
            sc.configureBlocking(false);
            while (true) {
                ByteBuffer bb = ByteBuffer.allocate(100);
                int i = sc.read(bb);
                if (i > 0) {
                    System.out.println("Read : " + i + " bytes.");
                    for(int j = 0; j < i; j++) {
                        System.out.print((char)bb.get(j));
                    }
                }
                if (i < 0) {
                    System.out.println("Closing : " + i);
                    sc.close();
                    return;
                }
            }
        } catch(Exception ex) {
        }
    }
}
===


-- System Information:
Debian Release: 4.0
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.18-blitz8
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages gij-4.1 depends on:
ii  gcj-4.1-base                4.1.1-20     The GNU Compiler Collection (gcj b
ii  libc6                       2.3.6.ds1-13 GNU C Library: Shared libraries
ii  libgcc1                     1:4.1.1-21   GCC support library
ii  libgcj7-0                   4.1.1-20     Java runtime library for use with 
ii  zlib1g                      1:1.2.3-13   compression library - runtime

gij-4.1 recommends no packages.

-- debconf-show failed


--- End Message ---
--- Begin Message ---
Version: 4.1.2-14

Fixed in gij-4.1 and gij-4.2 in unstable.

Mike Simons writes:
> Package: gij-4.1
> Version: 4.1.1-20
> Severity: normal
> File: /usr/bin/gij-wrapper-4.1
> 
> This bug report is a variation of bug:
>   http://bugs.donarmstrong.com/cgi-bin/bugreport.cgi?bug=281602
> I've confirmed that bug 281602 was fixed... the source code in that
> example used a blocking socket, this example uses a non-blocking socket.
> 
> 
> To run:
> ===
> # compile
> javac test.java  
> 
> # start server
> java test
> 
> # connect a client, send "foo" and close after 3 seconds
> echo "foo" | nc -q 3 localhost 2003
> ===
> 
> 
> If you strace the java test process you should see a bunch of this after
> the socket is closed:
> ===
> ioctl(6, FIONREAD, [0])                 = 0
> ioctl(6, FIONREAD, [0])                 = 0
> ioctl(6, FIONREAD, [0])                 = 0
> ===
> 
> GIJ never actually calls read to determine if the socket was closed,
> it just assumes that because no bytes are available to read now, that
> it can return 0 to caller.

--- End Message ---

Reply to: