From 0aa46ac09393cae02592904eec713cf4ab20a41e Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Mon, 21 Jan 2008 20:06:34 -0800 Subject: [PATCH] mon,msg: small fd cleanups --- src/mon/MonitorStore.cc | 6 +++--- src/msg/SimpleMessenger.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/mon/MonitorStore.cc b/src/mon/MonitorStore.cc index 015f1d60ca791..92691e0e01591 100644 --- a/src/mon/MonitorStore.cc +++ b/src/mon/MonitorStore.cc @@ -111,7 +111,7 @@ void MonitorStore::put_int(version_t val, const char *a, const char *b) sprintf(tfn, "%s.new", fn); int fd = ::open(tfn, O_WRONLY|O_CREAT, 0644); - assert(fd > 0); + assert(fd >= 0); ::write(fd, vs, strlen(vs)); ::close(fd); ::rename(tfn, fn); @@ -149,7 +149,7 @@ int MonitorStore::get_bl_ss(bufferlist& bl, const char *a, const char *b) } int fd = ::open(fn, O_RDONLY); - if (!fd) { + if (fd < 0) { if (b) { dout(15) << "get_bl " << a << "/" << b << " DNE" << dendl; } else { @@ -202,7 +202,7 @@ int MonitorStore::put_bl_ss(bufferlist& bl, const char *a, const char *b) char tfn[200]; sprintf(tfn, "%s.new", fn); int fd = ::open(tfn, O_WRONLY|O_CREAT, 0644); - assert(fd); + assert(fd >= 0); // write data for (list::const_iterator it = bl.buffers().begin(); diff --git a/src/msg/SimpleMessenger.h b/src/msg/SimpleMessenger.h index 11b6be6d21601..d6c4a428080a3 100644 --- a/src/msg/SimpleMessenger.h +++ b/src/msg/SimpleMessenger.h @@ -199,7 +199,7 @@ private: } void force_close() { - ::close(sd); + if (sd > 0) ::close(sd); } }; -- 2.39.5