Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4457776

Socket channels map OP_CONNECT to POLLIN, should use POLLOUT

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P2 P2
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta2
    • generic
    • generic

      Date: Fri, 11 May 2001 16:17:32 -0400 (EDT)
      From: Peter Jones - JavaSoft East <###@###.###>

      ...

      Also, looking at the code for SocketChannelImpl.translateAndSetReadyMask,
      it ssems like it maps POLLIN to OP_CONNECT, but it's my understanding
      that the OS actually uses POLLOUT to indicate that an outgoing connection
      has been successfully made. For example, from the poll(2) man page:

           A file descriptor for a socket that is listening for connec-
           tions will indicate that it is ready for reading, once con-
           nections are available. A file descriptor for a socket that
           is connecting asynchronously will indicate that it is ready
           for writing, once a connection has been established.

      I see that there is a regression test "BasicConnect.java", and I was
      wondering if it only seems to "pass" just because it connects to the
      time server port, which always responds with data on a new connection
      with no further prompting-- so the POLLIN that OP_CONNECT gets mapped
      to will trigger anyway. I tried modifying BasicConnect to connect to
      an HTTP server (jini.east:80), which, of course, doesn't send any data
      upon connection, and then the test hung (until the web server's read
      timeout eventually expired), although netstat showed that a connection
      had indeed been established. Modifying the bit translation logic in
      SocketChannelImpl in my workspace to map OP_CONNECT to POLLOUT made the
      test "pass" again.

            mr Mark Reinhold
            mr Mark Reinhold
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: