Skip to content

Commit 521ed17

Browse files
committed
Fix possible concurrency issue with the session mutex
The sessions vector may be changed concurrently with sessionCount() being called. Thread sanitizer catches this issue. sessionCount() is only used in session created/session destroyed log messages, so I don't really think there's a big issue right now, and the lock does of course come with some cost.
1 parent 4caa5f0 commit 521ed17

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/web/WebController.C

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ Configuration& WebController::configuration()
164164

165165
int WebController::sessionCount() const
166166
{
167+
#ifdef WT_THREADED
168+
std::unique_lock<std::recursive_mutex> lock(mutex_);
169+
#endif
167170
return sessions_.size();
168171
}
169172

src/web/WebController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class WT_API WebController
172172
#ifdef WT_THREADED
173173
// mutex to protect access to the sessions map and plain/ajax session
174174
// counts
175-
std::recursive_mutex mutex_;
175+
mutable std::recursive_mutex mutex_;
176176

177177
SocketNotifier socketNotifier_;
178178
// mutex to protect access to notifier maps. This cannot be protected

0 commit comments

Comments
 (0)