diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-05-31 14:33:22 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-05-31 14:33:22 +0000 |
commit | 33936593ff384763588979e128f20d4951e0d268 (patch) | |
tree | 5e9f20d58cf9b6ca084b02b1c3d9e38bbea9f047 /cpp/src/IceGrid/Database.cpp | |
parent | Added locator trace for IceGrid (diff) | |
download | ice-33936593ff384763588979e128f20d4951e0d268.tar.bz2 ice-33936593ff384763588979e128f20d4951e0d268.tar.xz ice-33936593ff384763588979e128f20d4951e0d268.zip |
Session fixes
Diffstat (limited to 'cpp/src/IceGrid/Database.cpp')
-rw-r--r-- | cpp/src/IceGrid/Database.cpp | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/cpp/src/IceGrid/Database.cpp b/cpp/src/IceGrid/Database.cpp index 144544d3e46..7ca95468137 100644 --- a/cpp/src/IceGrid/Database.cpp +++ b/cpp/src/IceGrid/Database.cpp @@ -220,11 +220,13 @@ Database::setObservers(const RegistryObserverPrx& registryObserver, const NodeOb void Database::checkSessionLock(AdminSessionI* session) { - if(_lock != 0 && session != _lock) + if(_lock == 0 && session) { - AccessDeniedException ex; - ex.lockUserId = _lockUserId; - throw ex; + throw AccessDeniedException(); // Sessions must first acquire the lock! + } + else if(_lock != 0 && session != _lock) + { + throw AccessDeniedException(_lockUserId); // Lock held by another session. } } @@ -232,7 +234,12 @@ int Database::lock(AdminSessionI* session, const string& userId) { Lock sync(*this); - checkSessionLock(session); + + if(_lock != 0 && session != _lock) + { + throw AccessDeniedException(_lockUserId); // Lock held by another session. + } + assert(_lock == 0 || _lock == session); _lock = session; _lockUserId = userId; @@ -244,7 +251,11 @@ void Database::unlock(AdminSessionI* session) { Lock sync(*this); - assert(_lock == session); + if(_lock != session) + { + throw AccessDeniedException(); + } + _lock = 0; _lockUserId.clear(); } @@ -442,14 +453,17 @@ Database::removeApplicationDescriptor(AdminSessionI* session, const std::string& } void -Database::instantiateServer(const string& application, const string& node, const ServerInstanceDescriptor& instance) +Database::instantiateServer(AdminSessionI* session, + const string& application, + const string& node, + const ServerInstanceDescriptor& instance) { ServerEntrySeq entries; int serial; ApplicationUpdateDescriptor update; { Lock sync(*this); - checkSessionLock(0); + checkSessionLock(session); StringApplicationDescriptorDict::const_iterator p = _descriptors.find(application); if(p == _descriptors.end()) |