[kaffe] CVS kaffe (guilhem): Various fixes.

Kaffe CVS Kaffe Mailing List <kaffe@kaffe.org>
Sun Aug 31 10:20:03 2003


PatchSet 4001 
Date: 2003/08/31 17:16:47
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Various fixes.

Noticeable changes:
Reimplementation of deleteOnExit (missing in classpath)
Removed SoInterrupt because it is wrong.
Implemented fsync for pthreads.

Members: 
	ChangeLog:1.1597->1.1598 
	include/Makefile.am:1.47->1.48 
	include/Makefile.in:1.119->1.120 
	kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.14->1.15 
	libraries/clib/io/File.c:1.20->1.21 
	libraries/clib/io/FileDescriptor.c:1.5->1.6 
	libraries/clib/net/NetworkInterface.c:1.2->1.3 
	libraries/clib/net/PlainDatagramSocketImpl.c:1.27->1.28 
	libraries/clib/net/PlainSocketImpl.c:1.31->1.32 
	libraries/javalib/java/io/File.java:1.35->1.36 
	libraries/javalib/java/lang/Runtime.java:1.25->1.26 
	libraries/javalib/java/lang/Thread.java:1.42->1.43 
	test/regression/Makefile.am:1.81->1.82 
	test/regression/Makefile.in:1.134->1.135 
	test/regression/SoInterrupt.java:1.5->1.6(DEAD) 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1597 kaffe/ChangeLog:1.1598
--- kaffe/ChangeLog:1.1597	Sat Aug 30 23:57:08 2003
+++ kaffe/ChangeLog	Sun Aug 31 17:16:47 2003
@@ -1,3 +1,36 @@
+2003-08-31  Guilhem Lavaux <guilhem@kaffe.org>
+
+	* kaffe/kaffevm/systems/unix-pthreads/syscalls.c:
+	(jthreadedFSync) added.
+	(Kaffe_SystemCallInterface) added jthreadedFSync.
+
+	* libraries/clib/net/PlainDatagramSocketImpl.c:
+	(java_net_PlainDatagramSocketImpl_receive) check if pkt is NULL
+	and throw NullPointerException if it is the case.
+	Changed the way EINTR is handled (it must be ignored).
+	ETIMEDOUT throws a better exception with bytesTransferred set to
+	the right value.
+	
+	* libraries/clib/net/PlainSocketImpl.c:
+	(java_net_PlainSocketImpl_receive) see above for the changed behaviour.
+	(java_net_PlainSocketImpl_accept) EINTR is now ignored.
+
+	* libraries/clib/io/File.c:
+	(java_io_File_listInternal) check whether the pointer is null.
+
+	* libraries/clib/io/FileDescriptor.c:
+	(getFileSize) don't return an error if there isn't.
+
+	* include/Makefile.am:
+	(NOINSTALL_DERIVED_HDRS) added java_io_InterruptedIOException.h
+
+	* test/regression/SoInterrupt.java: removed. This test was a
+	non-sense from the beginning to the end.
+
+	* test/regression/Makefile.am: removed SoInterrupt.java
+
+	* test/regression/Makefile.in: regenerated.
+
 2003-08-30  Timothy S. Stack <stack@cs.utah.edu>
 
 	* include/jni.h, include/jvmpi.h:
Index: kaffe/include/Makefile.am
diff -u kaffe/include/Makefile.am:1.47 kaffe/include/Makefile.am:1.48
--- kaffe/include/Makefile.am:1.47	Sat Aug 30 14:18:23 2003
+++ kaffe/include/Makefile.am	Sun Aug 31 17:16:48 2003
@@ -47,6 +47,7 @@
 	java_io_FileInputStream.h \
 	java_io_FileOutputStream.h \
 	java_io_InputStream.h \
+	java_io_InterruptedIOException.h \
 	java_io_ObjectInputStream.h \
 	java_io_PrintStream.h \
 	java_io_RandomAccessFile.h \
Index: kaffe/include/Makefile.in
diff -u kaffe/include/Makefile.in:1.119 kaffe/include/Makefile.in:1.120
--- kaffe/include/Makefile.in:1.119	Sat Aug 30 14:18:23 2003
+++ kaffe/include/Makefile.in	Sun Aug 31 17:16:48 2003
@@ -282,6 +282,7 @@
 	java_io_FileInputStream.h \
 	java_io_FileOutputStream.h \
 	java_io_InputStream.h \
