harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ray Chen (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-6473) [classlib][nio]SocketChannel's bug when then main thread is in blocking read() and another thread trired to close it
Date Mon, 15 Mar 2010 08:11:27 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-6473?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12845228#action_12845228
] 

Ray Chen commented on HARMONY-6473:
-----------------------------------

For Linux following work around may solve this bug:

      do {
          tm = 100;
          result = poll (&my_pollfd, 1, tm);
          if (!hysock_socketIsValid (hysocketP)) {
              throwJavaNetSocketException (env, HYPORT_ERROR_SOCKET_BADSOCKET);
              return (jint) - 1;
          }
      } while(result <= 0);//while (result == -1 && errno == EINTR);

which means break the endless poll into countless small time slice, every time to check the
hysocketP.

However, this may cause potential side-effect, in the svn log I see the patch with following
log:
"Ensure that interruptions in the poll call do not cause early return of the socket read,
especially since the signal may be a GC interrupt."

Index: OSNetworkSystemLinux.c
===================================================================
--- OSNetworkSystemLinux.c	(revision 761236)
+++ OSNetworkSystemLinux.c	(revision 761237)
@@ -71,7 +71,9 @@
   my_pollfd.fd = hysocketP->sock;
   my_pollfd.events = POLLIN | POLLPRI;
   my_pollfd.revents = 0;
-  result = poll (&my_pollfd, 1, timeout);
+  do {
+    result = poll (&my_pollfd, 1, timeout);
+  } while (result == -1 && errno == EINTR);
   if (result == 0)
     return HYPORT_ERROR_SOCKET_TIMEOUT;

Any comments about this?

> [classlib][nio]SocketChannel's bug when then main thread is in blocking read() and another
thread trired to close it
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-6473
>                 URL: https://issues.apache.org/jira/browse/HARMONY-6473
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>         Environment: Windows, Linux
>            Reporter: Ray Chen
>         Attachments: Harmony6473_TestCase.java
>
>
> On Windows, throws the java.net.SocketException, and the exception trace as following:
> Uncaught exception in main:
> java.net.SocketException: The socket argument is not a socket
> 	at org.apache.harmony.luni.platform.OSNetworkSystem.read(OSNetworkSystem.java)
> 	at org.apache.harmony.nio.internal.SocketChannelImpl.readImpl(SocketChannelImpl.java:455)
> 	at org.apache.harmony.nio.internal.SocketChannelImpl.read(SocketChannelImpl.java:373)
> 	at CMVC151710_SocketChannel.runTest(CMVC151710_SocketChannel.java:48)
> 	at CMVC151710_SocketChannel.main(CMVC151710_SocketChannel.java:14)
> On linux, the blocking read() hang forever

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message