Skip to content
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

Add Lwt_unix.pread and pwrite #768

Merged
merged 7 commits into from
Mar 7, 2020
Merged

Conversation

chambart
Copy link
Contributor

@chambart chambart commented Mar 5, 2020

I just happened to need those function at the same time as #767. Hence, here it is.

I had to document that pwrite and pread leaves the current file position undefined because unix pread and windows ReadFile don't agree on that. This doesn't seem to be a serious problem. I don't expect anybody to be using both pread and read/write on the same fd.

Thanks for maintaining a functional test suite for Windows I would have been too lazy to bother starting a VM to test that !

Otherwise, I don't know whether the test suite triggers both the job and standard version of the functions. If it doesn't, how should I do this ?

Copy link
Collaborator

@aantron aantron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Otherwise, I don't know whether the test suite triggers both the job and standard version of the functions. If it doesn't, how should I do this ?

There probably isn't a legitimate way to trigger the non-blocking version of these functions. To my knowledge, on both Unix and Windows, all fds that allow positional I/O also do not support non-blocking I/O. The only exception to that may be asynchronous HANDLEs on Windows, but we don't open HANDLEs in asynchronous mode.

You can still force the non-blocking code to run by calling Lwt_unix.set_blocking ~set_flags:false fd false in additional test cases for this. The non-blocking code added in this PR will then run, but the underlying pread (etc.) calls will still block, and it would be a bug in a user's program if it did this.

You can check whether the code is running by either inserting prints or running make coverage and looking at the branches.

cc @tomjridge

src/unix/lwt_unix.cppo.mli Show resolved Hide resolved
src/unix/lwt_unix.cppo.ml Outdated Show resolved Hide resolved
src/unix/lwt_unix.cppo.mli Outdated Show resolved Hide resolved
@aantron aantron added this to the 5.2.0 milestone Mar 5, 2020
@tomjridge
Copy link

Thanks you very much @chambart and @aantron !

@aantron aantron merged commit a77e6f2 into ocsigen:master Mar 7, 2020
@aantron
Copy link
Collaborator

aantron commented Mar 7, 2020

Thanks @chambart! I agreed with making the functions separate, rather than using an optional argument.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants