From c4fbec7118182f945b25ef2e11cf566aa359be1d Mon Sep 17 00:00:00 2001 From: Jiaying Ren Date: Wed, 2 Dec 2015 15:52:12 +0800 Subject: [PATCH] rgw: fix partial read mime map issue Signed-off-by: Jiaying Ren --- src/rgw/rgw_tools.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 6f198c9a8a8f..0dfc3e6ec4e0 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -4,6 +4,7 @@ #include #include "common/errno.h" +#include "common/safe_io.h" #include "include/types.h" @@ -141,9 +142,9 @@ static int ext_mime_map_init(CephContext *cct, const char *ext_map) goto done; } - ret = read(fd, buf, st.st_size + 1); + ret = safe_read(fd, buf, st.st_size + 1); if (ret != st.st_size) { - // huh? file size has changed, what are the odds? + // huh? file size has changed? ldout(cct, 0) << "ext_mime_map_init(): raced! will retry.." << dendl; free(buf); close(fd); -- 2.47.3