From aea0f7108838a5a9ff9d30f82638ed9e4a077601 Mon Sep 17 00:00:00 2001 From: Jordan DeLong Date: Fri, 11 Jan 2013 12:52:50 -0800 Subject: [PATCH] Remove some unnecessary uses of LOG(FATAL) in folly Summary: ScopeGuard::execute will already call std::terminate if an exception is thrown, as it's noexcept, and the case in ConcurrentSkipList should be a check. Test Plan: Ran folly tests. Will look at phabricator to see if anything breaks downstream from removing glog/logging.h from scopeguard. Reviewed By: chip@fb.com FB internal diff: D677038 --- folly/ConcurrentSkipList.h | 6 ++---- folly/ScopeGuard.h | 14 ++------------ folly/test/ScopeGuardTest.cpp | 3 ++- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/folly/ConcurrentSkipList.h b/folly/ConcurrentSkipList.h index b3a6be25..6c2a5006 100644 --- a/folly/ConcurrentSkipList.h +++ b/folly/ConcurrentSkipList.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -182,9 +182,7 @@ class ConcurrentSkipList { //=================================================================== ~ConcurrentSkipList() { - LOG_IF(FATAL, recycler_.refs() > 0) - << "number of accessors is not 0, " << recycler_.refs() << " instead!" - << " This shouldn't have happened!"; + CHECK_EQ(recycler_.refs(), 0); while (NodeType* current = head_.load(std::memory_order_relaxed)) { NodeType* tmp = current->skip(0); NodeType::destroy(current); diff --git a/folly/ScopeGuard.h b/folly/ScopeGuard.h index 5647675f..f6f2e2c3 100644 --- a/folly/ScopeGuard.h +++ b/folly/ScopeGuard.h @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,6 @@ #include #include #include -#include #include "folly/Preprocessor.h" @@ -108,16 +107,7 @@ class ScopeGuardImpl : public ScopeGuardImplBase { private: void* operator new(size_t) = delete; - void execute() noexcept { - try { - function_(); - } catch (const std::exception& ex) { - LOG(FATAL) << "ScopeGuard cleanup function threw a " << - typeid(ex).name() << "exception: " << ex.what(); - } catch (...) { - LOG(FATAL) << "ScopeGuard cleanup function threw a non-exception object"; - } - } + void execute() noexcept { function_(); } FunctionType function_; }; diff --git a/folly/test/ScopeGuardTest.cpp b/folly/test/ScopeGuardTest.cpp index b84f18ce..35b1e3a9 100644 --- a/folly/test/ScopeGuardTest.cpp +++ b/folly/test/ScopeGuardTest.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2012 Facebook, Inc. + * Copyright 2013 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,6 +18,7 @@ #include #include +#include #include #include -- 2.34.1