summaryrefslogtreecommitdiff
path: root/cpp/demo/book/lifecycle/FilesystemI.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2009-03-16 15:57:46 +1000
committerMichi Henning <michi@zeroc.com>2009-03-16 15:57:46 +1000
commit34670a13476e540168578b4e578d2f953af9394e (patch)
tree023b483abd8ef14a7206fe3bebbb3fda3abb78c8 /cpp/demo/book/lifecycle/FilesystemI.cpp
parentBug 3535: Race condition in file system demo (diff)
downloadice-34670a13476e540168578b4e578d2f953af9394e.tar.bz2
ice-34670a13476e540168578b4e578d2f953af9394e.tar.xz
ice-34670a13476e540168578b4e578d2f953af9394e.zip
Bug 3535: moved removeEntry outside synchronization.
Diffstat (limited to 'cpp/demo/book/lifecycle/FilesystemI.cpp')
-rw-r--r--cpp/demo/book/lifecycle/FilesystemI.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/cpp/demo/book/lifecycle/FilesystemI.cpp b/cpp/demo/book/lifecycle/FilesystemI.cpp
index 1cb9f0bd3b5..c48ba2f227d 100644
--- a/cpp/demo/book/lifecycle/FilesystemI.cpp
+++ b/cpp/demo/book/lifecycle/FilesystemI.cpp
@@ -90,15 +90,18 @@ FilesystemI::FileI::write(const Lines& text, const Current& c)
void
FilesystemI::FileI::destroy(const Current& c)
{
- IceUtil::Mutex::Lock lock(_m);
-
- if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
+ IceUtil::Mutex::Lock lock(_m);
+
+ if(_destroyed)
+ {
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
+ }
+
+ c.adapter->remove(id());
+ _destroyed = true;
}
- _destroyed = true;
- c.adapter->remove(id());
_parent->removeEntry(_name);
}
@@ -215,20 +218,23 @@ FilesystemI::DirectoryI::destroy(const Current& c)
throw PermissionDenied("Cannot destroy root directory");
}
- IceUtil::Mutex::Lock lock(_m);
-
- if(_destroyed)
{
- throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
- }
+ IceUtil::Mutex::Lock lock(_m);
- if(!_contents.empty())
- {
- throw PermissionDenied("Cannot destroy non-empty directory");
+ if(_destroyed)
+ {
+ throw ObjectNotExistException(__FILE__, __LINE__, c.id, c.facet, c.operation);
+ }
+
+ if(!_contents.empty())
+ {
+ throw PermissionDenied("Cannot destroy non-empty directory");
+ }
+
+ c.adapter->remove(id());
+ _destroyed = true;
}
- c.adapter->remove(id());
- _destroyed = true;
_parent->removeEntry(_name);
}