8205959: Do not restart close if errno is EINTR
authorigerasim
Thu, 28 Jun 2018 01:10:09 -0700
changeset 50869 be1020446dd5
parent 50868 addda6247cb0
child 50870 830b05ca7f58
8205959: Do not restart close if errno is EINTR Reviewed-by: alanb, vtewari
src/java.base/linux/native/libnet/linux_close.c
--- a/src/java.base/linux/native/libnet/linux_close.c	Thu Jun 28 10:05:43 2018 +0200
+++ b/src/java.base/linux/native/libnet/linux_close.c	Thu Jun 28 01:10:09 2018 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -290,13 +290,13 @@
          * And close/dup the file descriptor
          * (restart if interrupted by signal)
          */
-        do {
-            if (fd1 < 0) {
-                rv = close(fd2);
-            } else {
+        if (fd1 < 0) {
+            rv = close(fd2);
+        } else {
+            do {
                 rv = dup2(fd1, fd2);
-            }
-        } while (rv == -1 && errno == EINTR);
+            } while (rv == -1 && errno == EINTR);
+        }
 
         /*
          * Send a wakeup signal to all threads blocked on this