summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-x[-rw-r--r--]buildscripts/cpplint.py45
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp6
-rw-r--r--src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h4
-rw-r--r--src/mongo/dbtests/perftests.cpp16
-rw-r--r--src/mongo/stdx/chrono.h2
-rw-r--r--src/mongo/stdx/condition_variable.h6
-rw-r--r--src/mongo/stdx/functional.h10
-rw-r--r--src/mongo/stdx/future.h12
-rw-r--r--src/mongo/stdx/memory.h4
-rw-r--r--src/mongo/stdx/mutex.h16
-rw-r--r--src/mongo/stdx/thread.h4
-rw-r--r--src/mongo/util/concurrency/rwlockimpl.h6
12 files changed, 88 insertions, 43 deletions
diff --git a/buildscripts/cpplint.py b/buildscripts/cpplint.py
index 008e4038a08..65413b1bea0 100644..100755
--- a/buildscripts/cpplint.py
+++ b/buildscripts/cpplint.py
@@ -190,6 +190,7 @@ _ERROR_CATEGORIES = [
'build/printf_format',
'build/storage_class',
'legal/copyright',
+ 'mongo/polyfill',
'readability/alt_tokens',
'readability/braces',
'readability/casting',
@@ -1610,6 +1611,49 @@ def ReverseCloseExpression(clean_lines, linenum, pos):
# Did not find start of expression before beginning of file, give up
return (line, 0, -1)
+def make_polyfill_regex():
+ polyfill_required_names = [
+ '_',
+ 'adopt_lock',
+ 'async',
+ 'bind',
+ 'chrono',
+ 'condition_variable',
+ 'condition_variable_any',
+ 'cv_status',
+ 'defer_lock',
+ 'function',
+ 'future',
+ 'future_status',
+ 'launch',
+ 'lock_guard',
+ 'make_unique',
+ 'mutex',
+ 'packaged_task',
+ 'placeholders',
+ 'promise',
+ 'recursive_mutex',
+ 'shared_lock,',
+ 'shared_mutex',
+ 'shared_timed_mutex',
+ 'this_thread',
+ 'thread',
+ 'timed_mutex',
+ 'try_to_lock',
+ 'unique_lock',
+ ]
+
+ qualified_names = ['boost::' + name + "(?!_)" for name in polyfill_required_names]
+ qualified_names.extend('std::' + name + "(?!_)" for name in polyfill_required_names)
+ qualified_names_regex = '|'.join(qualified_names)
+ return re.compile(qualified_names_regex)
+_RE_PATTERN_MONGO_POLYFILL=make_polyfill_regex()
+
+def CheckForMongoPolyfill(filename, clean_lines, linenum, error):
+ line = clean_lines.elided[linenum]
+ if re.search(_RE_PATTERN_MONGO_POLYFILL, line):
+ error(filename, linenum, 'mongodb/polyfill', 5,
+ 'Illegal use of banned name from std::/boost::, use mongo::stdx:: variant instead')
def CheckForCopyright(filename, lines, error):
"""Logs an error if no Copyright message appears at the top of the file."""
@@ -5752,6 +5796,7 @@ def ProcessLine(filename, file_extension, clean_lines, line,
nesting_state.Update(filename, clean_lines, line, error)
CheckForNamespaceIndentation(filename, nesting_state, clean_lines, line,
error)
+ CheckForMongoPolyfill(filename, clean_lines, line, error)
if nesting_state.InAsmBlock(): return
CheckForFunctionLengths(filename, clean_lines, line, function_state, error)
CheckForMultilineCommentsAndStrings(filename, clean_lines, line, error)
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
index 2bb1c0c0b99..1401ea80108 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp
@@ -149,7 +149,7 @@ void WiredTigerSessionCache::shuttingDown() {
// This ensures that any calls, which are currently inside of getSession/releaseSession
// will be able to complete before we start cleaning up the pool. Any others, which are
// about to enter will return immediately because of _shuttingDown == true.
- stdx::lock_guard<boost::shared_mutex> lk(_shutdownLock);
+ stdx::lock_guard<boost::shared_mutex> lk(_shutdownLock); // NOLINT
}
closeAll();
@@ -172,7 +172,7 @@ void WiredTigerSessionCache::closeAll() {
}
WiredTigerSession* WiredTigerSessionCache::getSession() {
- boost::shared_lock<boost::shared_mutex> shutdownLock(_shutdownLock);
+ boost::shared_lock<boost::shared_mutex> shutdownLock(_shutdownLock); // NOLINT
// We should never be able to get here after _shuttingDown is set, because no new
// operations should be allowed to start.
@@ -203,7 +203,7 @@ void WiredTigerSessionCache::releaseSession(WiredTigerSession* session) {
invariant(session);
invariant(session->cursorsOut() == 0);
- boost::shared_lock<boost::shared_mutex> shutdownLock(_shutdownLock);
+ boost::shared_lock<boost::shared_mutex> shutdownLock(_shutdownLock); // NOLINT
if (_shuttingDown.loadRelaxed()) {
// Leak the session in order to avoid race condition with clean shutdown, where the
// storage engine is ripped from underneath transactions, which are not "active"
diff --git a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
index 9760e6e48f9..546b1797b6c 100644
--- a/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
+++ b/src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.h
@@ -148,8 +148,8 @@ private:
// Regular operations take it in shared mode. Shutdown sets the _shuttingDown flag and
// then takes it in exclusive mode. This ensures that all threads, which would return
// sessions to the cache would leak them.
- boost::shared_mutex _shutdownLock;
- AtomicUInt32 _shuttingDown; // Used as boolean - 0 = false, 1 = true
+ boost::shared_mutex _shutdownLock; // NOLINT
+ AtomicUInt32 _shuttingDown; // Used as boolean - 0 = false, 1 = true
SpinLock _cacheLock;
typedef std::list<WiredTigerSession*> SessionCache;
diff --git a/src/mongo/dbtests/perftests.cpp b/src/mongo/dbtests/perftests.cpp
index d2e0a8009e6..5021eff0558 100644
--- a/src/mongo/dbtests/perftests.cpp
+++ b/src/mongo/dbtests/perftests.cpp
@@ -605,10 +605,10 @@ public:
RWLock lk("testrw");
SimpleMutex m;
-boost::mutex mboost;
-boost::timed_mutex mboost_timed;
-std::mutex mstd;
-std::timed_mutex mstd_timed;
+boost::mutex mboost; // NOLINT
+boost::timed_mutex mboost_timed; // NOLINT
+std::mutex mstd; // NOLINT
+std::timed_mutex mstd_timed; // NOLINT
SpinLock s;
stdx::condition_variable c;
@@ -639,7 +639,7 @@ public:
return false;
}
void timed() {
- boost::lock_guard<boost::mutex> lk(mboost);
+ boost::lock_guard<boost::mutex> lk(mboost); // NOLINT
}
};
class boosttimed_mutexspeed : public B {
@@ -654,7 +654,7 @@ public:
return false;
}
void timed() {
- boost::lock_guard<boost::timed_mutex> lk(mboost_timed);
+ boost::lock_guard<boost::timed_mutex> lk(mboost_timed); // NOLINT
}
};
class simplemutexspeed : public B {
@@ -685,7 +685,7 @@ public:
return false;
}
void timed() {
- std::lock_guard<std::mutex> lk(mstd);
+ std::lock_guard<std::mutex> lk(mstd); // NOLINT
}
};
class stdtimed_mutexspeed : public B {
@@ -700,7 +700,7 @@ public:
return false;
}
void timed() {
- std::lock_guard<std::timed_mutex> lk(mstd_timed);
+ std::lock_guard<std::timed_mutex> lk(mstd_timed); // NOLINT
}
};
diff --git a/src/mongo/stdx/chrono.h b/src/mongo/stdx/chrono.h
index 797b5d3b963..47ab2a2d231 100644
--- a/src/mongo/stdx/chrono.h
+++ b/src/mongo/stdx/chrono.h
@@ -33,7 +33,7 @@
namespace mongo {
namespace stdx {
-namespace chrono = boost::chrono;
+namespace chrono = boost::chrono; // NOLINT
} // namespace stdx
} // namespace mongo
diff --git a/src/mongo/stdx/condition_variable.h b/src/mongo/stdx/condition_variable.h
index e3d77a853a8..206a9e84465 100644
--- a/src/mongo/stdx/condition_variable.h
+++ b/src/mongo/stdx/condition_variable.h
@@ -33,9 +33,9 @@
namespace mongo {
namespace stdx {
-using condition_variable = boost::condition_variable;
-using condition_variable_any = boost::condition_variable_any;
-using cv_status = boost::cv_status;
+using condition_variable = boost::condition_variable; // NOLINT
+using condition_variable_any = boost::condition_variable_any; // NOLINT
+using cv_status = boost::cv_status; // NOLINT
} // namespace stdx
} // namespace mongo
diff --git a/src/mongo/stdx/functional.h b/src/mongo/stdx/functional.h
index d86973b2066..c20f6e21310 100644
--- a/src/mongo/stdx/functional.h
+++ b/src/mongo/stdx/functional.h
@@ -42,9 +42,9 @@
namespace mongo {
namespace stdx {
-using ::std::bind;
-using ::std::function;
-namespace placeholders = ::std::placeholders;
+using ::std::bind; // NOLINT
+using ::std::function; // NOLINT
+namespace placeholders = ::std::placeholders; // NOLINT
} // namespace stdx
} // namespace mongo
@@ -57,8 +57,8 @@ namespace placeholders = ::std::placeholders;
namespace mongo {
namespace stdx {
-using boost::bind;
-using boost::function;
+using boost::bind; // NOLINT
+using boost::function; // NOLINT
namespace placeholders {
static boost::arg<1> _1;
diff --git a/src/mongo/stdx/future.h b/src/mongo/stdx/future.h
index bbc46efac14..bc4816aff6f 100644
--- a/src/mongo/stdx/future.h
+++ b/src/mongo/stdx/future.h
@@ -33,12 +33,12 @@
namespace mongo {
namespace stdx {
-using boost::async;
-using boost::future;
-using boost::future_status;
-using boost::launch;
-using boost::packaged_task;
-using boost::promise;
+using boost::async; // NOLINT
+using boost::future; // NOLINT
+using boost::future_status; // NOLINT
+using boost::launch; // NOLINT
+using boost::packaged_task; // NOLINT
+using boost::promise; // NOLINT
} // namespace stdx
} // namespace mongo
diff --git a/src/mongo/stdx/memory.h b/src/mongo/stdx/memory.h
index 1c4f512dc5a..83793f86c5a 100644
--- a/src/mongo/stdx/memory.h
+++ b/src/mongo/stdx/memory.h
@@ -37,7 +37,7 @@
namespace mongo {
namespace stdx {
-using ::std::make_unique;
+using ::std::make_unique; // NOLINT
} // namespace stdx
} // namespace mongo
@@ -49,7 +49,7 @@ using ::std::make_unique;
namespace mongo {
namespace stdx {
-using boost::make_unique;
+using boost::make_unique; // NOLINT
} // namespace stdx
} // namespace mongo
diff --git a/src/mongo/stdx/mutex.h b/src/mongo/stdx/mutex.h
index 9dc0f0c07b1..4303d25fba2 100644
--- a/src/mongo/stdx/mutex.h
+++ b/src/mongo/stdx/mutex.h
@@ -35,16 +35,16 @@
namespace mongo {
namespace stdx {
-using boost::mutex;
-using boost::timed_mutex;
-using boost::recursive_mutex;
+using boost::mutex; // NOLINT
+using boost::timed_mutex; // NOLINT
+using boost::recursive_mutex; // NOLINT
-using boost::adopt_lock_t;
-using boost::defer_lock_t;
-using boost::try_to_lock_t;
+using boost::adopt_lock_t; // NOLINT
+using boost::defer_lock_t; // NOLINT
+using boost::try_to_lock_t; // NOLINT
-using boost::lock_guard;
-using boost::unique_lock;
+using boost::lock_guard; // NOLINT
+using boost::unique_lock; // NOLINT
#if _MSC_VER < 1900
#define MONGO_STDX_CONSTEXPR const
diff --git a/src/mongo/stdx/thread.h b/src/mongo/stdx/thread.h
index 3b9490b2d67..e46900c02a3 100644
--- a/src/mongo/stdx/thread.h
+++ b/src/mongo/stdx/thread.h
@@ -33,8 +33,8 @@
namespace mongo {
namespace stdx {
-using thread = boost::thread;
-namespace this_thread = boost::this_thread;
+using thread = boost::thread; // NOLINT
+namespace this_thread = boost::this_thread; // NOLINT
} // namespace stdx
} // namespace mongo
diff --git a/src/mongo/util/concurrency/rwlockimpl.h b/src/mongo/util/concurrency/rwlockimpl.h
index d0d4c8fad99..40103080911 100644
--- a/src/mongo/util/concurrency/rwlockimpl.h
+++ b/src/mongo/util/concurrency/rwlockimpl.h
@@ -125,7 +125,7 @@ using rwlock_underlying_shared_mutex = boost::modified_shared_mutex;
#include <boost/thread/shared_mutex.hpp>
namespace mongo {
namespace detail {
-using rwlock_underlying_shared_mutex = boost::shared_mutex;
+using rwlock_underlying_shared_mutex = boost::shared_mutex; // NOLINT
} // namespace detail
} // namespace mongo
#endif
@@ -164,14 +164,14 @@ protected:
#if defined(_WIN32)
return _m.timed_lock_shared(boost::posix_time::milliseconds(millis));
#else
- return _m.try_lock_shared_for(boost::chrono::milliseconds(millis));
+ return _m.try_lock_shared_for(boost::chrono::milliseconds(millis)); // NOLINT
#endif
}
bool lock_try(int millis = 0) {
#if defined(_WIN32)
return _m.timed_lock(boost::posix_time::milliseconds(millis));
#else
- return _m.try_lock_for(boost::chrono::milliseconds(millis));
+ return _m.try_lock_for(boost::chrono::milliseconds(millis)); // NOLINT
#endif
}