From d633ecb1fd4f0f397e1de64611bebf93c8ce909f Mon Sep 17 00:00:00 2001 From: Matt Benjamin Date: Tue, 17 Jan 2017 23:10:58 -0500 Subject: [PATCH] rgw: s/static std::map/static pointer/ for ext_mime_map In some librgw shutdown cases, it appears that the shared object runtime has partially destructed the static map when our shutdown code is running. Fixes: http://tracker.ceph.com/issues/18585 Signed-off-by: Matt Benjamin --- src/rgw/rgw_tools.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_tools.cc b/src/rgw/rgw_tools.cc index 0779688b3bd..3b2f2278c51 100644 --- a/src/rgw/rgw_tools.cc +++ b/src/rgw/rgw_tools.cc @@ -16,7 +16,7 @@ #define READ_CHUNK_LEN (512 * 1024) -static map ext_mime_map; +static std::map* ext_mime_map; int rgw_put_system_obj(RGWRados *rgwstore, rgw_bucket& bucket, const string& oid, const char *data, size_t size, bool exclusive, RGWObjVersionTracker *objv_tracker, real_time set_mtime, map *pattrs) @@ -97,7 +97,7 @@ void parse_mime_map_line(const char *start, const char *end) do { ext = strsep(&l, DELIMS); if (ext && *ext) { - ext_mime_map[ext] = mime; + (*ext_mime_map)[ext] = mime; } } while (ext); } @@ -164,8 +164,8 @@ done: const char *rgw_find_mime_by_ext(string& ext) { - map::iterator iter = ext_mime_map.find(ext); - if (iter == ext_mime_map.end()) + map::iterator iter = ext_mime_map->find(ext); + if (iter == ext_mime_map->end()) return NULL; return iter->second.c_str(); @@ -173,6 +173,7 @@ const char *rgw_find_mime_by_ext(string& ext) int rgw_tools_init(CephContext *cct) { + ext_mime_map = new std::map; int ret = ext_mime_map_init(cct, cct->_conf->rgw_mime_types_file.c_str()); if (ret < 0) return ret; @@ -182,5 +183,6 @@ int rgw_tools_init(CephContext *cct) void rgw_tools_cleanup() { - ext_mime_map.clear(); + delete ext_mime_map; + ext_mime_map = nullptr; } -- 2.39.5