+	java_io_InterruptedIOException.h \
 	java_io_ObjectInputStream.h \
 	java_io_PrintStream.h \
 	java_io_RandomAccessFile.h \
Index: kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c
diff -u kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.14 kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.15
--- kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c:1.14	Fri Aug  8 14:38:25 2003
+++ kaffe/kaffe/kaffevm/systems/unix-pthreads/syscalls.c	Sun Aug 31 17:16:48 2003
@@ -249,6 +249,17 @@
 }
 
 static int
+jthreadedFSync(int fd)
+{
+	int rc = 0;
+	
+	if (fsync(fd) == -1) {
+		rc = errno;
+	}
+	return (rc);
+}
+
+static int
 jthreadedMkdir(const char *path, int mode)
 {
 	int rc = 0;
@@ -880,6 +891,7 @@
         jthreadedFStat,
         jthreadedStat,
         jthreadedFTruncate,
+        jthreadedFSync,
         jthreadedMkdir,
         jthreadedRmdir,
         jthreadedRename,
Index: kaffe/libraries/clib/io/File.c
diff -u kaffe/libraries/clib/io/File.c:1.20 kaffe/libraries/clib/io/File.c:1.21
--- kaffe/libraries/clib/io/File.c:1.20	Sat Aug 30 14:18:24 2003
+++ kaffe/libraries/clib/io/File.c	Sun Aug 31 17:16:49 2003
@@ -272,7 +272,7 @@
     mentry = dirlist;
     dirlist = mentry->next;
     unhand_array(array)->body[i] =
-      (Hjava_lang_Object*)stringC2Java(mentry->name);
+      (Hjava_lang_Object*)checkPtr(stringC2Java(mentry->name));
     /* if allocation fails, continue freeing mentries in
        this loop. */
     oom |= !unhand_array(array)->body[i];
Index: kaffe/libraries/clib/io/FileDescriptor.c
diff -u kaffe/libraries/clib/io/FileDescriptor.c:1.5 kaffe/libraries/clib/io/FileDescriptor.c:1.6
--- kaffe/libraries/clib/io/FileDescriptor.c:1.5	Sat Aug 30 20:24:59 2003
+++ kaffe/libraries/clib/io/FileDescriptor.c	Sun Aug 31 17:16:49 2003
@@ -274,7 +274,7 @@
 
   if (rc == 0 && S_ISREG(statbuf.st_mode)) {
     *fileSize = statbuf.st_size;
-  }
+  } else
   if (rc == 0)
   {
     rc = EINVAL;
Index: kaffe/libraries/clib/net/NetworkInterface.c
diff -u kaffe/libraries/clib/net/NetworkInterface.c:1.2 kaffe/libraries/clib/net/NetworkInterface.c:1.3
--- kaffe/libraries/clib/net/NetworkInterface.c:1.2	Sat Aug 30 14:18:25 2003
+++ kaffe/libraries/clib/net/NetworkInterface.c	Sun Aug 31 17:16:49 2003
@@ -97,7 +97,7 @@
 			&((struct sockaddr_in *)sa)->sin_addr,
 			addr,
 			NII_MAX_ADDRESS_SIZE);
-	      address_string = stringC2Java(addr);
+	      address_string = checkPtr(stringC2Java(addr));
 	      break;
 #if defined(AF_INET6)
 	    case AF_INET6:
@@ -105,7 +105,7 @@
 			&((struct sockaddr_in6 *)sa)->sin6_addr,
 			addr,
 			NII_MAX_ADDRESS_SIZE);
-	      address_string = stringC2Java(addr);
+	      address_string = checkPtr(stringC2Java(addr));
 #endif
 	    default:
 	      /* XXX What to do? */
