]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: consolidate dup'd librgw, rgwlib
authorMatt Benjamin <mbenjamin@redhat.com>
Wed, 6 Jan 2016 02:34:34 +0000 (21:34 -0500)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:07:27 +0000 (12:07 -0500)
There can be only one.  Fixes crash on shutdown.

Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
src/include/rados/librgw.h
src/rgw/librgw.cc
src/rgw/rgw_file.cc
src/rgw/rgw_lib.h

index eeeea463cf880225d31d29462de9754d28b00aa8..9ba8f3ac67a6f948594a0d9ea226bbc97a537082 100644 (file)
@@ -22,9 +22,6 @@ typedef void* librgw_t;
 int librgw_create(librgw_t *rgw, int argc, char **argv);
 void librgw_shutdown(librgw_t rgw);
 
-int librgw_init();
-int librgw_stop();
-
 #ifdef __cplusplus
 }
 #endif
index 2c0b22bdcd71717645c8d6a4c6f7a5c22eb15563..84db604d83fb70e32cef7a31c49bc668475441c0 100644 (file)
@@ -62,7 +62,7 @@ namespace rgw {
 
   static std::mutex librgw_mtx;
 
-  RGWLib librgw; /* XXX initialize? */
+  RGWLib rgwlib;
 
   class C_InitTimeout : public Context {
   public:
@@ -476,7 +476,7 @@ namespace rgw {
     int port = 80;
     RGWProcessEnv env = { store, &rest, olog, port };
 
-    fec = new RGWFrontendConfig("librgw");
+    fec = new RGWFrontendConfig("rgwlib");
     fe = new RGWLibFrontend(env, fec);
 
     fe->init();
@@ -531,7 +531,7 @@ namespace rgw {
 
   int RGWLibRequest::read_permissions(RGWOp* op) {
     int ret =
-      rgw_build_bucket_policies(librgw.get_store(), get_state());
+      rgw_build_bucket_policies(rgwlib.get_store(), get_state());
     if (ret < 0) {
       ldout(get_state()->cct, 10) << "read_permissions on "
                                  << get_state()->bucket << ":"
@@ -564,20 +564,10 @@ namespace rgw {
     return 0;
   } /* RGWHandler_Lib::authorize */
 
-/* global RGW library object */
-  static RGWLib rgwlib;
-
 } /* namespace rgw */
 
 extern "C" {
 
-int librgw_init()
-{
-  using namespace rgw;
-
-  return rgwlib.init();
-}
-
 int librgw_create(librgw_t* rgw, int argc, char **argv)
 {
   using namespace rgw;
@@ -587,7 +577,7 @@ int librgw_create(librgw_t* rgw, int argc, char **argv)
     if (! g_ceph_context) {
       vector<const char*> args;
       argv_to_vec(argc, const_cast<const char**>(argv), args);
-      librgw.init(args);
+      rgwlib.init(args);
     }
   }
 
@@ -687,9 +677,7 @@ void librgw_shutdown(librgw_t rgw)
   using namespace rgw;
 
   CephContext* cct = static_cast<CephContext*>(rgw);
-#if 0
   rgwlib.stop();
-#endif
   cct->put();
 }
 
index 9a29675dddfe5950bfd5aa017a60b095e056ec52..49cb70fc1821562225b958984ad5fd66a464dd9f 100644 (file)
@@ -32,7 +32,7 @@ using namespace rgw;
 
 namespace rgw {
 
-  extern RGWLib librgw;
+  extern RGWLib rgwlib;
 
   const string RGWFileHandle::root_name = "/";
 
@@ -45,7 +45,7 @@ namespace rgw {
     std::string bucket_name{path};
     RGWStatBucketRequest req(cct, get_user(), bucket_name);
 
-    int rc = librgw.get_fe()->execute_req(&req);
+    int rc = rgwlib.get_fe()->execute_req(&req);
     if ((rc == 0) &&
        (req.get_ret() == 0) &&
        (req.matched())) {
@@ -87,7 +87,7 @@ namespace rgw {
        RGWStatObjRequest req(cct, get_user(),
                              parent->bucket_name(), object_name,
                              RGWStatObjRequest::FLAG_NONE);
-       int rc = librgw.get_fe()->execute_req(&req);
+       int rc = rgwlib.get_fe()->execute_req(&req);
        if ((rc == 0) &&
            (req.get_ret() == 0)) {
          fhr = lookup_fh(parent, path, RGWFileHandle::FLAG_NONE);
@@ -98,7 +98,7 @@ namespace rgw {
       case 1:
       {
        RGWStatLeafRequest req(cct, get_user(), parent, object_name);
-       int rc = librgw.get_fe()->execute_req(&req);
+       int rc = rgwlib.get_fe()->execute_req(&req);
        if ((rc == 0) &&
            (req.get_ret() == 0)) {
          if (req.matched) {
@@ -142,7 +142,7 @@ namespace rgw {
     /* force cache drain, forces objects to evict */
     fh_cache.drain(ObjUnref(this),
                  RGWFileHandle::FHCache::FLAG_LOCK);
-    librgw.get_fe()->get_process()->unregister_fs(this);
+    rgwlib.get_fe()->get_process()->unregister_fs(this);
     rele();
   } /* RGWLibFS::close */
 
@@ -224,7 +224,7 @@ namespace rgw {
     if (is_root()) {
       RGWListBucketsRequest req(cct, fs->get_user(), this, rcb, cb_arg,
                                offset);
-      rc = librgw.get_fe()->execute_req(&req);
+      rc = rgwlib.get_fe()->execute_req(&req);
       if (! rc) {
        parent->set_nlink(3 + d->name_cache.size());
        state.atime = now;
@@ -235,7 +235,7 @@ namespace rgw {
     } else {
       rgw_obj_key marker{"", ""};
       RGWReaddirRequest req(cct, fs->get_user(), this, rcb, cb_arg, offset);
-      rc = librgw.get_fe()->execute_req(&req);
+      rc = rgwlib.get_fe()->execute_req(&req);
       if (! rc) {
        state.atime = now;
        parent->set_nlink(3 + d->name_cache.size());
@@ -268,7 +268,7 @@ namespace rgw {
       f->write_req =
        new RGWWriteRequest(fs->get_context(), fs->get_user(), this,
                            bucket_name(), object_name);
-      rc = librgw.get_fe()->start_req(f->write_req);
+      rc = rgwlib.get_fe()->start_req(f->write_req);
     }
 
     f->write_req->put_data(off, bl);
@@ -289,7 +289,7 @@ namespace rgw {
     int rc = 0;
     file* f = get<file>(&variant_type);
     if (f && (f->write_req)) {
-      rc = librgw.get_fe()->finish_req(f->write_req);
+      rc = rgwlib.get_fe()->finish_req(f->write_req);
       if (! rc) {
        rc = f->write_req->get_ret();
       }
@@ -523,14 +523,14 @@ extern "C" {
                                  sec_key);
   assert(new_fs);
 
-  rc = new_fs->authorize(librgw.get_store());
+  rc = new_fs->authorize(rgwlib.get_store());
   if (rc != 0) {
     delete new_fs;
     return -EINVAL;
   }
 
   /* register fs for shared gc */
-  librgw.get_fe()->get_process()->register_fs(new_fs);
+  rgwlib.get_fe()->get_process()->register_fs(new_fs);
 
   struct rgw_fs *fs = new_fs->get_fs();
   fs->rgw = rgw;
@@ -655,7 +655,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
     uri += "/"; /* XXX */
     uri += name;
     RGWCreateBucketRequest req(cct, fs->get_user(), uri);
-    rc = librgw.get_fe()->execute_req(&req);
+    rc = rgwlib.get_fe()->execute_req(&req);
     rc2 = req.get_ret();
   } else {
     /* create an object representing the directory (naive version) */
@@ -665,7 +665,7 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
     string dir_name = rgw_fh->relative_object_name() + "/";
     RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
                         dir_name, bl);
-    rc = librgw.get_fe()->execute_req(&req);
+    rc = rgwlib.get_fe()->execute_req(&req);
     rc2 = req.get_ret();
   }
 
@@ -712,7 +712,7 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
     string uri = "/";
     uri += name;
     RGWDeleteBucketRequest req(cct, fs->get_user(), uri);
-    rc = librgw.get_fe()->execute_req(&req);
+    rc = rgwlib.get_fe()->execute_req(&req);
   } else {
     /*
      * leaf object
@@ -728,7 +728,7 @@ int rgw_unlink(struct rgw_fs *rgw_fs, struct rgw_file_handle *parent_fh,
       std::string oname = rgw_fh->relative_object_name();
       RGWDeleteObjRequest req(cct, fs->get_user(), parent->bucket_name(),
                              oname);
-      rc = librgw.get_fe()->execute_req(&req);
+      rc = rgwlib.get_fe()->execute_req(&req);
       /* release */
       (void) rgw_fh_rele(rgw_fs, fh, 0 /* flags */);
     }
@@ -746,7 +746,7 @@ void dump_buckets(void) {
   RGWUserBuckets buckets;
   uint64_t max_buckets = g_ceph_context->_conf->rgw_list_buckets_max_chunk;
 
-  RGWRados* store = librgw.get_store();
+  RGWRados* store = rgwlib.get_store();
 
   /* XXX check offsets */
   uint64_t ix = 3;
@@ -875,7 +875,7 @@ int rgw_getattr(struct rgw_fs *rgw_fs,
     RGWStatObjRequest req(cct, fs->get_user(), bname, oname,
                          RGWStatObjRequest::FLAG_NONE);
 
-    int rc = librgw.get_fe()->execute_req(&req);
+    int rc = rgwlib.get_fe()->execute_req(&req);
     if ((rc != 0) ||
        (req.get_ret() != 0)) {
       /* XXX EINVAL is likely illegal protocol return--if the object
@@ -986,7 +986,7 @@ int rgw_read(struct rgw_fs *rgw_fs,
                    rgw_fh->object_name(), offset, length,
                    buffer);
 
-  int rc = librgw.get_fe()->execute_req(&req);
+  int rc = rgwlib.get_fe()->execute_req(&req);
   if ((rc == 0) &&
       (req.get_ret() == 0)) {
     *bytes_read = req.nread;
@@ -1060,7 +1060,7 @@ int rgw_readv(struct rgw_fs *rgw_fs,
                      bl);
   req.do_hexdump = false;
 
-  rc = librgw.get_fe()->execute_req(&req);
+  rc = rgwlib.get_fe()->execute_req(&req);
 
   if (! rc) {
     RGWReadV* rdv = static_cast<RGWReadV*>(
@@ -1119,7 +1119,7 @@ int rgw_readv(struct rgw_fs *rgw_fs,
   RGWPutObjRequest req(cct, fs->get_user(), rgw_fh->bucket_name(),
                       oname, bl);
 
-  int rc = librgw.get_fe()->execute_req(&req);
+  int rc = rgwlib.get_fe()->execute_req(&req);
 
   /* XXX update size (in request) */
 
index fc4aa771b5e444bbd2761d9fb6f455c9dbfadba3..1a75e379e7160e3b0ead2e9c084b0e3f28a53a55 100644 (file)
@@ -41,7 +41,7 @@ namespace rgw {
     int stop();
   };
 
-  extern RGWLib librgw;
+  extern RGWLib rgwlib;
 
 /* request interface */
 
@@ -161,7 +161,7 @@ namespace rgw {
 
     RGWLibContinuedReq(CephContext* _cct, RGWUserInfo* _user)
       :  RGWLibRequest(_cct, _user), io_ctx(),
-        rstate(_cct, &io_ctx.get_env(), _user), rados_ctx(librgw.get_store(),
+        rstate(_cct, &io_ctx.get_env(), _user), rados_ctx(rgwlib.get_store(),
                                                           &rstate)
       {
        io_ctx.init(_cct);