8000 FileDescriptor MODE vs jUring operation · Issue #17 · davidtos/JUring · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

FileDescriptor MODE vs jUring operation #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
manticore-projects opened this issue Apr 16, 2025 · 4 comments
Open

FileDescriptor MODE vs jUring operation #17

manticore-projects opened this issue Apr 16, 2025 · 4 comments
Labels
bug Something isn't working

Comments

@manticore-projects
Copy link

Greetings!

When creating the FileDescriptor I have to decide on the mode (read or write).
However, when calling jUring.prepareWrite this mode will not be enforced or checked. I can still prepareWrite on a READ file descriptor and it will pass silently (without actually writing anything).

Reproducer:

        Files.write(Path.of("src/test/resources/write_file"), "Clean content".getBytes());

        String input = "Hello, from Java";
        var inputBytes = input.getBytes();

        List<Long> ids = new ArrayList<>();
        List<Long> completedIds = new ArrayList<>();

        try(FileDescriptor fd = new FileDescriptor("src/test/resources/write_file", Flag.READ, 0)) {

            ids.add(jUring.prepareWrite(fd, inputBytes, 0));
            ids.add(jUring.prepareWrite(fd, inputBytes, 0));
            ids.add(jUring.prepareWrite(fd, inputBytes, 0));

            jUring.submit();

            for (int i = 0; i < ids.size(); i++) {
                Result result = jUring.waitForResult();
                completedIds.add(result.getId());
            }

            assertEquals(completedIds.size(), ids.size());
            assertThat(completedIds).containsAll(ids);

Btw, this test has the name mixedReadAndWrite but I can see only writes? Where is the mix or read please?

@davidtos
Copy link
Owner
davidtos commented Apr 17, 2025

Hi,

Thanks for taking such a close look at the code, and code to reproduce the issue! I really appreciate that!
This bug should definitely not happen, and will make sure it gets fixed.

About the test name: I accidentally switched the naming of two test around. The test above that one has reads and writes.

Thanks for creating the issue! 👍


  • Note for when this gets picked up: Check how adding file mode checks impacts performance. If performance desegregates to much try to move the checks to compile time with inheritance and method overloading.

@davidtos davidtos added the bug Something isn't working label Apr 17, 2025
@davidtos davidtos moved this to Ready in JUring project Apr 17, 2025
@manticore-projects
Copy link
Author

Thank you so much for the fast round-turn.
I will try it out more.

My goal is to implement a FileChannel based on JUring which can be plugged into a H2 Database for a proof of concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Ready
Development

No branches or pull requests

2 participants
0