summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatt Benjamin <mbenjamin@redhat.com>2015-10-29 16:49:06 +0100
committerMatt Benjamin <mbenjamin@redhat.com>2016-02-12 18:05:23 +0100
commit290b06a91c1a7d619f8ee83a9ee9e86f3e7ee132 (patch)
tree06f82b28de5508dadbb5091e07fb6da0e04b00bb /src
parentlibrgw: dispatch RGWDeleteRequest in object branch in rgw_unlink(). (diff)
downloadceph-290b06a91c1a7d619f8ee83a9ee9e86f3e7ee132.tar.xz
ceph-290b06a91c1a7d619f8ee83a9ee9e86f3e7ee132.zip
librgw: rework library CephContext* and init
Remove duplicated init step. Just reference the global Ceph context for the library instance(s). The immediate effect of this is to bring the (correctly initialized) global context into all call paths, which (e.g.) fixes debug log prints within subsystems. Signed-off-by: Matt Benjamin <mbenjamin@redhat.com>
Diffstat (limited to 'src')
-rw-r--r--src/include/rados/librgw.h7
-rw-r--r--src/rgw/librgw.cc36
-rw-r--r--src/test/librgw_file.cc2
-rw-r--r--src/test/librgw_file_cd.cc2
-rw-r--r--src/test/librgw_file_gp.cc2
5 files changed, 21 insertions, 28 deletions
diff --git a/src/include/rados/librgw.h b/src/include/rados/librgw.h
index 2772c94d22e..eeeea463cf8 100644
--- a/src/include/rados/librgw.h
+++ b/src/include/rados/librgw.h
@@ -19,12 +19,7 @@ extern "C" {
#endif
typedef void* librgw_t;
-int librgw_create(librgw_t *rgw, const char * const id, int argc, char **argv);
-int librgw_acl_bin2xml(librgw_t rgw, const char *bin, int bin_len, char **xml);
-void librgw_free_xml(librgw_t rgw, char *xml);
-int librgw_acl_xml2bin(librgw_t rgw, const char *xml, char **bin,
- int *bin_len);
-void librgw_free_bin(librgw_t rgw, char *bin);
+int librgw_create(librgw_t *rgw, int argc, char **argv);
void librgw_shutdown(librgw_t rgw);
int librgw_init();
diff --git a/src/rgw/librgw.cc b/src/rgw/librgw.cc
index 45259f4ca0a..2d5e6e0e8fa 100644
--- a/src/rgw/librgw.cc
+++ b/src/rgw/librgw.cc
@@ -140,6 +140,15 @@ int RGWLibProcess::process_request(RGWLibRequest* req, RGWLibIO* io)
<< " starting new request req=" << hex << req << dec
<< " ======" << dendl;
+ dout(15) << "foobar1 dout dout_subsys=" << dout_subsys
+ << dendl;
+ if (g_ceph_context->_conf->subsys.should_gather(ceph_subsys_rgw, 15)) {
+ dout(15) << "foobar2 in should-gather(ceph_subsys_rgw, 15)"
+ << dendl;
+ }
+ dout(15) << "foobar3 dout dout_subsys=" << dout_subsys
+ << dendl;
+
/*
* invariant: valid requests are derived from RGWOp--well-formed
* requests should have assigned RGWRequest::op in their descendant
@@ -285,15 +294,17 @@ int RGWLib::init()
int RGWLib::init(vector<const char*>& args)
{
int r = 0;
+
/* alternative default for module */
vector<const char *> def_args;
def_args.push_back("--debug-rgw=1/5");
def_args.push_back("--keyring=$rgw_data/keyring");
def_args.push_back("--log-file=/var/log/radosgw/$cluster-$name.log");
- global_init(&def_args, args, CEPH_ENTITY_TYPE_CLIENT,
- CODE_ENVIRONMENT_DAEMON,
- CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
+ global_init(&def_args, args,
+ CEPH_ENTITY_TYPE_CLIENT,
+ CODE_ENVIRONMENT_DAEMON,
+ CINIT_FLAG_UNPRIVILEGED_DAEMON_DEFAULTS);
Mutex mutex("main");
SafeTimer init_timer(g_ceph_context, mutex);
@@ -446,22 +457,8 @@ int librgw_init()
return rgwlib.init();
}
-int librgw_create(librgw_t* rgw, const char* const id, int argc, char **argv)
+int librgw_create(librgw_t* rgw, int argc, char **argv)
{
- CephInitParameters iparams(CEPH_ENTITY_TYPE_CLIENT);
- if (id) {
- iparams.name.set(CEPH_ENTITY_TYPE_CLIENT, id);
- }
-
- CephContext* cct = common_preinit(iparams, CODE_ENVIRONMENT_LIBRARY, 0,
- "rgw_data");
- cct->_conf->set_val("log_to_stderr", "false"); // quiet by default
- cct->_conf->set_val("err_to_stderr", "true"); // quiet by default
- cct->_conf->parse_env(); // environment variables override
- cct->_conf->apply_changes(NULL);
- common_init_finish(cct);
-
- /* assign ref'd cct as g_ceph_context if none exists */
if (! g_ceph_context) {
std::lock_guard<std::mutex> lg(librgw_mtx);
if (! g_ceph_context) {
@@ -471,7 +468,8 @@ int librgw_create(librgw_t* rgw, const char* const id, int argc, char **argv)
}
}
- *rgw = cct;
+ *rgw = g_ceph_context->get();
+
return 0;
}
diff --git a/src/test/librgw_file.cc b/src/test/librgw_file.cc
index d6406142251..c7247ff9a38 100644
--- a/src/test/librgw_file.cc
+++ b/src/test/librgw_file.cc
@@ -43,7 +43,7 @@ namespace {
}
TEST(LibRGW, INIT) {
- int ret = librgw_create(&rgw, nullptr, saved_args.argc, saved_args.argv);
+ int ret = librgw_create(&rgw, saved_args.argc, saved_args.argv);
ASSERT_EQ(ret, 0);
ASSERT_NE(rgw, nullptr);
}
diff --git a/src/test/librgw_file_cd.cc b/src/test/librgw_file_cd.cc
index addf29bf9f5..417ecb4bf76 100644
--- a/src/test/librgw_file_cd.cc
+++ b/src/test/librgw_file_cd.cc
@@ -47,7 +47,7 @@ namespace {
}
TEST(LibRGW, INIT) {
- int ret = librgw_create(&rgw, nullptr, saved_args.argc, saved_args.argv);
+ int ret = librgw_create(&rgw, saved_args.argc, saved_args.argv);
ASSERT_EQ(ret, 0);
ASSERT_NE(rgw, nullptr);
}
diff --git a/src/test/librgw_file_gp.cc b/src/test/librgw_file_gp.cc
index e2bc1301a33..bc3d8058d75 100644
--- a/src/test/librgw_file_gp.cc
+++ b/src/test/librgw_file_gp.cc
@@ -129,7 +129,7 @@ namespace {
}
TEST(LibRGW, INIT) {
- int ret = librgw_create(&rgw, nullptr, saved_args.argc, saved_args.argv);
+ int ret = librgw_create(&rgw, saved_args.argc, saved_args.argv);
ASSERT_EQ(ret, 0);
ASSERT_NE(rgw, nullptr);
}