-
Type:
Bug
-
Resolution: Not an Issue
-
Priority:
P4
-
None
-
Affects Version/s: None
-
Component/s: core-libs
http://hg.openjdk.java.net/jdk/jdk/file/13acc8e38a29/src/java.base/macosx/native/libnet/bsd_close.c#l291 says
291 {
292 /*
293 * Send a wakeup signal to all threads blocked on this
294 * file descriptor.
295 */
296 threadEntry_t *curr = fdEntry->threads;
297 while (curr != NULL) {
298 curr->intr = 1;
299 pthread_kill( curr->thr, sigWakeup );
300 curr = curr->next;
301 }
302
303 /*
304 * And close/dup the file descriptor
305 * (restart if interrupted by signal)
306 */
307 do {
308 if (fd1 < 0) {
309 rv = close(fd2);
310 } else {
311 rv = dup2(fd1, fd2);
312 }
313 } while (rv == -1 && errno == EINTR);
314
315 }
sending the wakeup signal, and then closing the file descriptor.
In contrast, http://hg.openjdk.java.net/jdk/jdk/file/13acc8e38a29/src/java.base/linux/native/libnet/linux_close.c#l288 says
288 {
289 /*
290 * And close/dup the file descriptor
291 * (restart if interrupted by signal)
292 */
293 if (fd1 < 0) {
294 rv = close(fd2);
295 } else {
296 do {
297 rv = dup2(fd1, fd2);
298 } while (rv == -1 && errno == EINTR);
299 }
300
301 /*
302 * Send a wakeup signal to all threads blocked on this
303 * file descriptor.
304 */
305 threadEntry_t *curr = fdEntry->threads;
306 while (curr != NULL) {
307 curr->intr = 1;
308 pthread_kill( curr->thr, sigWakeup );
309 curr = curr->next;
310 }
311 }
Closing the file descriptor and then sending the wakeup signal. Note the misplaced (?) "And" in the comment at line 290.
Is there a correct order for the waking up and closing? Is one of these files a bug waiting to happen? If there is a reason for the difference, it might be worth a comment.
If it comes down to a vote (!), the implementation in aix_close.c looks like the implementation in bsd_close.c.
291 {
292 /*
293 * Send a wakeup signal to all threads blocked on this
294 * file descriptor.
295 */
296 threadEntry_t *curr = fdEntry->threads;
297 while (curr != NULL) {
298 curr->intr = 1;
299 pthread_kill( curr->thr, sigWakeup );
300 curr = curr->next;
301 }
302
303 /*
304 * And close/dup the file descriptor
305 * (restart if interrupted by signal)
306 */
307 do {
308 if (fd1 < 0) {
309 rv = close(fd2);
310 } else {
311 rv = dup2(fd1, fd2);
312 }
313 } while (rv == -1 && errno == EINTR);
314
315 }
sending the wakeup signal, and then closing the file descriptor.
In contrast, http://hg.openjdk.java.net/jdk/jdk/file/13acc8e38a29/src/java.base/linux/native/libnet/linux_close.c#l288 says
288 {
289 /*
290 * And close/dup the file descriptor
291 * (restart if interrupted by signal)
292 */
293 if (fd1 < 0) {
294 rv = close(fd2);
295 } else {
296 do {
297 rv = dup2(fd1, fd2);
298 } while (rv == -1 && errno == EINTR);
299 }
300
301 /*
302 * Send a wakeup signal to all threads blocked on this
303 * file descriptor.
304 */
305 threadEntry_t *curr = fdEntry->threads;
306 while (curr != NULL) {
307 curr->intr = 1;
308 pthread_kill( curr->thr, sigWakeup );
309 curr = curr->next;
310 }
311 }
Closing the file descriptor and then sending the wakeup signal. Note the misplaced (?) "And" in the comment at line 290.
Is there a correct order for the waking up and closing? Is one of these files a bug waiting to happen? If there is a reason for the difference, it might be worth a comment.
If it comes down to a vote (!), the implementation in aix_close.c looks like the implementation in bsd_close.c.