]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librados: use rados_config_t typedef instead of CephContext
authorSage Weil <sage@newdream.net>
Wed, 15 Feb 2012 01:03:00 +0000 (17:03 -0800)
committerSage Weil <sage@newdream.net>
Wed, 15 Feb 2012 01:03:00 +0000 (17:03 -0800)
Signed-off-by: Sage Weil <sage@newdream.net>
src/include/rados/librados.h
src/librados.cc

index 5d16f94a7ce46179d5b117b93a71a55bca47072e..7fb06455c9f4d7b289cf82bcb7775abb155d75cd 100644 (file)
@@ -50,8 +50,6 @@ enum {
 /** @endcond */
 /** @} */
 
-struct CephContext;
-
 /**
  * @typedef rados_t
  *
@@ -63,6 +61,19 @@ struct CephContext;
  */
 typedef void *rados_t;
 
+/**
+ * @tyepdef rados_config_t
+ *
+ * A handle for the ceph configuration context for the rados_t cluster
+ * instance.  This can be used to share configuration context/state
+ * (e.g., logging configuration) between librados instance.
+ *
+ * @warning The config context does not have independent reference
+ * counting.  As such, a rados_config_t handle retrieved from a given
+ * rados_t is only valid as long as that rados_t.
+ */
+typedef void *rados_config_t;
+
 /**
  * @typedef rados_ioctx_t
  *
@@ -182,13 +193,13 @@ int rados_create(rados_t *cluster, const char * const id);
 /**
  * Initialize a cluster handle from an existing configuration.
  *
- * Copies all configuration, as retrieved by the C++ API.
+ * Share configuration state with another rados_t instance.
  *
  * @param cluster where to store the handle
  * @param cct_ the existing configuration to use
  * @returns 0 on success, negative error code on failure
  */
-int rados_create_with_context(rados_t *cluster, struct CephContext *cct_);
+int rados_create_with_context(rados_t *cluster, rados_config_t cct);
 
 /**
  * Connect to the cluster.
@@ -369,12 +380,14 @@ int rados_cluster_stat(rados_t cluster, struct rados_cluster_stat_t *result);
 int rados_pool_list(rados_t cluster, char *buf, size_t len);
 
 /**
- * Get CephContext for a rados cluster handle
+ * Get a configuration handle for a rados cluster handle
+ *
+ * This handle is valid only as long as the cluster handle is valid.
  *
  * @param cluster cluster handle
- * @returns CephContext for this cluster
+ * @returns config handle for this cluster
  */
-struct CephContext *rados_cct(rados_t cluster);
+rados_config_t rados_cct(rados_t cluster);
 
 /**
  * Create an io context
@@ -406,12 +419,12 @@ int rados_ioctx_create(rados_t cluster, const char *pool_name, rados_ioctx_t *io
 void rados_ioctx_destroy(rados_ioctx_t io);
 
 /**
- * Get CephContext for a pool handle
+ * Get configuration hadnle for a pool handle
  *
  * @param io pool handle
- * @returns CephContext for this cluster
+ * @returns rados_config_t for this cluster
  */
-struct CephContext *rados_ioctx_cct(rados_ioctx_t io);
+rados_config_t rados_ioctx_cct(rados_ioctx_t io);
 
 /**
  * Get pool usage statistics
index 0540373a2dcbf8d1adf1ba4c16627f89f0e9ba48..86e1ac309a3e2c2e15bf33af0a47a8d02678eb32 100644 (file)
@@ -3437,17 +3437,18 @@ extern "C" int rados_create(rados_t *pcluster, const char * const id)
  * already called global_init and want to use that particular configuration for
  * their cluster.
  */
-extern "C" int rados_create_with_context(rados_t *pcluster, CephContext *cct)
+extern "C" int rados_create_with_context(rados_t *pcluster, rados_config_t cct_)
 {
+  CephContext *cct = (CephContext *)cct_;
   librados::RadosClient *radosp = new librados::RadosClient(cct);
   *pcluster = (void *)radosp;
   return 0;
 }
 
-extern "C" CephContext *rados_cct(rados_t cluster)
+extern "C" rados_config_t rados_cct(rados_t cluster)
 {
   librados::RadosClient *client = (librados::RadosClient *)cluster;
-  return client->cct;
+  return (rados_config_t)client->cct;
 }
 
 extern "C" int rados_connect(rados_t cluster)
@@ -3631,10 +3632,10 @@ extern "C" int rados_ioctx_pool_stat(rados_ioctx_t io, struct rados_pool_stat_t
   return 0;
 }
 
-extern "C" struct CephContext *rados_ioctx_cct(rados_ioctx_t io)
+extern "C" rados_config_t rados_ioctx_cct(rados_ioctx_t io)
 {
   librados::IoCtxImpl *ctx = (librados::IoCtxImpl *)io;
-  return ctx->client->cct;
+  return (rados_config_t)ctx->client->cct;
 }
 
 extern "C" void rados_ioctx_snap_set_read(rados_ioctx_t io, rados_snap_t seq)