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

SimpleSocketImpl.c, connect() method loop can take 15min. Remove retry loop.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.2.2
    • core-libs
    • beta
    • generic
    • generic



      Name: skT88420 Date: 02/11/2000


      I am looking at the source code from the community Release of Java 1.2.2.
      File: share/classes/java/net/PlainSocketImpl.java has version 1.32 98/07/07 at
      the top.

      java.net.Socket creation involves a call to the connect() method of the
      underlying socket. If the socket target is unavailable there will be an
      excessive blocking before it times out (almost 15 minutes on RH Linux 6.0). The
      main reason is an excessive loop in the Java 1.2.2 sourcefile:
      "src:share/classes/java/net/PlainSocketImpl.java" method doConnect(). This loop
      trieds to connect at least 3 times before giving up. This might seem like a
      good idea, but I think you should consider letting the client of this low level
      class decide how many times to retry. Using the three times hard coded in the
      indicated loop will result in the thread that made the connect() call blocking
      for something close to 15 minutes (!) for servers that succeed in DNS lookups,
      but are not there to respond. I know, I've tried it with Blackdown 1.1.7B,
      Blackdown 1.1.8, IBM 1.1.8 and soon I'll try it with Sun's 1.2.2 for linux.

      Consider removing the outer loop or at least making a way for the client to set
      a timeout so we can decide if we want to wait this long (my servlet's user will
      definitely NOT wait nearly that long. One 4-5 minute time-out is already
      excessive.

      The second point is that it would be very nice to actually have some way to set
      a Timeout for connect calls. One can set the SO_Timeout value, but this cannot
      be set before the connect() call because the connect() call is called from
      inside the java.net.Socket constructor. If you construct a socket with no
      destination/target ip/socket then it wont try to connect, but there is no way to
      specify the ip/socket later (like after you have set the SO_timeout value).
      (and there should be some way in java.net.URL to get the contents and specify a
      timeout value as well so I don't have to go to the socket level just to fetch a
      page without hanging the machine for an unknown (long) time).
      (Review ID: 101148)
      ======================================================================

            alanb Alan Bateman
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: