From ee02cfd23facb3404fc377f643b213c2f498474d Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Thu, 18 Sep 2014 20:53:10 -0700 Subject: [PATCH] rgw: calculate hash after writing data Since data is written asynchronously, we should do the hash calculation while it's pending. Signed-off-by: Yehuda Sadeh (cherry picked from commit 5bb94ede19a50543a02a8019ed6c9680b3852d4e) --- src/rgw/rgw_rados.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index ffa8a723ef32c..44ff649202fb0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -1084,11 +1084,11 @@ int RGWPutObjProcessor_Atomic::handle_data(bufferlist& bl, off_t ofs, MD5 *hash, bool exclusive = (!write_ofs && immutable_head()); /* immutable head object, need to verify nothing exists there we could be racing with another upload, to the same object and cleanup can be messy */ - if (hash) { - hash->Update((const byte *)bl.c_str(), bl.length()); - } int ret = write_data(bl, write_ofs, phandle, exclusive); if (ret >= 0) { /* we might return, need to clear bl as it was already sent */ + if (hash) { + hash->Update((const byte *)bl.c_str(), bl.length()); + } bl.clear(); } return ret; -- 2.39.5