]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rgw_main.cc: reorder framework detection
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 31 Jan 2017 16:58:44 +0000 (17:58 +0100)
committerSage Weil <sage@redhat.com>
Thu, 9 Feb 2017 02:54:25 +0000 (21:54 -0500)
Fix for:

CID 1398896: Resource leak (RESOURCE_LEAK)
 overwrite_var: Overwriting fe in fe = new
 RGWLoadGenFrontend(env, config) leaks the storage that fe
 points to.

Do not check again and again for framework if there is
already a match, make use of if/else. This should also
fix the RESOURCE_LEAK warning.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/rgw/rgw_main.cc

index 363807617318a0ffe3784325a6ac1f4f7c046053..0330e322f4cb90196b9aeba3051b46c3fa4d70e6 100644 (file)
@@ -458,26 +458,7 @@ int main(int argc, const char **argv)
     RGWFrontendConfig *config = fiter->second;
     string framework = config->get_framework();
     RGWFrontend *fe = NULL;
-#if defined(WITH_RADOSGW_ASIO_FRONTEND)
-    if ((framework == "asio") &&
-       cct->check_experimental_feature_enabled("rgw-asio-frontend")) {
-      int port;
-      config->get_val("port", 80, &port);
-      std::string uri_prefix;
-      config->get_val("prefix", "", &uri_prefix);
-      RGWProcessEnv env{ store, &rest, olog, port, uri_prefix };
-      fe = new RGWAsioFrontend(env);
-    }
-#endif /* WITH_RADOSGW_ASIO_FRONTEND */
-#if defined(WITH_RADOSGW_FCGI_FRONTEND)
-    if (framework == "fastcgi" || framework == "fcgi") {
-      std::string uri_prefix;
-      config->get_val("prefix", "", &uri_prefix);
-      RGWProcessEnv fcgi_pe = { store, &rest, olog, 0, uri_prefix };
 
-      fe = new RGWFCGXFrontend(fcgi_pe, config);
-    }
-#endif /* WITH_RADOSGW_FCGI_FRONTEND */
     if (framework == "civetweb" || framework == "mongoose") {
       int port;
       config->get_val("port", 80, &port);
@@ -488,7 +469,7 @@ int main(int argc, const char **argv)
 
       fe = new RGWCivetWebFrontend(env, config);
     }
-    if (framework == "loadgen") {
+    else if (framework == "loadgen") {
       int port;
       config->get_val("port", 80, &port);
       std::string uri_prefix;
@@ -498,10 +479,32 @@ int main(int argc, const char **argv)
 
       fe = new RGWLoadGenFrontend(env, config);
     }
+#if defined(WITH_RADOSGW_ASIO_FRONTEND)
+    else if ((framework == "asio") &&
+       cct->check_experimental_feature_enabled("rgw-asio-frontend")) {
+      int port;
+      config->get_val("port", 80, &port);
+      std::string uri_prefix;
+      config->get_val("prefix", "", &uri_prefix);
+      RGWProcessEnv env{ store, &rest, olog, port, uri_prefix };
+      fe = new RGWAsioFrontend(env);
+    }
+#endif /* WITH_RADOSGW_ASIO_FRONTEND */
+#if defined(WITH_RADOSGW_FCGI_FRONTEND)
+    else if (framework == "fastcgi" || framework == "fcgi") {
+      std::string uri_prefix;
+      config->get_val("prefix", "", &uri_prefix);
+      RGWProcessEnv fcgi_pe = { store, &rest, olog, 0, uri_prefix };
+
+      fe = new RGWFCGXFrontend(fcgi_pe, config);
+    }
+#endif /* WITH_RADOSGW_FCGI_FRONTEND */
+
     if (fe == NULL) {
       dout(0) << "WARNING: skipping unknown framework: " << framework << dendl;
       continue;
     }
+
     dout(0) << "starting handler: " << fiter->first << dendl;
     int r = fe->init();
     if (r < 0) {