folly/wangle -> wangle cutover
[folly.git] / folly / File.cpp
index 0dece45d6525ac58ec08544a8d07e57aafa784ec..253d005472a0a80f52c5bb67452071d0b9538c69 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <fcntl.h>
 #include <unistd.h>
+#include <sys/file.h>
 
 #include <folly/Exception.h>
 #include <folly/FileUtil.h>
@@ -65,7 +66,11 @@ File& File::operator=(File&& other) {
 }
 
 File::~File() {
-  closeNoThrow();  // ignore error
+  auto fd = fd_;
+  if (!closeNoThrow()) {  // ignore most errors
+    DCHECK_NE(errno, EBADF) << "closing fd " << fd << ", it may already "
+      << "have been closed. Another time, this might close the wrong FD.";
+  }
 }
 
 /* static */ File File::temporary() {