From aec7efc3af42d375c9a5efc99d33f072be06cc97 Mon Sep 17 00:00:00 2001 From: Takeshi Nakatani Date: Sat, 5 Nov 2022 11:45:28 +0900 Subject: [PATCH] Updated comments in curl.cpp (related to #1827) (#2052) --- src/curl.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/curl.cpp b/src/curl.cpp index 042e227..cdf29e5 100644 --- a/src/curl.cpp +++ b/src/curl.cpp @@ -3304,8 +3304,13 @@ int S3fsCurl::PutRequest(const char* tpath, headers_t& meta, int fd) return -EINVAL; } if(-1 != fd){ - // TODO: is this necessary? // duplicate fd + // + // [NOTE] + // This process requires FILE*, then it is linked to fd with fdopen. + // After processing, the FILE* is closed with fclose, and fd is closed together. + // The fd should not be closed here, so call dup here to duplicate it. + // int fd2; if(-1 == (fd2 = dup(fd)) || -1 == fstat(fd2, &st) || 0 != lseek(fd2, 0, SEEK_SET) || NULL == (file = fdopen(fd2, "rb"))){ S3FS_PRN_ERR("Could not duplicate file descriptor(errno=%d)", errno);