@@ -133,7 +133,7 @@
   while (ifa != NULL)
     {
       struct Hjava_lang_String* iface_name =
-	stringC2Java(ifa->ifa_name);
+	checkPtr(stringC2Java(ifa->ifa_name));
       struct Hjava_net_InetAddress* addr;
       
       addr = getInetAddress(ifa);
Index: kaffe/libraries/clib/net/PlainDatagramSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.27 kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.28
--- kaffe/libraries/clib/net/PlainDatagramSocketImpl.c:1.27	Sat Aug 30 14:18:25 2003
+++ kaffe/libraries/clib/net/PlainDatagramSocketImpl.c	Sun Aug 31 17:16:49 2003
@@ -17,6 +17,7 @@
 #include <native.h>
 #include "java_lang_Integer.h"
 #include "java_io_FileDescriptor.h"
+#include "java_io_InterruptedIOException.h"
 #include "java_net_DatagramPacket.h"
 #include "java_net_NetworkInterface.h"
 #include "java_net_SocketAddress.h"
@@ -29,6 +30,7 @@
 #include <jsyscall.h>
 #include "../../../kaffe/kaffevm/debug.h"
 #include "../../../kaffe/kaffevm/itypes.h"
+#include "../../../kaffe/kaffevm/exception.h"
 
 /*
  * Supported socket options
@@ -241,9 +243,12 @@
 	int alen = sizeof(addr);
 	HArrayOfByte *array_address;
 	int i;
+	int to_read, offset;
 
 	assert(this != NULL);
-	assert(pkt != NULL);
+	if (pkt == NULL || unhand(pkt)->buffer == NULL)
+		SignalError("java.lang.NullPointerException", "null datagram packet");
+	assert(unhand(pkt)->length <= unhand(unhand(pkt)->buffer)->length);
 
 DBG(NATIVENET,
 	dprintf("datagram_receive(%p, %p [%d bytes])\n",
@@ -254,25 +259,39 @@
 	addr.sin_port = htons(unhand(this)->localPort);
 
 	/* XXX should assert (unhand(pkt)->length <= unhand_array(unhand(pkt)->buf)->length), no? */
-
-	rc = KRECVFROM(unhand(unhand(this)->fd)->nativeFd,
-		&(unhand_array(unhand(pkt)->buffer)->body)[unhand(pkt)->offset],
-		unhand(pkt)->length, 0, (struct sockaddr*)&addr,
-		&alen, unhand(this)->timeout, &r);
-	switch( rc )
-	{
-	case 0:
-		break;
-	case ETIMEDOUT:
-		SignalError("java.net.SocketTimeoutException", SYS_ERROR(rc));
-		break;
-	case EINTR:
-		SignalError("java.io.InterruptedIOException", SYS_ERROR(rc));
-		break;
-	default:
-		SignalError("java.net.SocketException", SYS_ERROR(rc));
-		break;
-	}
+        offset = unhand(pkt)->offset; 
+	to_read = unhand(pkt)->length;
+        do { 
+	        rc = KRECVFROM(unhand(unhand(this)->fd)->nativeFd,
+			       &(unhand_array(unhand(pkt)->buffer)->body)[offset],
+			       to_read, 0, (struct sockaddr*)&addr,
+			       &alen, unhand(this)->timeout, &r);
+		switch( rc )
+		{
+		case 0:
+		        break;
+		case ETIMEDOUT: {
+		        struct Hjava_io_InterruptedIOException* except;
+		  
+			except = (struct Hjava_io_InterruptedIOException *)
+			  execute_java_constructor(
+						   "java.net.SocketTimeoutException", 0, 0,
+						   "([Ljava/lang/String;)V",
+						   checkPtr(stringC2Java("Read timed out")));
+			except->bytesTransferred = offset-unhand(pkt)->offset;
+			
+			throwException((struct Hjava_lang_Throwable*)except);
+			break;
+		}
+		case EINTR:
+		        break;
+		default:
+		        SignalError("java.net.SocketException", SYS_ERROR(rc));
+			break;
+		}
+		to_read -= r;
+		offset += r;
+	} while (rc == EINTR);
 
 	unhand(pkt)->length = r;
 	unhand(pkt)->port = ntohs(addr.sin_port);
Index: kaffe/libraries/clib/net/PlainSocketImpl.c
diff -u kaffe/libraries/clib/net/PlainSocketImpl.c:1.31 kaffe/libraries/clib/net/PlainSocketImpl.c:1.32
--- kaffe/libraries/clib/net/PlainSocketImpl.c:1.31	Sat Aug 30 14:18:25 2003
+++ kaffe/libraries/clib/net/PlainSocketImpl.c	Sun Aug 31 17:16:49 2003
@@ -20,12 +20,14 @@
 #include "java_net_InetAddress.h"
 #include "java_net_PlainSocketImpl.h"
 #include "java_net_SocketOptions.h"
+#include "java_io_InterruptedIOException.h"
 #include "nets.h"
 #include <jsyscall.h>
 #include <jthread.h>
 #include "../../../kaffe/kaffevm/debug.h"
 #include "../../../kaffe/kaffevm/object.h"
 #include "../../../kaffe/kaffevm/itypes.h"
+#include "../../../kaffe/kaffevm/exception.h"
 
 #include "dummyin6.h"
 
@@ -313,11 +315,10 @@
 	    )
 
 	alen = sizeof(addr);
