commit-classpath
[Top][All Lists]
Advanced

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

Retry ServerSocket.accept (java-net.c _accept) on EINTR


From: Mark Wielaard
Subject: Retry ServerSocket.accept (java-net.c _accept) on EINTR
Date: Sun, 25 Apr 2004 18:17:40 +0200

Hi,

This fixes a long standing bug were accept() would throw a IOException
when the system call got interrupted. This happens for example with VMs
like jamvm which uses signals to tell all threads to suspend or sablevm
which you can send SIGQUIT to get a stacktrace of the current thread.

2004-04-25  Mark Wielaard  <address@hidden>

       * native/jni/java-net/javanet.c (_javanet_accept): Retry when we get
       EINTR.

Committed.

Cheers,

Mark
Index: native/jni/java-net/javanet.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/java-net/javanet.c,v
retrieving revision 1.17
diff -u -r1.17 javanet.c
--- native/jni/java-net/javanet.c       21 Apr 2004 11:03:00 -0000      1.17
+++ native/jni/java-net/javanet.c       25 Apr 2004 16:12:29 -0000
@@ -789,12 +789,17 @@
     }
 
   /* Accept the connection */
-  /******* Do we need to look for EINTR? */
-  TARGET_NATIVE_NETWORK_SOCKET_ACCEPT(fd,newfd,result);
-  if (result != TARGET_NATIVE_OK)
+  while (result != TARGET_NATIVE_OK)
     {
-       JCL_ThrowException(env, IO_EXCEPTION, "Internal error: 
_javanet_accept(): ");
-       return;
+      TARGET_NATIVE_NETWORK_SOCKET_ACCEPT(fd,newfd,result);
+      if (result != TARGET_NATIVE_OK
+         && (TARGET_NATIVE_LAST_ERROR()
+             != TARGET_NATIVE_ERROR_INTERRUPT_FUNCTION_CALL))
+       {
+         JCL_ThrowException(env, IO_EXCEPTION,
+                            "Internal error: _javanet_accept(): ");
+         return;
+       }
     }
 
   /* Populate instance variables */ 

Attachment: signature.asc
Description: This is a digitally signed message part


reply via email to

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