[crac] RFR: Handle open file descriptors with configurable policies [v12]

Radim Vansa rvansa at openjdk.org
Tue Jul 18 10:04:34 UTC 2023


On Tue, 18 Jul 2023 10:00:43 GMT, Radim Vansa <rvansa at openjdk.org> wrote:

>> When the application does not close some file descriptors through Resources we can use `jdk.crac.resource-policies` pointing to a configuration file that might adjust the behaviour. The file uses a simple YAML-conformant format with individual rules separated by a line with `---`:
>> 
>> 
>> type: file
>> path: /path/to/*.txt
>> action: close
>> ---
>> type: socket
>> localAddress: 127.0.0.1
>> localPort: 8080
>> action: ignore
>> 
>> 
>> Available types:
>> * `file`: supports `path` with 'glob' pattern matching (see FileSystem.getPathMatcher() for details)
>> * `pipe`: anonymous pipes (named pipe is handled as `file`)
>> * `socket`: can be refined using `family`, `localAddress`, `localPort`, `localPath` (in case of Unix sockets), `remoteAddress`, `remotePort` and `remotePath`
>> 
>> Actions depend on each resource, defaulting to `error`, with common options `close` and `ignore`. Files have `reopen` action, too.
>
> Radim Vansa has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 18 commits:
> 
>  - Keep append mode same when reopening FileOutputStream
>  - Merge branch 'crac' into newfd-policies
>  - Add policies to FileDescriptor
>  - Merge branch 'crac' into newfd-policies
>  - Update after review
>  - Cosmetic fixes (imports)
>  - Merge remote-tracking branch 'origin/crac' into newfd-policies
>  - Another rework, without native methods
>  - Don't use numeric FDs, remote _AT_END policies
>  - cleanup
>  - ... and 8 more: https://git.openjdk.org/crac/compare/df3c147a...41bee682

Updated. Notably I had to adjust the native `FOS.open0` method to accept another parameter - by default non-appending reopen would truncate that file.
Also one suboptimal situation is that the FileChannel exposed through FIS/FOS `getChannel()` method is not marked as closed; if there's any operation concurrent to the C/R it might get an unexpected exception. It didn't seem right to close it and add some reopen method through SharedSecrets. See comments in code.

-------------

PR Comment: https://git.openjdk.org/crac/pull/69#issuecomment-1639919086


More information about the crac-dev mailing list