-	rc = KACCEPT(unhand(unhand(this)->fd)->nativeFd, (struct sockaddr*)&addr, &alen, unhand(this)->timeout, &r);
-	if (rc == EINTR) {
-		SignalError("java.io.InterruptedIOException", 
-			    "Accept was interrupted");
-	}
+	do {
+	        rc = KACCEPT(unhand(unhand(this)->fd)->nativeFd,
+			     (struct sockaddr*)&addr, &alen, unhand(this)->timeout, &r);
+	} while (rc == EINTR);
 	if (rc == ETIMEDOUT) {
 	        SignalError("java.net.SocketTimeoutException",
 			    "Accept timed out");
@@ -562,6 +563,7 @@
         ssize_t r;
 	int rc;
 	int fd;
+	int total_read;
 
 	DBG(NATIVENET,
 	    dprintf("socket_read(%p, %p, %d, %d)\n", 
@@ -573,24 +575,32 @@
 		SignalError("java.io.IOException", "fd invalid"); 
 	}
 
-        rc = KSOCKREAD(fd, &unhand_array(buf)->body[offset], len, unhand(this)->timeout, &r);
-	if (rc == EINTR || rc == ETIMEDOUT) {
-		SignalError("java.io.InterruptedIOException", 
-			    "Read was interrupted");
-	}
-	if (rc == ETIMEDOUT) {
-	        SignalError("java.net.SocketTimeoutException",
-			    "Read timed out");
-	}
-        if (rc) {
-                SignalError("java.io.IOException", SYS_ERROR(rc));
-        }
-        else if (r == 0 && len > 0) {
-                return (-1);    /* EOF */
-        }
-        else {
-                return (r);
-        }
+	total_read = 0;
+	r = 0;
+	do {
+	         rc = KSOCKREAD(fd, &unhand_array(buf)->body[offset], len, unhand(this)->timeout, &r);
+
+		 if (rc == ETIMEDOUT) {
+		         struct Hjava_io_InterruptedIOException* except;
+
+			 except = (struct Hjava_io_InterruptedIOException *)
+			   execute_java_constructor(
+						    "java.net.SocketTimeoutException", 0, 0,
+						    "(Ljava/lang/String;)V",
+						    checkPtr(stringC2Java("Read was interrupted")));
+			 except->bytesTransferred = r;
+	      
+			 throwException((struct Hjava_lang_Throwable*)except);
+		 } else if (rc != EINTR && rc != 0) {
+		   SignalError("java.io.IOException", SYS_ERROR(rc));
+		 } else if (rc == 0 && r == 0 && len > 0) {
+		   return (-1);
+		 }
+		 offset += r;
+		 len -= r;
+		 total_read += r;
+	} while (rc == EINTR);
+	return (total_read);
 }
 
 void
Index: kaffe/libraries/javalib/java/io/File.java
diff -u kaffe/libraries/javalib/java/io/File.java:1.35 kaffe/libraries/javalib/java/io/File.java:1.36
--- kaffe/libraries/javalib/java/io/File.java:1.35	Sat Aug 30 14:18:31 2003
+++ kaffe/libraries/javalib/java/io/File.java	Sun Aug 31 17:16:50 2003
@@ -42,6 +42,8 @@
 import java.net.URL;
 import gnu.classpath.Configuration;
 import gnu.java.io.PlatformHelper;
+import java.util.LinkedList;
+import java.util.Iterator;
 
 /* Written using "Java Class Libraries", 2nd edition, ISBN 0-201-31002-3
  * "The Java Language Specification", ISBN 0-201-63451-1
@@ -1241,6 +1243,37 @@
       s.checkRead (path);
   }
 
+  static class DeleteFileHelper extends Thread
+  {
+    LinkedList filesToDelete = new LinkedList();
+
+    public DeleteFileHelper()
+    {
+      Runtime.getRuntime().addShutdownHook (this);
+    }
+    
+    public void run()
+    {
+      Iterator fileIterator = filesToDelete.iterator();
+
+      while (fileIterator.hasNext())
+	{
+	  String path = (String)fileIterator.next();
+	  try
+	    {
+	      File f = new File(path);
+
+	      f.delete();
+	    }
+	  catch (Throwable _)
+	    {
+	    }
+	}
+    }
+  }
+
+  private static DeleteFileHelper deleteHelper = new DeleteFileHelper();
+
   /** 
    * Calling this method requests that the file represented by this object
    * be deleted when the virtual machine exits.  Note that this request cannot
@@ -1258,11 +1291,8 @@
     if (sm != null)
       sm.checkDelete(path);
 
-    // Sounds like we need to do some VM specific stuff here. We could delete
-    // the file in finalize() and set FinalizeOnExit to true, but delete on
-    // finalize != delete on exit and we should not be setting up system
-    // parameters without the user's knowledge.
-    // FIXME: ********IMPLEMENT ME!!!!!!***************
+    deleteHelper.filesToDelete.add (getAbsolutePath());
+    
     return;
   }
 
Index: kaffe/libraries/javalib/java/lang/Runtime.java
diff -u kaffe/libraries/javalib/java/lang/Runtime.java:1.25 kaffe/libraries/javalib/java/lang/Runtime.java:1.26
--- kaffe/libraries/javalib/java/lang/Runtime.java:1.25	Sat Jul 26 17:28:36 2003
+++ kaffe/libraries/javalib/java/lang/Runtime.java	Sun Aug 31 17:16:50 2003
@@ -240,13 +240,21 @@
        hook_enum = shutdownHooks.elements();
        while (hook_enum.hasMoreElements()) {
 	       Thread hook = (Thread)hook_enum.nextElement();
+	       boolean join_interrupted = false;
 
 	       /* XXX Should this timeout? */
-	       try {
-		       hook.join();
-	       } catch (Exception e) {
-		       e.printStackTrace();
+	       do
+	       {
+		       join_interrupted = false;
+		       try {
+			       hook.join();
+		       } catch (InterruptedException _) {
+			       join_interrupted = true;
+		       } catch (Exception e) {
+			       e.printStackTrace();
+		       }
 	       }
+	       while (join_interrupted);
        }
        return true;
 }
