]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rbd: modify watch
authorYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Tue, 8 Feb 2011 21:39:30 +0000 (13:39 -0800)
committerYehuda Sadeh <yehuda.sadeh@dreamhost.com>
Tue, 8 Feb 2011 21:39:30 +0000 (13:39 -0800)
src/rbd.cc

index 7743cd1a201fc61d59a7bd43f4f43a0c9beaca6b..8936d5a87e8403cee0d1a9fcec3cb32eca18e587 100644 (file)
@@ -468,14 +468,19 @@ static int do_watch(librbd::pool_t& pp, const char *imgname)
   md_oid += RBD_SUFFIX;
 
   librados::Rados rados;
+  rados.initialize(0, NULL);
   int r = rados.watch(md_pool, md_oid, 0, &cookie, &ctx);
   if (r < 0) {
     cerr << "watch failed" << std::endl;
+    rados.shutdown();
     return r;
   }
 
   cout << "press enter to exit..." << std::endl;
   getchar();
+
+  rados.shutdown();
+
   return 0;
 }
 
@@ -698,7 +703,7 @@ int main(int argc, const char **argv)
   if (imgname &&
       (opt_cmd == OPT_RESIZE || opt_cmd == OPT_INFO || opt_cmd == OPT_SNAP_LIST ||
        opt_cmd == OPT_SNAP_CREATE || opt_cmd == OPT_SNAP_ROLLBACK ||
-       opt_cmd == OPT_SNAP_REMOVE || opt_cmd == OPT_EXPORT)) {
+       opt_cmd == OPT_SNAP_REMOVE || opt_cmd == OPT_EXPORT || opt_cmd == OPT_WATCH)) {
     r = rbd.open_image(pool, imgname, &image, NULL);
     if (r < 0) {
       cerr << "error opening image " << imgname << " (err=" << r << ")" << std::endl;