Loading src/backend.cpp +10 −7 Changes for src/backend.cpp: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -69,19 +69,22 @@ void authdb::AuthBackend::write(const unsigned char* dest, size_t destsize){ } void authdb::AuthBackend::lock(){ if (!_Lock.try_lock_for(std::chrono::seconds(5))) throw AuthBackendError("backend lock timeout"); try { // Cluster sync (network I/O) runs BEFORE acquiring the backend mutex. // This prevents distributed deadlocks where two nodes hold their // backend locks and wait for each other's peer fetch to complete. _Api->lock(); } catch (...) { _Lock.unlock(); throw; if (!_Lock.try_lock_for(std::chrono::seconds(5))) { // If we can't get the lock, undo the cluster fetch _Api->unlock(); throw AuthBackendError("backend lock timeout"); } } void authdb::AuthBackend::unlock(){ _Api->unlock(); // Release the backend mutex BEFORE cluster push (network I/O) // so other local threads can proceed while replication happens. _Lock.unlock(); _Api->unlock(); } void authdb::AuthBackend::setPos(size_t pos){ Loading Loading
src/backend.cpp +10 −7 Changes for src/backend.cpp: 10 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -69,19 +69,22 @@ void authdb::AuthBackend::write(const unsigned char* dest, size_t destsize){ } void authdb::AuthBackend::lock(){ if (!_Lock.try_lock_for(std::chrono::seconds(5))) throw AuthBackendError("backend lock timeout"); try { // Cluster sync (network I/O) runs BEFORE acquiring the backend mutex. // This prevents distributed deadlocks where two nodes hold their // backend locks and wait for each other's peer fetch to complete. _Api->lock(); } catch (...) { _Lock.unlock(); throw; if (!_Lock.try_lock_for(std::chrono::seconds(5))) { // If we can't get the lock, undo the cluster fetch _Api->unlock(); throw AuthBackendError("backend lock timeout"); } } void authdb::AuthBackend::unlock(){ _Api->unlock(); // Release the backend mutex BEFORE cluster push (network I/O) // so other local threads can proceed while replication happens. _Lock.unlock(); _Api->unlock(); } void authdb::AuthBackend::setPos(size_t pos){ Loading