Index: kaffe/libraries/javalib/java/lang/Thread.java
diff -u kaffe/libraries/javalib/java/lang/Thread.java:1.42 kaffe/libraries/javalib/java/lang/Thread.java:1.43
--- kaffe/libraries/javalib/java/lang/Thread.java:1.42	Wed Jul  9 10:01:57 2003
+++ kaffe/libraries/javalib/java/lang/Thread.java	Sun Aug 31 17:16:50 2003
@@ -240,7 +240,7 @@
 		}
 	}
 	else {
-		/* Can't to it in java - so ask the system to try */
+		/* Can't do it in java - so ask the system to try */
 		interrupt0();
 	}
 }
Index: kaffe/test/regression/Makefile.am
diff -u kaffe/test/regression/Makefile.am:1.81 kaffe/test/regression/Makefile.am:1.82
--- kaffe/test/regression/Makefile.am:1.81	Mon Aug 18 06:34:46 2003
+++ kaffe/test/regression/Makefile.am	Sun Aug 31 17:16:50 2003
@@ -149,7 +149,8 @@
 
 TEST_REFLECTION = \
 	ReflectInvoke.java \
-	InvTarExcTest.java 
+	InvTarExcTest.java \
+	DeleteFile.java
 
 ## tests for ClassLoader
 TEST_CLASS_LOADING = \
@@ -205,7 +206,6 @@
 ## Test interrupting I/O
 ## This is kind of tricky, and Sun doesn't support it.
 TEST_INTERRUPTING_IO = \
-	SoInterrupt.java \
 	sysdepCallMethod.java 
 
 ## This one is skipped unless you --enable-debug.
Index: kaffe/test/regression/Makefile.in
diff -u kaffe/test/regression/Makefile.in:1.134 kaffe/test/regression/Makefile.in:1.135
--- kaffe/test/regression/Makefile.in:1.134	Mon Aug 18 06:34:46 2003
+++ kaffe/test/regression/Makefile.in	Sun Aug 31 17:16:50 2003
@@ -383,7 +383,8 @@
 
 TEST_REFLECTION = \
 	ReflectInvoke.java \
-	InvTarExcTest.java 
+	InvTarExcTest.java \
+	DeleteFile.java
 
 
 TEST_CLASS_LOADING = \
