[Top][All Lists]

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

Re: [PATCH] small fix for ServerSocket close

From: Dalibor Topic
Subject: Re: [PATCH] small fix for ServerSocket close
Date: Wed, 19 Nov 2003 15:14:53 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030312

Hi Michael,

Michael Koch wrote:

--- /var/tmp/PROJECTS/classpath//./java/net/   Fri Oct 17 
19:05:29 2003
+++ java/net/  Wed Oct 22 21:32:21 2003
@@ -339,7 +339,8 @@
  public void close () throws IOException
-    impl.close ();
+    if (impl != null)
+      impl.close ();

    if (getChannel() != null)
      getChannel().close ();

After thinking about this patch, its more and more bogus in my eyes as
impl never may be null. I provided a better fix to libgcj. When its
approved I will merge it into classpath too.

Not yet, but soon it will.

ServerSocket is still broken with respect to how it behaves when it's closed. When the socket is closed, access to methods like accept() should throw an IOException that it's closed. Currently, no such checks are done and you get weird exceptions.

bash-2.05a$ cat

public class stest {
        public static void main(String [] args) {

                try {
                        ServerSocket ss = new ServerSocket();
                catch (Exception e) {

bash-2.05a$ java stest Socket is closed
        at stest.main(
bash-2.05a$ which java

bash-2.05a$ /tmp/topic/current-jit3/bin/kaffe stest Bad file descriptor
   at (
   at (
   at (
   at (
   at stest.main (

I want to fix the server socket methods to behave properly after close. In order to do that, I want to set impl to null in close, and check for impl == null to determine if the socket has been closed already in all methods that should throw an IOException when the socket is closed.

But I first wanted to get the simple patches from Guilhem in before I start hacking on it myself. Seems to be hard enough ;)

dalibor topic

reply via email to

[Prev in Thread] Current Thread [Next in Thread]