[ 
https://issues.apache.org/jira/browse/HADOOP-20067?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18145062#comment-18145062
 ] 

ASF GitHub Bot commented on HADOOP-20067:
-----------------------------------------

LuciferYang commented on PR #8931:
URL: https://github.com/apache/hadoop/pull/8931#issuecomment-6889796581

   Thank you @slfan1989 




> RawLocalFileSystem: broken double-checked locking in 
> LocalFSFileInputStream#getAsyncChannel() can leak AsynchronousFileChannels
> -------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HADOOP-20067
>                 URL: https://issues.apache.org/jira/browse/HADOOP-20067
>             Project: Hadoop Common
>          Issue Type: Bug
>          Components: fs
>    Affects Versions: 3.6.0
>            Reporter: Yang Jie
>            Assignee: Yang Jie
>            Priority: Minor
>              Labels: pull-request-available
>             Fix For: 3.6.0
>
>
> LocalFSFileInputStream#getAsyncChannel() checks {{asyncChannel == null}} 
> outside the lock but not again inside it, and the field is not volatile. When 
> two threads make the first readVectored() call on the same stream, both can 
> open an AsynchronousFileChannel. The last assignment wins and close() only 
> closes that channel, so the other one keeps its file descriptor open until 
> the JVM exits. PositionedReadable requires positioned reads, readVectored 
> included, to be thread-safe.
> The fix makes the field volatile and checks it again inside the synchronized 
> block. This was pointed out in the review of HADOOP-19901: 
> https://github.com/apache/hadoop/pull/8511#discussion_r4452981403. A 
> readVectored() call after close() still opens a new channel; this change does 
> not touch that.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to