This is an automated email from the ASF dual-hosted git repository.
apitrou pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/main by this push:
new e68236ae36 GH-46928: [C++] Retry on EINTR while opening file in
FileOpenReadable (#47629)
e68236ae36 is described below
commit e68236ae36385127b851ca129ed0cbc1078cae48
Author: Ayush Bansal <[email protected]>
AuthorDate: Wed Sep 24 12:18:43 2025 +0530
GH-46928: [C++] Retry on EINTR while opening file in FileOpenReadable
(#47629)
### Rationale for this change
File open should be retried when it fails due to EINTR
### What changes are included in this PR?
checking the errno and retrying file open inside FileOpenReadable. This is
already done at other places in io_util.cc
### Are these changes tested?
No, hard to reproduce
### Are there any user-facing changes?
On slow file systems like FUSE, file open would be retried instead of
exiting on receiving interrupt.
* GitHub Issue: #46928
Authored-by: Ayush Bansal <[email protected]>
Signed-off-by: Antoine Pitrou <[email protected]>
---
cpp/src/arrow/util/io_util.cc | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/cpp/src/arrow/util/io_util.cc b/cpp/src/arrow/util/io_util.cc
index 6e8c1b72b8..50f3bd9a15 100644
--- a/cpp/src/arrow/util/io_util.cc
+++ b/cpp/src/arrow/util/io_util.cc
@@ -1070,8 +1070,11 @@ Result<FileDescriptor> FileOpenReadable(const
PlatformFilename& file_name) {
}
fd = FileDescriptor(ret);
#else
- int ret = open(file_name.ToNative().c_str(), O_RDONLY);
- if (ret < 0) {
+ int ret;
+ do {
+ ret = open(file_name.ToNative().c_str(), O_RDONLY);
+ } while (ret == -1 && errno == EINTR);
+ if (ret == -1) {
return IOErrorFromErrno(errno, "Failed to open local file '",
file_name.ToString(),
"'");
}
@@ -1137,7 +1140,10 @@ Result<FileDescriptor> FileOpenWritable(const
PlatformFilename& file_name,
oflag |= O_RDWR;
}
- int ret = open(file_name.ToNative().c_str(), oflag, 0666);
+ int ret;
+ do {
+ ret = open(file_name.ToNative().c_str(), oflag, 0666);
+ } while (ret == -1 && errno == EINTR);
if (ret == -1) {
return IOErrorFromErrno(errno, "Failed to open local file '",
file_name.ToString(),
"'");