[kaffe] CVS kaffe (kaz): libraries/javalib/java/net/Socket.java: Reverted.

Kaffe CVS cvs-commits at kaffe.org
Fri Apr 23 08:17:03 PDT 2004


PatchSet 4683 
Date: 2004/04/23 15:12:46
Author: kaz
Branch: HEAD
Tag: (none) 
Log:
2004-04-23  Ito kazumitsu <kaz at maczuka.gcd.org>

        * libraries/javalib/java/net/Socket.java: Reverted.

        * libraries/clib/net/PlainSocketImpl.c
        gnu_java_net_PlainSocketImpl_socketAccept():
        Close the socket if it has already been created.

Members: 
	ChangeLog:1.2259->1.2260 
	libraries/clib/net/PlainSocketImpl.c:1.43->1.44 
	libraries/javalib/java/net/Socket.java:1.32->1.33 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2259 kaffe/ChangeLog:1.2260
--- kaffe/ChangeLog:1.2259	Fri Apr 23 13:37:12 2004
+++ kaffe/ChangeLog	Fri Apr 23 15:12:46 2004
@@ -1,3 +1,11 @@
+2004-04-23  Ito kazumitsu <kaz at maczuka.gcd.org>
+
+	* libraries/javalib/java/net/Socket.java: Reverted.
+
+	* libraries/clib/net/PlainSocketImpl.c
+	gnu_java_net_PlainSocketImpl_socketAccept():
+	Close the socket if it has already been created.
+
 2004-04-23  Guilhem Lavaux <guilhem at kaffe.org>
 
 	* config/i386/gnu/jit-md.h, config/i386/gnu/md.h,
Index: kaffe/libraries/clib/net/PlainSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainSocketImpl.c:1.43 kaffe/libraries/clib/net/PlainSocketImpl.c:1.44
--- kaffe/libraries/clib/net/PlainSocketImpl.c:1.43	Sun Apr 18 13:57:30 2004
+++ kaffe/libraries/clib/net/PlainSocketImpl.c	Fri Apr 23 15:12:49 2004
@@ -376,7 +376,7 @@
 gnu_java_net_PlainSocketImpl_socketAccept(struct Hgnu_java_net_PlainSocketImpl* this, struct Hjava_net_SocketImpl* sock)
 {
 	int r;
-	int rc;
+	int rc, rc1;
 	int alen;
 	struct sockaddr_in addr;
 	HArrayOfByte *remote_addr;
@@ -413,6 +413,13 @@
 	if (rc) {
 		SignalError("java.io.IOException", SYS_ERROR(rc));
 	}
+	if (unhand((struct Hgnu_java_net_PlainSocketImpl *)sock)->native_fd != -1) {
+		rc1 = KSOCKCLOSE(unhand((struct Hgnu_java_net_PlainSocketImpl *)sock)->native_fd);
+		if (rc1) {
+			SignalError("java.io.IOException", SYS_ERROR(rc1));
+		}
+	}
+
 	unhand((struct Hgnu_java_net_PlainSocketImpl *)sock)->native_fd = r;
 
 	/* Enter information into socket object */
Index: kaffe/libraries/javalib/java/net/Socket.java
diff -u kaffe/libraries/javalib/java/net/Socket.java:1.32 kaffe/libraries/javalib/java/net/Socket.java:1.33
--- kaffe/libraries/javalib/java/net/Socket.java:1.32	Fri Apr 16 15:28:24 2004
+++ kaffe/libraries/javalib/java/net/Socket.java	Fri Apr 23 15:12:49 2004
@@ -82,6 +82,11 @@
   private SocketImpl impl;
 
   /**
+   * True if socket implementation was created by calling their create() method.
+   */
+  private boolean implCreated;
+
+  /**
    * True if the socket is bound.
    */
   private boolean bound;
@@ -307,6 +312,19 @@
   SocketImpl getImpl()
     throws SocketException
   {
+    try
+      {
+	if (!implCreated)
+	  {
+	    impl.create(true);
+	    implCreated = true;
+	  }
+      }
+    catch (IOException e)
+      {
+	throw new SocketException(e.getMessage());
+      }
+
     return impl;
   }
 
@@ -340,7 +358,6 @@
     // bind to address/port
     try
       {
-        getImpl().create (true);
         getImpl().bind (tmp.getAddress(), tmp.getPort());
 	bound = true;
       }




More information about the kaffe mailing list