From: Matt Benjamin Date: Sun, 20 Dec 2015 01:27:31 +0000 (-0500) Subject: librgw: fix initialization of string_ref from temporary X-Git-Tag: v10.1.0~382^2~84 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8db2c6a9693d2385dd725a1519b2278b0229983f;p=ceph.git librgw: fix initialization of string_ref from temporary Found by valgrind. The good news: amounts to proof that the sref notation works. Signed-off-by: Matt Benjamin --- diff --git a/src/common/cohort_lru.h b/src/common/cohort_lru.h index 2f83b423055..0baa3a25fc8 100644 --- a/src/common/cohort_lru.h +++ b/src/common/cohort_lru.h @@ -324,6 +324,7 @@ namespace cohort { if (csz) { p.csz = csz; p.cache = (T**) ::operator new(csz * sizeof(T*)); + memset(p.cache, 0, csz * sizeof(T*)); } locks.push_back(&p.lock); } diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 35eaa9f0acc..2c902306273 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -526,7 +526,8 @@ namespace rgw { cct->_conf->rgw_nfs_fhcache_size), fh_lru(cct->_conf->rgw_nfs_lru_lanes, cct->_conf->rgw_nfs_lru_lane_hiwat), - uid(_uid), key(_user_id, _key) { + uid(_uid), key(_user_id, _key), + flags(0) { /* no bucket may be named rgw_fs_inst-(.*) */ fsid = RGWFileHandle::root_name + "rgw_fs_inst-" + @@ -565,6 +566,9 @@ namespace rgw { return fhr; RGWFileHandle::FHCache::Latch lat; + memset(&lat, 0, sizeof(lat)); // XXXX testing + + std::string obj_name{name}; std::string key_name{parent->make_key_name(name)}; @@ -857,9 +861,10 @@ public: return 0; } - int operator()(const boost::string_ref& name, - const boost::string_ref& marker) { + int operator()(const boost::string_ref name, + const boost::string_ref marker) { /* hash offset of name in parent (short name) for NFS readdir cookie */ + std::string sname{name}; uint64_t off = XXH64(name.data(), name.length(), fh_key::seed); *offset = off; /* update traversal cache */ @@ -877,15 +882,15 @@ public: struct req_state* s = get_state(); for (const auto& iter : objs) { + boost::string_ref sref {iter.key.name}; + std::cout << "readdir objects prefix: " << prefix - << " obj: " << iter.key.name << std::endl; + << " obj: " << sref << std::endl; - size_t last_del = iter.key.name.find_last_of('/'); - boost::string_ref sref; + size_t last_del = sref.find_last_of('/'); if (last_del != string::npos) - sref = boost::string_ref{iter.key.name.substr(last_del+1)}; - else - sref = boost::string_ref{iter.key.name}; + sref = sref.substr(last_del+1); + /* if we find a trailing slash in a -listing- the parent is an * empty directory */ @@ -914,12 +919,11 @@ public: if (iter.first.back() == '/') const_cast(iter.first).pop_back(); - size_t last_del = iter.first.find_last_of('/'); - boost::string_ref sref; + boost::string_ref sref{iter.first}; + + size_t last_del = sref.find_last_of('/'); if (last_del != string::npos) - sref = boost::string_ref{iter.first.substr(last_del+1)}; - else - sref = boost::string_ref{iter.first}; + sref = sref.substr(last_del+1); lsubdout(cct, rgw, 15) << "RGWReaddirRequest " << __func__ << " "