RFR 8194929 : Unreferenced FileDescriptors not closed

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

RFR 8194929 : Unreferenced FileDescriptors not closed

roger riggs
Please review a fix for a missing entry in the mapfiles.  The missing
entry point
caused the closing of unreferenced FileDescriptors to be skipped.

The tests for FileInputStream, FileOutputStream, and RandomAccess file
unreferenced
FileDescriptors have been updated to verify the raw fds have been closed.

This fix applies to JDK 10+.

Webrev:
http://cr.openjdk.java.net/~rriggs/webrev-fd-cleanup-8194929/index.html

Issue:
   https://bugs.openjdk.java.net/browse/JDK-8194929

Thanks, Roger

Reply | Threaded
Open this post in threaded view
|

Re: RFR 8194929 : Unreferenced FileDescriptors not closed

Alan Bateman


On 11/01/2018 15:19, Roger Riggs wrote:
> Please review a fix for a missing entry in the mapfiles.  The missing
> entry point
> caused the closing of unreferenced FileDescriptors to be skipped.
Looks good.

>
> The tests for FileInputStream, FileOutputStream, and RandomAccess file
> unreferenced
> FileDescriptors have been updated to verify the raw fds have been closed.
closeCounter is incremented before super.close(). That is good enough
for the original test as it's just checking that close is called. I'm
just wondering if the test methods now need to poll
FileDescriptor::valid or wait until ffd is -1 to ensure to avoid a race
with the getOpenFileDescriptorCount.

-Alan
Reply | Threaded
Open this post in threaded view
|

Re: RFR 8194929 : Unreferenced FileDescriptors not closed

roger riggs
Hi  Alan,

On 1/11/2018 11:14 AM, Alan Bateman wrote:

>
>
> On 11/01/2018 15:19, Roger Riggs wrote:
>> Please review a fix for a missing entry in the mapfiles.  The missing
>> entry point
>> caused the closing of unreferenced FileDescriptors to be skipped.
> Looks good.
>
>>
>> The tests for FileInputStream, FileOutputStream, and RandomAccess
>> file unreferenced
>> FileDescriptors have been updated to verify the raw fds have been
>> closed.
> closeCounter is incremented before super.close(). That is good enough
> for the original test as it's just checking that close is called. I'm
> just wondering if the test methods now need to poll
> FileDescriptor::valid or wait until ffd is -1 to ensure to avoid a
> race with the getOpenFileDescriptorCount.
Holding a reference to the FileDescriptor would prevent it from being
reclaimed and the test would never complete.

Each test waits until the Cleanup object has been reclaimed; if it has
been reclaimed then
the closeCleanup0 has already been called to close the raw fd.

Thanks, Roger