summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2006-01-20 13:45:59 +0000
committerBenoit Foucher <benoit@zeroc.com>2006-01-20 13:45:59 +0000
commit9d6dea6bd5f161090490cdbe4f5a8f800fe18102 (patch)
tree6afc5338579c30711640c9a2d6a27316ad3438a5 /cpp/src
parentFix (diff)
downloadice-9d6dea6bd5f161090490cdbe4f5a8f800fe18102.tar.bz2
ice-9d6dea6bd5f161090490cdbe4f5a8f800fe18102.tar.xz
ice-9d6dea6bd5f161090490cdbe4f5a8f800fe18102.zip
Fixed race condition in server activation (bug 807).
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/IceGrid/ServerI.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index c1006cadec5..cc32ab551dd 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -1128,6 +1128,19 @@ ServerI::activate()
failure = os.str();
}
+ ServerCommandPtr command;
+ {
+ Lock sync(*this);
+ disableOnFailure();
+ setStateNoSync(ServerI::Inactive, failure);
+ command = nextCommand();
+ }
+
+ //
+ // It's important to notify the adapters after changing the state!
+ // Otherwise, a race condition could occur if an adapter is
+ // activated after the notification and the state change.
+ //
for(ServerAdapterDict::iterator r = adpts.begin(); r != adpts.end(); ++r)
{
try
@@ -1138,14 +1151,7 @@ ServerI::activate()
{
}
}
-
- ServerCommandPtr command;
- {
- Lock sync(*this);
- disableOnFailure();
- setStateNoSync(ServerI::Inactive, failure);
- command = nextCommand();
- }
+
if(command)
{
command->execute();