From 1e3af175359d633c3728524396a22f9f33873ff2 Mon Sep 17 00:00:00 2001 From: fang yuxiang Date: Thu, 1 Feb 2018 17:36:46 +0800 Subject: [PATCH] rgw: can't download object with range when compression enabled Fixes: http://tracker.ceph.com/issues/22852 Signed-off-by: fang yuxiang --- src/rgw/rgw_compression.cc | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/rgw/rgw_compression.cc b/src/rgw/rgw_compression.cc index b9637d01d09b9..b1ffa04e15a93 100644 --- a/src/rgw/rgw_compression.cc +++ b/src/rgw/rgw_compression.cc @@ -121,15 +121,17 @@ int RGWGetObj_Decompress::handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len } cur_ofs += bl_len; - off_t ch_len = std::min(out_bl.length() - q_ofs, q_len); - r = next->handle_data(out_bl, q_ofs, ch_len); - if (r < 0) { - lderr(cct) << "handle_data failed with exit code " << r << dendl; - return r; + if (ch_len > 0) { + r = next->handle_data(out_bl, q_ofs, ch_len); + if (r < 0) { + lderr(cct) << "handle_data failed with exit code " << r << dendl; + return r; + } + out_bl.splice(0, q_ofs + ch_len); + q_len -= ch_len; + q_ofs = 0; } - q_len -= ch_len; - q_ofs = 0; return r; } -- 2.39.5