]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: fix initialization of string_ref from temporary
authorMatt Benjamin <mbenjamin@redhat.com>
Sun, 20 Dec 2015 01:27:31 +0000 (20:27 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:06 +0000 (12:07 -0500)
Found by valgrind.  The good news:  amounts to proof that the
sref notation works.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/common/cohort_lru.h
src/rgw/rgw_file.h

index 2f83b4230556feb874bbe2bce6edc9343c0b4c39..0baa3a25fc8836e9fe84a97a48ee677ed42e55d9 100644 (file)
@@ -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);
        }
index 35eaa9f0acc51d820b8422eabf84bea50ab40469..2c902306273d9def7ef418fc62d38b6af154c10a 100644 (file)
@@ -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<std::string&>(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__ << " "