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

Bug#240550: marked as done ([PR 14759] ServerSocketChannel causes Selector.select() to return immediatly)



Your message dated 
with message-id <20100713184531.10815.63133.mass-bugs-close@merkel.debian.org>
and subject line gcj-4.3 removed from Debian unstable
has caused the Debian Bug report #240550,
regarding [PR 14759] ServerSocketChannel causes Selector.select() to return immediatly
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 this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
240550: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=240550
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: libgcj4
Version: 1:3.3.3-5
Severity: normal

If a ServerSocketChannel has been registered for SelectionKey.OP_ACCEPT
at a Selector, select() will return immediatly with OP_ACCEPT on that
Channel, even when there is no connection waiting.

See example:

Server.java:
-------------------------8<---------------------------------------------
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import java.util.Iterator;

public class Server {
  public static void main(String[] args) {
    try {
      Selector serverSelector = Selector.open();

      ServerSocketChannel ssc = ServerSocketChannel.open();
      ssc.configureBlocking(false);
      ssc.socket().bind(new InetSocketAddress(2003));
      ssc.register(serverSelector, SelectionKey.OP_ACCEPT);
      while(true) {
	System.out.println("Before selector");
	while(serverSelector.select() > 0) {
	  System.out.println("Something was selected.");
	  java.util.Set readyKeys = serverSelector.selectedKeys();
	  Iterator iter = readyKeys.iterator();
	  while(iter.hasNext()) {
	    SelectionKey key = (SelectionKey)iter.next();
	    iter.remove();
	    if(key.isAcceptable()) {
	      ServerSocketChannel ssc2 = (ServerSocketChannel)key.channel();
	      System.out.println("Before accept.");
	      Socket socket = ssc2.socket().accept();
	      System.out.println("After accept.");
	      socket.getOutputStream().write("Hello World!\r\n".getBytes());
	      socket.close();						
	    }
	  }
	}
      }
    } catch (Exception e) {
      // TODO: handle exception
      e.printStackTrace();
    }
  }
}
-------------------------8<---------------------------------------------
Compile and run it with:
gcj-3.3 --main=Server Server.java && ./a.out

and it will output:
Before selector
Something was selected.
Before accept.

and hang in the ServerSocket.accept() method until a connection
happens.

-- System Information:
Debian Release: testing/unstable
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.20-xfs
Locale: LANG=sv_SE, LC_CTYPE=sv_SE

Versions of packages libgcj4 depends on:
ii  libc6                       2.3.2.ds1-11 GNU C Library: Shared libraries an
ii  libgcc1                     1:3.3.3-1    GCC support library
ii  libgcj-common               1:3.3.3-1    Java runtime library (common files
ii  libstdc++5                  1:3.3.3-1    The GNU Standard C++ Library v3
ii  xlibs                       4.2.1-12.1   X Window System client libraries
ii  zlib1g                      1:1.2.1-5    compression library - runtime

-- no debconf information


--- End Message ---
--- Begin Message ---
Version: 4.3.4-4+rm

gcj-4.3 has been removed from Debian unstable: http://bugs.debian.org/577262

Closing its bugs with a Version higher than the last unstable upload.

More information about this script at:
  http://git.debian.org/?p=users/morph/mass-bugs-close.git;a=blob_plain;f=README;hb=HEAD


--- End Message ---

Reply to: