]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librgw: return result code from execute_request
authorMatt Benjamin <mbenjamin@redhat.com>
Thu, 8 Oct 2015 17:12:48 +0000 (13:12 -0400)
committerMatt Benjamin <mbenjamin@redhat.com>
Fri, 12 Feb 2016 17:04:56 +0000 (12:04 -0500)
Update rgw_mkdir and rgw_readdir to use it.

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

index 8b6b41aaac89f49076bc805f166f51a08a697d66..a9a4bd441c6effe882f70e40b96d8aee30fd195b 100644 (file)
@@ -144,8 +144,8 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
              const char *name, mode_t mode, struct stat *st,
              struct rgw_file_handle *handle)
 {
-  string uri;
   int rc;
+  string uri;
 
   rc = librgw.get_uri(parent_handle->handle, uri);
   if (rc < 0 ) { /* invalid parent */
@@ -164,11 +164,9 @@ int rgw_mkdir(struct rgw_fs *rgw_fs,
   uri += "/";
   uri += name;
   RGWCreateBucketRequest req(cct, fs->get_user(), uri);
-  (void) librgw.get_fe()->execute_req(&req);
-
-  /* TODO: result */
+  rc = librgw.get_fe()->execute_req(&req);
 
-  return 0;
+  return rc;
 }
 
 /*
@@ -282,8 +280,8 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
                const struct rgw_file_handle *parent_handle, uint64_t *offset,
                rgw_readdir_cb rcb, void *cb_arg, bool *eof)
 {
-  string uri;
   int rc;
+  string uri;
 
   rc = librgw.get_uri(parent_handle->handle, uri);
   if (rc < 0 ) { /* invalid parent */
@@ -301,23 +299,21 @@ int rgw_readdir(struct rgw_fs *rgw_fs,
   if (is_root(uri)) {
     /* for now, root always contains one user's bucket namespace */
     RGWListBucketsRequest req(cct, fs->get_user(), rcb, cb_arg, offset);
-    (void) librgw.get_fe()->execute_req(&req);
+    rc = librgw.get_fe()->execute_req(&req);
   } else {
     /*
      * bucket?
      */
     uri += "/";
-
     RGWListBucketRequest req(cct, fs->get_user(), uri, rcb, cb_arg, offset);
-    (void) librgw.get_fe()->execute_req(&req);
+    rc = librgw.get_fe()->execute_req(&req);
 
   }
 
-  /* TODO: result */
-
+  /* XXXX request MUST set this */
   *eof = true; // XXX move into RGGWListBucket(s)Request
 
-  return 0;
+  return rc;
 }
 
 /*
index 132288647805f61324ac7dcbe303c09466c053f4..6bec854efd8f68fa7995d8130e8698048b848d86 100644 (file)
@@ -193,8 +193,8 @@ public:
     static_cast<RGWLibProcess*>(pprocess)->enqueue_req(req); // async
   }
 
-  inline void execute_req(RGWLibRequest* req) {
-    static_cast<RGWLibProcess*>(pprocess)->process_request(req); // !async
+  inline int execute_req(RGWLibRequest* req) {
+    return static_cast<RGWLibProcess*>(pprocess)->process_request(req); // !async
   }
 
 }; /* RGWLibFrontend */
index fe09d0b58ff1b6427ba3d58dc611140c449365c1..bd1dae5d462684024c485c837145482008351837 100644 (file)
@@ -59,6 +59,7 @@ TEST(LibRGW, CREATE_BUCKET) {
   struct stat st;
   struct rgw_file_handle fh;
   int ret = rgw_mkdir(fs, &fs->root_fh, "sorry_dave", 755, &st, &fh);
+  ASSERT_EQ(ret, 0);
 }
 
 extern "C" {