]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: use rados::init_internal
authorColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 16 Mar 2011 18:52:32 +0000 (11:52 -0700)
committerColin Patrick McCabe <cmccabe@alumni.cmu.edu>
Wed, 16 Mar 2011 18:52:32 +0000 (11:52 -0700)
Signed-off-by: Colin McCabe <colin.mccabe@dreamhost.com>
src/rgw/rgw_access.cc
src/rgw/rgw_access.h
src/rgw/rgw_admin.cc
src/rgw/rgw_main.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 56b2bcc39d386a19026c3b7ae1ef9136763dbd19..1166b75b8f381bf36e154d8d22f4fc5ba33168e4 100644 (file)
@@ -17,7 +17,7 @@ RGWAccess::~RGWAccess()
 {
 }
 
-RGWAccess *RGWAccess::init_storage_provider(const char *type, int argc, char *argv[])
+RGWAccess *RGWAccess::init_storage_provider(const char *type, md_config_t *conf)
 {
   if (strcmp(type, "rados") == 0) {
     store = &rados_provider;
@@ -27,7 +27,7 @@ RGWAccess *RGWAccess::init_storage_provider(const char *type, int argc, char *ar
     store = NULL;
   }
 
-  if (store->initialize(argc, argv) < 0)
+  if (store->initialize(conf) < 0)
     store = NULL;
 
   return store;
index 4bfa66f55e6235b557dbcd24ad5329a117dbebfd..dae8bcc481b96fb4c4fb691d237132f98c2faccb 100644 (file)
@@ -9,6 +9,8 @@
 
 #include "rgw_common.h"
 
+struct md_config_t;
+
 /**
  * Abstract class defining the interface for storage devices used by RGW.
  */
@@ -16,7 +18,7 @@ class RGWAccess {
 public:
   virtual ~RGWAccess();
   /** do all necessary setup of the storage device */
-  virtual int initialize(int argc, char *argv[]) { return 0; }
+  virtual int initialize(md_config_t *conf) { return 0; }
   /** prepare a listing of all buckets. */
   virtual int list_buckets_init(std::string& id, RGWAccessHandle *handle) = 0;
   /** get the next bucket in the provided listing context. */
@@ -179,7 +181,7 @@ public:
    * Given the name of the storage provider, initialize it
    * with the given arguments.
    */
-  static RGWAccess *init_storage_provider(const char *type, int argc, char *argv[]);
+  static RGWAccess *init_storage_provider(const char *type, md_config_t *conf);
   static RGWAccess *store;
 };
 
index 9c0c17e0fc036c3db2cefa4424e5a7e8c3bcbc57..8b9de3d268a1b8c750c37744a80dca6e4b771b63 100644 (file)
@@ -226,7 +226,7 @@ int main(int argc, char **argv)
   if (opt_cmd == OPT_NO_CMD)
     ARGS_USAGE();
 
-  store = RGWAccess::init_storage_provider("rados", argc, argv);
+  store = RGWAccess::init_storage_provider("rados", &g_conf);
   if (!store) {
     cerr << "couldn't init storage provider" << std::endl;
     return 5; //EIO
index 9ab79de9716f7a278aedbe21aabd0d88e2e42453..82f99375820c364fe2c4567492e88858c53859a3 100644 (file)
@@ -12,6 +12,9 @@
 
 #include "fcgiapp.h"
 
+#include "common/ceph_argparse.h"
+#include "common/common_init.h"
+#include "common/config.h"
 #include "rgw_common.h"
 #include "rgw_access.h"
 #include "rgw_acl.h"
 
 using namespace std;
 
-static sighandler_t sighandler_segv;
 static sighandler_t sighandler_usr1;
 static sighandler_t sighandler_alrm;
 
-/*
- * ?print out the C++ errors to log in case it fails
- */
-static void sigsegv_handler(int signum)
-{
-  BackTrace bt(0);
-  bt.print(cerr);
-
-  signal(signum, sighandler_segv);
-}
-
 static void godown_handler(int signum)
 {
   FCGX_ShutdownPending();
@@ -62,19 +53,23 @@ static void godown_alarm(int signum)
 /*
  * start up the RADOS connection and then handle HTTP messages as they come in
  */
-int main(int argc, char *argv[])
+int main(int argc, const char **argv)
 {
   struct req_state s;
   struct fcgx_state fcgx;
 
   curl_global_init(CURL_GLOBAL_ALL);
 
-  if (!RGWAccess::init_storage_provider("rados", argc, argv)) {
-    cerr << "Couldn't init storage provider (RADOS)" << endl;
+  vector<const char*> args;
+  argv_to_vec(argc, argv, args);
+  env_to_vec(args);
+  common_init(args, CEPH_ENTITY_TYPE_CLIENT, CODE_ENVIRONMENT_DAEMON, 0);
+
+  if (!RGWAccess::init_storage_provider("rados", &g_conf)) {
+    cerr << "Couldn't init storage provider (RADOS)" << std::endl;
     return 5; //EIO
   }
 
-  sighandler_segv = signal(SIGSEGV, sigsegv_handler);
   sighandler_usr1 = signal(SIGUSR1, godown_handler);
   sighandler_alrm = signal(SIGALRM, godown_alarm);
 
@@ -87,7 +82,7 @@ int main(int argc, char *argv[])
     int ret;
     
     if (!handler->authorize(&s)) {
-      RGW_LOG(10) << "failed to authorize request" << endl;
+      RGW_LOG(10) << "failed to authorize request" << std::endl;
       abort_early(&s, -EPERM);
       goto done;
     }
@@ -98,7 +93,7 @@ int main(int argc, char *argv[])
       case -ENOENT:
         break;
       default:
-        RGW_LOG(10) << "could not read acls" << " ret=" << ret << endl;
+        RGW_LOG(10) << "could not read acls" << " ret=" << ret << std::endl;
         abort_early(&s, ret);
         goto done;
       }
index a006c3e54675c863fc0129d4fea3655b369ddaa1..c038cafd39fe18cc2379924e020f3b9b76b25135 100644 (file)
@@ -26,14 +26,14 @@ static librados::IoCtx root_pool_ctx;
  * Initialize the RADOS instance and prepare to do other ops
  * Returns 0 on success, -ERR# on failure.
  */
-int RGWRados::initialize(int argc, char *argv[])
+int RGWRados::initialize(md_config_t *conf)
 {
   int ret;
   rados = new Rados();
   if (!rados)
     return -ENOMEM;
 
-  ret = rados->init(NULL);
+  ret = rados->init_internal(conf);
   if (ret < 0)
    return ret;
 
index 2ecbed51a00a2c114d69d1dabcfdc75b1af69aac..7be06ee0730341055075555079cb767d67bb1990 100644 (file)
@@ -19,7 +19,7 @@ class RGWRados  : public RGWAccess
 
 public:
   /** Initialize the RADOS instance and prepare to do other ops */
-  virtual int initialize(int argc, char *argv[]);
+  virtual int initialize(md_config_t *conf);
   /** set up a bucket listing. id is ignored, handle is filled in. */
   virtual int list_buckets_init(std::string& id, RGWAccessHandle *handle);
   /**