===================================================================
Checking out kaffe/test/regression/SoInterrupt.java
RCS:  /home/cvs/kaffe/kaffe/test/regression/Attic/SoInterrupt.java,v
VERS: 1.5
***************
--- kaffe/test/regression/SoInterrupt.java	Sun Aug 31 17:19:02 2003
+++ /dev/null	Sun Aug  4 19:57:58 2002
@@ -1,136 +0,0 @@
-/**
- * Test interruptable I/O.
- *
- * Note that this test will not run under Sun's JDK1.2 on Solaris, see
- * http://developer.java.sun.com/developer/bugParade/bugs/4178050.html
- *
- * It's unlikely to work on Windows either, see
- * http://developer.java.sun.com/developer/bugParade/bugs/4154947.html
- *
- * It it supported by Kaffe's jthreads, though it may not work under other
- * threading systems either.  XXX
- *
- * @author Godmar Back <gback@cs.utah.edu>
- */
-import java.net.*;
-import java.io.*;
-
-public class SoInterrupt {
-    public static void main(String av[]) throws Exception {
-	final boolean verbose = av.length > 0;
-	final String foo = "foo";
-	final Thread main = Thread.currentThread();
-
-	int tryport = 45054;
-	ServerSocket server;
-	for(;;++tryport) {
-	    try {
-		server = new ServerSocket(tryport);
-		break;
-	    } catch (IOException _) {}
-	}
-        final int port = tryport;
-	Thread watchdog = new Thread() {
-	    public void run() {
-		try {
-		    Thread.sleep(10 * 1000);
-		} catch (InterruptedException _) { }
-		System.out.println("Watchdog Failure: Time out.");
-		System.exit(1);
-	    }
-	};
-	watchdog.start();
-
-        Thread t = new Thread() {
-            public void run() {
-		try {
-		    // let main thread wait a while
-		    try {
-			Thread.sleep(1000);
-		    } catch (InterruptedException e) {
-			System.out.println("Failure " + e);
-		    }
-		    if (verbose)
-			System.out.println("interrupting " + main);
-		    // interrupt it
-		    main.interrupt();
-		    // give it some more time
-		    try {
-			Thread.sleep(1000);
-		    } catch (InterruptedException e) {
-			System.out.println("Failure " + e);
-		    }
-
-		    // now connect
-		    if (verbose)
-			System.out.println("connecting...");
-		    Socket s = new Socket(InetAddress.getByName(null), port);
-		    // wait some
-		    try {
-			Thread.sleep(1000);
-		    } catch (InterruptedException e) {
-			System.out.println("Failure " + e);
-		    }
-
-		    if (verbose)
-			System.out.println("interrupting again " + main);
-		    // interrupt it again
-		    main.interrupt();
-		    // wait some more
-		    try {
-			Thread.sleep(1000);
-		    } catch (InterruptedException e) {
-			System.out.println("Failure " + e);
-		    }
-
-		    // now finish up
-		    PrintWriter p = new PrintWriter(s.getOutputStream());
-		    p.println(foo);
-		    p.close();
-		} catch (Exception e) {
-		    System.out.println("Failure " + e);
-		}
-            }
-        };
-        t.start();
-        Socket rsocket = null;
-	try {
-	    if (verbose)
-		System.out.println("waiting for client...");
-	    rsocket = server.accept(); 
-	    if (verbose)
-		System.out.println("accepted..." + rsocket);
-	} catch (InterruptedIOException e) {
-	    if (verbose)
-		System.out.println(e);
-	    System.out.println("Success 1.");
-	}
-	if (verbose)
-	    System.out.println("waiting for client again...");
-	rsocket = server.accept(); 
-	System.out.println("Success 2.");
-	InputStream is = rsocket.getInputStream();
-	LineNumberReader r = new LineNumberReader(new InputStreamReader(is));
-        byte []b = null;
-        try {
-	    r.readLine();
-	} catch (InterruptedIOException e) {
-	    // System.out.println(e);
-	    System.out.println("Success 3.");
-	}
-	String s = r.readLine();
-	if (s.equals(foo)) {
-	    System.out.println("Success 4.");
-	} else {
-	    System.out.println("Failure: `" + s + "'");
-	}
-	System.exit(0);
-    }
-}
-
-/* Expected Output:
-Success 1.
-Success 2.
-Success 3.
-Success 4.
-*/