From 1fc18c46816caf69365c6ce136e93424e3d4009d Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 17 Oct 2012 21:21:01 +0100 Subject: [PATCH] mon: MonitorStore: fix error checks for mkdir operations We introduced a bug on the monitor store a couple of commits back that would trigger a EEXIST error message when the store tried to make sure a directory exists by trying to 'mkdir' it. We now check if 'errno' is EEXIST and, if so, we ignore the error. Signed-off-by: Joao Eduardo Luis --- src/mon/MonitorStore.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 8806ad0d6a459..b9decedac9e30 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -165,7 +165,7 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) snprintf(fn, sizeof(fn), "%s/%s", dir.c_str(), a); if (b) { int r = ::mkdir(fn, 0755); - if (r < 0) { + if ((r < 0) && (errno != EEXIST)) { int err = -errno; derr << __func__ << " failed to create dir " << fn << ": " << cpp_strerror(err) << dendl; @@ -332,7 +332,7 @@ int MonitorStore::write_bl_ss_impl(bufferlist& bl, const char *a, const char *b, snprintf(fn, sizeof(fn), "%s/%s", dir.c_str(), a); if (b) { int r = ::mkdir(fn, 0755); - if (r < 0) { + if ((r < 0) && (errno != EEXIST)) { err = -errno; derr << __func__ << " failed to create dir " << fn << ": " << cpp_strerror(err) << dendl; @@ -420,7 +420,7 @@ int MonitorStore::put_bl_sn_map(const char *a, char dfn[1024]; snprintf(dfn, sizeof(dfn), "%s/%s", dir.c_str(), a); int r = ::mkdir(dfn, 0755); - if (r < 0) { + if ((r < 0) && (errno != EEXIST)) { int err = -errno; derr << __func__ << " failed to create dir " << dfn << ": " << cpp_strerror(err) << dendl; -- 2.39.5