]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
monclient: gracefully error out when given an invalid monmap path
authorSage Weil <sage@newdream.net>
Mon, 16 Aug 2010 02:49:17 +0000 (19:49 -0700)
committerSage Weil <sage@newdream.net>
Mon, 16 Aug 2010 02:49:17 +0000 (19:49 -0700)
src/mon/MonClient.cc

index 0bf844b90654fa65019202b0556ad9141f912f07..0bcc658691fbf06a1e4df3f8a5d2582d4d055beb 100644 (file)
@@ -49,11 +49,18 @@ int MonClient::build_initial_monmap()
   // file?
   if (g_conf.monmap) {
     const char *monmap_fn = g_conf.monmap;
-    int r = monmap.read(monmap_fn);
+    int r;
+    try {
+      r = monmap.read(monmap_fn);
+    }
+    catch (buffer::error *e) {
+      r = -EINVAL;
+    }
     if (r >= 0)
       return 0;
     char buf[80];
-    cerr << "unable to read monmap from " << monmap_fn << ": " << strerror_r(errno, buf, sizeof(buf)) << std::endl;
+    cerr << "unable to read/decode monmap from " << monmap_fn << ": " << strerror_r(-r, buf, sizeof(buf)) << std::endl;
+    return r;
   }
 
   // -m foo?