Skip to content

Commit

Permalink
Hang in PreClose method during dup2 system call
Browse files Browse the repository at this point in the history
During fcntl, dup2 system calls if read/write happens then PreClose method gets hang. This issue is not seen if we Signal/Kill the thread first and then call the preClose method.

Signed-off-by: Shruthi.Shruthi1 <Shruthi.Shruthi1@ibm.com>
  • Loading branch information
shruacha1234 committed Jan 5, 2023
1 parent a8becd5 commit bbc3c5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
* questions.
*/

/*
* ===========================================================================
* (c) Copyright IBM Corp. 2022, 2022 All Rights Reserved
* ===========================================================================
*/
package sun.nio.ch;

import java.io.FileDescriptor;
Expand Down Expand Up @@ -107,8 +112,8 @@ protected void implCloseSelectableChannel() throws IOException {
assert state == ST_CLOSING;
long th = thread;
if (th != 0) {
nd.preClose(fd);
NativeThread.signal(th);
nd.preClose(fd);

// wait for read operation to end
while (thread != 0) {
Expand Down

0 comments on commit bbc3c5d

Please sign in to comment.