Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tishj committed Oct 21, 2023
1 parent 0503915 commit e9d85c9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/include/duckdb/main/client_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,16 +274,20 @@ class ClientContextLock {
private:
// The identifier for an invalid thread
static const std::thread::id INVALID_THREAD;

private:
explicit ClientContextLock(mutex &context_lock, atomic<std::thread::id> &marker) : client_guard(context_lock), marker(marker) {
explicit ClientContextLock(mutex &context_lock, atomic<std::thread::id> &marker)
: client_guard(context_lock), marker(marker) {
// Set the current thread so lock attempts by the same thread don't result in a deadlock
marker = std::this_thread::get_id();
}

public:
~ClientContextLock() {
// Unset the current thread before unlocking the client_guard
marker = INVALID_THREAD;
}

public:
static unique_ptr<ClientContextLock> Lock(ClientContext &context) {
auto can_lock = context.context_lock.try_lock();
Expand Down
3 changes: 2 additions & 1 deletion src/main/client_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ struct ActiveQueryContext {
};

ClientContext::ClientContext(shared_ptr<DatabaseInstance> database)
: db(std::move(database)), interrupted(false), client_data(make_uniq<ClientData>(*this)), transaction(*this), thread_id(std::thread::id()) {
: db(std::move(database)), interrupted(false), client_data(make_uniq<ClientData>(*this)), transaction(*this),
thread_id(std::thread::id()) {
}

ClientContext::~ClientContext() {
Expand Down

0 comments on commit e9d85c9

Please sign in to comment.