-
Notifications
You must be signed in to change notification settings - Fork 89
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
refactor: catch errno EINTR when reading and writing files instead of EAGAIN #242
Conversation
… EAGAIN EAGAIN error code Appears only when the O_NONBLOCK option is set and there is no more content in the file to read. Signed-off-by: guoxiangCN <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #242 +/- ##
==========================================
+ Coverage 97.18% 97.19% +0.01%
==========================================
Files 30 30
Lines 9368 9368
==========================================
+ Hits 9104 9105 +1
+ Misses 264 263 -1
Continue to review full report at Codecov.
|
Thanks for the attention. According to rust, a
So it appears we should remove the retry looping entirely. For consistency do the same for the FYI we already have retry logic at a higher level, so this change won't affect the IO results. raft-engine/src/file_pipe_log/log_file.rs Line 203 in ee0f6cf
raft-engine/src/file_pipe_log/log_file.rs Line 107 in ee0f6cf
|
How about direclty add an extra option |
Okay, I didn't notice the higher judgment. However, according to the constraints of the write method you mentioned, retrying the entire while loop will also lead to a semi successful and semi failed state of data writing, that is, partial success and partial failure. |
Having looked closely, I think the implementation here is not very important. We maintain a file offset and use it to write, so a partial successful write can be overwritten correctly afterwards: raft-engine/src/env/default.rs Lines 215 to 216 in d2b41e0
And the |
@LykxSassinator No, non block is only useful for network fd. |
EAGAIN error code Appears only when the O_NONBLOCK option is set and there is no more content in the file to read.
If a read() is interrupted by a signal before it reads any data, it shall return -1 with errno set to [EINTR].