summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2007-11-05 23:48:51 +1000
committerMichi Henning <michi@zeroc.com>2007-11-05 23:48:51 +1000
commited2d219830a72554d2110e90bb79189f16e24cfa (patch)
tree23dc22d4f5216f691e53b54b4a26b07c419ca594
parentBug 2522 for C++ and Java. (diff)
parentFix VC60 compilation problems (diff)
downloadice-ed2d219830a72554d2110e90bb79189f16e24cfa.tar.bz2
ice-ed2d219830a72554d2110e90bb79189f16e24cfa.tar.xz
ice-ed2d219830a72554d2110e90bb79189f16e24cfa.zip
Merge branch 'master' of ssh://cvs.zeroc.com/home/git/ice
-rwxr-xr-xcpp/config/PropertyNames.xml1
-rw-r--r--cpp/src/Freeze/MapI.cpp11
-rw-r--r--cpp/src/Ice/PropertyNames.cpp3
-rw-r--r--cpp/src/Ice/PropertyNames.h2
-rwxr-xr-xcpp/src/Ice/Service.cpp52
-rwxr-xr-xcpp/src/iceserviceinstall/Install.cpp11
-rwxr-xr-xcpp/src/iceserviceinstall/ServiceInstaller.cpp221
-rwxr-xr-xcpp/src/iceserviceinstall/ServiceInstaller.h21
-rw-r--r--cs/src/Ice/PropertyNames.cs3
-rw-r--r--java/src/IceInternal/PropertyNames.java3
10 files changed, 250 insertions, 78 deletions
diff --git a/cpp/config/PropertyNames.xml b/cpp/config/PropertyNames.xml
index b4456e4a9c7..6f62e69307d 100755
--- a/cpp/config/PropertyNames.xml
+++ b/cpp/config/PropertyNames.xml
@@ -318,6 +318,7 @@ generated from the section label.
<property name="Default.PreferSecure" />
<property name="Default.Protocol" />
<property name="Default.Router" class="proxy" />
+ <property name="EventLog.Source" />
<property name="GC.Interval" />
<property name="ImplicitContext" />
<property name="InitPlugins" />
diff --git a/cpp/src/Freeze/MapI.cpp b/cpp/src/Freeze/MapI.cpp
index ff8ffb916ee..390b4253ccb 100644
--- a/cpp/src/Freeze/MapI.cpp
+++ b/cpp/src/Freeze/MapI.cpp
@@ -1317,14 +1317,11 @@ Freeze::MapHelperI::close()
_connection->unregisterMap(this);
}
_db = 0;
-
- for(IndexMap::iterator p = _indices.begin(); p != _indices.end(); ++p)
- {
- MapIndexBasePtr& indexBase = p->second;
- indexBase->_impl = 0;
- indexBase->_map = 0;
- }
+ //
+ // We can't clear the indexBase as MapIndexI is using
+ // the first map's indexBase objects
+ //
_indices.clear();
}
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index cb5e8ce95fc..8f282dcdb08 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Fri Oct 12 15:45:46 2007
+// Generated by makeprops.py from file ..\config\PropertyNames.xml, Mon Oct 29 16:59:13 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -66,6 +66,7 @@ const IceInternal::Property IcePropsData[] =
IceInternal::Property("Ice.Default.Router.CollocationOptimized", false, 0),
IceInternal::Property("Ice.Default.Router.ThreadPerConnection", false, 0),
IceInternal::Property("Ice.Default.Router", false, 0),
+ IceInternal::Property("Ice.EventLog.Source", false, 0),
IceInternal::Property("Ice.GC.Interval", false, 0),
IceInternal::Property("Ice.ImplicitContext", false, 0),
IceInternal::Property("Ice.InitPlugins", false, 0),
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index 9896f908a5a..337d21a566f 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Fri Oct 12 15:45:46 2007
+// Generated by makeprops.py from file ..\config\PropertyNames.xml, Mon Oct 29 16:59:13 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 155b2c68625..312a6914fc7 100755
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -140,9 +140,9 @@ class SMEventLoggerI : public Ice::Logger
{
public:
- SMEventLoggerI(const string& service)
+ SMEventLoggerI(const string& source)
{
- _source = RegisterEventSource(0, mangleService(service).c_str());
+ _source = RegisterEventSource(0, mangleSource(source).c_str());
if(_source == 0)
{
SyscallException ex(__FILE__, __LINE__);
@@ -156,13 +156,13 @@ public:
assert(_source != 0);
DeregisterEventSource(_source);
}
-
+
static void
- addKeys(const string& service)
+ addKeys(const string& source)
{
HKEY hKey;
DWORD d;
- LONG err = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createKey(service).c_str(), 0, "REG_SZ",
+ LONG err = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createKey(source).c_str(), 0, "REG_SZ",
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d);
if(err != ERROR_SUCCESS)
{
@@ -189,7 +189,7 @@ public:
// the "EventMessageFile" key should contain the path to this
// DLL.
//
- err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
+ err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
reinterpret_cast<unsigned char*>(path), static_cast<DWORD>(strlen(path) + 1));
if(err == ERROR_SUCCESS)
{
@@ -213,9 +213,9 @@ public:
}
static void
- removeKeys(const string& theService)
+ removeKeys(const string& source)
{
- LONG err = RegDeleteKey(HKEY_LOCAL_MACHINE, createKey(theService).c_str());
+ LONG err = RegDeleteKey(HKEY_LOCAL_MACHINE, createKey(source).c_str());
if(err != ERROR_SUCCESS)
{
SyscallException ex(__FILE__, __LINE__);
@@ -285,14 +285,14 @@ public:
{
_module = module;
}
-
+
private:
static string
- mangleService(string name)
+ mangleSource(string name)
{
//
- // The service name cannot contain backslashes.
+ // The source name cannot contain backslashes.
//
string::size_type pos = 0;
while((pos = name.find('\\', pos)) != string::npos)
@@ -310,7 +310,7 @@ private:
//
// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application.
//
- return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleService(name);
+ return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleSource(name);
}
@@ -379,15 +379,32 @@ Ice::Service::interrupt()
}
int
-Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
+Ice::Service::main(int& argc, char* argv[], const InitializationData& initializationData)
{
_name = argv[0];
#ifdef _WIN32
+
+ //
+ // On Windows, we parse the properties here to extract Ice.EventLog.Source
+ //
+ InitializationData initData = initializationData;
+ if(initData.properties == 0)
+ {
+ initData.properties = createProperties(argc, argv, initData.properties, initData.stringConverter);
+ }
+ else
+ {
+ StringSeq options = argsToStringSeq(argc, argv);
+ options = initData.properties->parseIceCommandLineOptions(options);
+ stringSeqToArgs(options, argc, argv);
+ }
+
//
// First check for the --service option.
//
string name;
+ string eventLogSource;
int idx = 1;
while(idx < argc)
{
@@ -408,7 +425,9 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
_logger = getProcessLogger();
if(LoggerIPtr::dynamicCast(_logger))
{
- _logger = new SMEventLoggerI(name);
+ string eventLogSource = initData.properties->
+ getPropertyWithDefault("Ice.EventLog.Source", name);
+ _logger = new SMEventLoggerI(eventLogSource);
setProcessLogger(_logger);
}
@@ -584,6 +603,9 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initData)
//
// Check for --daemon, --noclose, --nochdir and --pidfile.
//
+
+ const InitializationData& initData = initializationData;
+
bool daemonize = false;
bool closeFiles = true;
bool changeDirectory = true;
@@ -1939,7 +1961,7 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
assert(fd == 2);
}
}
-
+
//
// Write PID
//
diff --git a/cpp/src/iceserviceinstall/Install.cpp b/cpp/src/iceserviceinstall/Install.cpp
index 6ea57893086..336e4a3b820 100755
--- a/cpp/src/iceserviceinstall/Install.cpp
+++ b/cpp/src/iceserviceinstall/Install.cpp
@@ -94,11 +94,11 @@ Install::run(int argc, char* argv[])
}
int serviceType = -1;
- for(int i = 0; i < IceServiceInstaller::serviceCount; ++i)
+ for(int j = 0; j < IceServiceInstaller::serviceCount; ++j)
{
- if(commands[0] == IceServiceInstaller::serviceTypeToLowerString(i))
+ if(commands[0] == IceServiceInstaller::serviceTypeToLowerString(j))
{
- serviceType = i;
+ serviceType = j;
break; // for
}
}
@@ -188,12 +188,15 @@ Install::usage() const
" <directory of " << appName() << ">\\<service>.exe\n"
"DisplayName Display name for the service\n"
"Description Description for the service\n"
+ "AutoStart When non 0, the service is started automatically when\n"
+ " the computer starts up. The default value is 1\n"
"ObjectName Account used to run the service. Defaults to\n"
" NT Authority\\LocalService\n"
"Password Password for ObjectName\n"
"DependOnRegistry When non 0, the service depends on the IceGrid registry\n"
" service (the IceGrid registry service name is computed\n"
" using Ice.Default.Locator in <config-file>).\n"
+ "EventLog The name of the EventLog used by this service;\n"
+ " the default is Application\n"
;
}
-
diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.cpp b/cpp/src/iceserviceinstall/ServiceInstaller.cpp
index ee0325665d5..8ed93fc16a2 100755
--- a/cpp/src/iceserviceinstall/ServiceInstaller.cpp
+++ b/cpp/src/iceserviceinstall/ServiceInstaller.cpp
@@ -65,12 +65,12 @@ IceServiceInstaller::IceServiceInstaller(int serviceType, const string& configFi
{
if(_icegridInstanceName == "")
{
- throw string("Ice.Default.Locator must be set in " + _configFile);
+ throw "Ice.Default.Locator must be set in " + _configFile;
}
_nodeName = _serviceProperties->getProperty("IceGrid.Node.Name");
if(_nodeName == "")
{
- throw string("IceGrid.Node.Name must be set in " + _configFile);
+ throw "IceGrid.Node.Name must be set in " + _configFile;
}
_serviceName = serviceTypeToLowerString(_serviceType) + "." + _icegridInstanceName + "." + _nodeName;
}
@@ -83,7 +83,7 @@ IceServiceInstaller::IceServiceInstaller(int serviceType, const string& configFi
}
else
{
- throw string("Unknown service type");
+ throw "Unknown service type";
}
}
}
@@ -104,9 +104,9 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
const string defaultDisplayName[] =
{
- string("IceGrid registry (") + _icegridInstanceName + ")",
- string("IceGrid node (") + _nodeName + " within " + _icegridInstanceName + ")",
- string("Glacier2 router (") + _glacier2InstanceName + ")"
+ "IceGrid registry (" + _icegridInstanceName + ")",
+ "IceGrid node (" + _nodeName + " within " + _icegridInstanceName + ")",
+ "Glacier2 router (" + _glacier2InstanceName + ")"
};
const string defaultDescription[] =
@@ -133,7 +133,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
throw "Can't get full path to self: " + formatMessage(GetLastError());
}
imagePath = string(buffer, size);
- imagePath.replace(imagePath.rfind('\\'), string::npos, string("\\")
+ imagePath.replace(imagePath.rfind('\\'), string::npos, "\\"
+ serviceTypeToLowerString(_serviceType) + ".exe");
}
if(!fileExists(imagePath))
@@ -147,13 +147,13 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
{
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
- throw string("The IceGrid registry service can't depend on itself");
+ throw "The IceGrid registry service can't depend on itself";
}
string registryDataDir = _serviceProperties->getProperty("IceGrid.Registry.Data");
if(registryDataDir == "")
{
- throw string("IceGrid.Registry.Data must be set in " + _configFile);
+ throw "IceGrid.Registry.Data must be set in " + _configFile;
}
if(!mkdir(registryDataDir))
{
@@ -165,7 +165,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
string nodeDataDir = _serviceProperties->getProperty("IceGrid.Node.Data");
if(nodeDataDir == "")
{
- throw string("IceGrid.Node.Data must be set in " + _configFile);
+ throw "IceGrid.Node.Data must be set in " + _configFile;
}
if(!mkdir(nodeDataDir))
{
@@ -187,8 +187,8 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
{
if(_icegridInstanceName == "")
{
- throw string("Ice.Default.Locator must be set in " + _configFile
- + " when DependOnRegistry is not zero");
+ throw"Ice.Default.Locator must be set in " + _configFile
+ + " when DependOnRegistry is not zero";
}
dependency = "icegridregistry." + _icegridInstanceName;
}
@@ -196,13 +196,25 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
grantPermissions(_configFile);
- addEventLogKey(_serviceName, getIceDLLPath(imagePath));
+ string eventLog = properties->getProperty("EventLog");
+ if(eventLog == "")
+ {
+ eventLog = "Application";
+ }
+ else
+ {
+ addLog(eventLog);
+ }
+
+ string eventLogSource = _serviceProperties->getPropertyWithDefault("Ice.EventLog.Source", _serviceName);
+
+ addSource(eventLogSource, eventLog, getIceDLLPath(imagePath));
SC_HANDLE scm = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
if(scm == 0)
{
DWORD res = GetLastError();
- throw string("Cannot open SCM: ") + formatMessage(res);
+ throw "Cannot open SCM: " + formatMessage(res);
}
string deps = dependency;
@@ -232,12 +244,13 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
char fullPath[MAX_PATH];
if(GetFullPathName(_configFile.c_str(), MAX_PATH, fullPath, 0) > MAX_PATH)
{
- throw string("Could not compute the full path of ") + _configFile;
+ throw "Could not compute the full path of " + _configFile;
}
string command = "\"" + imagePath + "\" --service " + _serviceName
+ " --Ice.Config=\"" + fullPath + "\"";
+ bool autoStart = properties->getPropertyAsIntWithDefault("AutoStart", 1) != 0;
string password = properties->getProperty("Password");
SC_HANDLE service = CreateService(
@@ -246,7 +259,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
displayName.c_str(),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
- SERVICE_AUTO_START,
+ autoStart ? SERVICE_AUTO_START : SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL,
command.c_str(),
0,
@@ -259,7 +272,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
{
DWORD res = GetLastError();
CloseServiceHandle(scm);
- throw string("Cannot create service") + _serviceName + ": " + formatMessage(res);
+ throw "Cannot create service" + _serviceName + ": " + formatMessage(res);
}
//
@@ -273,7 +286,7 @@ IceServiceInstaller::install(const PropertiesPtr& properties)
DWORD res = GetLastError();
CloseServiceHandle(scm);
CloseServiceHandle(service);
- throw string("Cannot set description for service") + _serviceName + ": "
+ throw "Cannot set description for service" + _serviceName + ": "
+ formatMessage(res);
}
@@ -288,7 +301,7 @@ IceServiceInstaller::uninstall()
if(scm == 0)
{
DWORD res = GetLastError();
- throw string("Cannot open SCM: ") + formatMessage(res);
+ throw "Cannot open SCM: " + formatMessage(res);
}
SC_HANDLE service = OpenService(scm, _serviceName.c_str(), SERVICE_ALL_ACCESS);
@@ -296,7 +309,22 @@ IceServiceInstaller::uninstall()
{
DWORD res = GetLastError();
CloseServiceHandle(scm);
- throw string("Cannot open service") + _serviceName + ": " + formatMessage(res);
+ throw "Cannot open service '" + _serviceName + "': " + formatMessage(res);
+ }
+
+ //
+ // Stop service first
+ //
+ SERVICE_STATUS serviceStatus;
+ if(!ControlService(service, SERVICE_CONTROL_STOP, &serviceStatus))
+ {
+ DWORD res = GetLastError();
+ if(res != ERROR_SERVICE_NOT_ACTIVE)
+ {
+ CloseServiceHandle(scm);
+ CloseServiceHandle(service);
+ throw "Cannot stop service '" + _serviceName + "': " + formatMessage(res);
+ }
}
if(!DeleteService(service))
@@ -304,22 +332,28 @@ IceServiceInstaller::uninstall()
DWORD res = GetLastError();
CloseServiceHandle(scm);
CloseServiceHandle(service);
- throw string("Cannot delete service") + _serviceName + ": " + formatMessage(res);
+ throw "Cannot delete service '" + _serviceName + "': " + formatMessage(res);
}
CloseServiceHandle(scm);
CloseServiceHandle(service);
- removeEventLogKey(_serviceName);
+ string eventLogSource = _serviceProperties->getPropertyWithDefault("Ice.EventLog.Source", _serviceName);
+ string eventLog = removeSource(eventLogSource);
+
+ if(eventLog != "Application")
+ {
+ removeLog(eventLog);
+ }
}
/* static */ vector<string>
IceServiceInstaller::getPropertyNames()
{
static const string propertyNames[] = { "ImagePath", "DisplayName", "ObjectName", "Password",
- "Description", "DependOnRegistry", "Debug" };
+ "Description", "DependOnRegistry", "Debug", "AutoStart", "EventLog" };
- vector<string> result(propertyNames, propertyNames + 7);
+ vector<string> result(propertyNames, propertyNames + 9);
return result;
}
@@ -384,7 +418,7 @@ IceServiceInstaller::initializeSid(const string& name)
_sid = 0;
free(domainName);
- throw string("Could not retrieve Security ID for ") + name + ": "
+ throw "Could not retrieve Security ID for " + name + ": "
+ formatMessage(res);
}
}
@@ -418,7 +452,7 @@ IceServiceInstaller::initializeSid(const string& name)
&domainLen, &nameUse) == false)
{
DWORD res = GetLastError();
- throw string("Could not retrieve full account name for ") + name + ": "
+ throw "Could not retrieve full account name for " + name + ": "
+ formatMessage(res);
}
@@ -462,7 +496,7 @@ IceServiceInstaller::fileExists(const string& path) const
else
{
const char* msg = strerror(errno);
- throw string("Problem with ") + path + ": " + msg;
+ throw "Problem with " + path + ": " + msg;
}
}
}
@@ -481,7 +515,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
0, 0, &acl, 0, &sd);
if(res != ERROR_SUCCESS)
{
- throw string("Could not retrieve securify info for ") + path + ": "
+ throw "Could not retrieve securify info for " + path + ": "
+ formatMessage(res);
}
@@ -498,7 +532,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
if(res != ERROR_SUCCESS)
{
- throw string("Could not retrieve effective rights for ") + _sidName
+ throw "Could not retrieve effective rights for " + _sidName
+ " on " + path + ": " + formatMessage(res);
}
@@ -559,7 +593,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
res = SetEntriesInAcl(1, &ea, acl, &newAcl);
if(res != ERROR_SUCCESS)
{
- throw string("Could not modify ACL for ") + path + ": " + formatMessage(res);
+ throw "Could not modify ACL for " + path + ": " + formatMessage(res);
}
res = SetNamedSecurityInfo(const_cast<char*>(path.c_str()), type,
@@ -567,7 +601,7 @@ IceServiceInstaller::grantPermissions(const string& path, SE_OBJECT_TYPE type, b
0, 0, newAcl, 0);
if(res != ERROR_SUCCESS)
{
- throw string("Could not grant access to ") + _sidName
+ throw "Could not grant access to " + _sidName
+ " on " + path + ": " + formatMessage(res);
}
@@ -647,16 +681,55 @@ IceServiceInstaller::formatMessage(DWORD err) const
}
void
-IceServiceInstaller::addEventLogKey(const string& serviceName, const string& resourceFile) const
+IceServiceInstaller::addLog(const string& log) const
+{
+ //
+ // Create or open the corresponding registry key
+ //
+
+ HKEY key = 0;
+ DWORD disposition = 0;
+ LONG res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createLog(log).c_str(),
+ 0, "REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0,
+ &key, &disposition);
+
+ if(res != ERROR_SUCCESS)
+ {
+ throw "Could not create new Event Log '" + log + "': " + formatMessage(res);
+ }
+
+ res = RegCloseKey(key);
+ if(res != ERROR_SUCCESS)
+ {
+ throw "Could not close registry key handle: " + formatMessage(res);
+ }
+}
+
+void
+IceServiceInstaller::removeLog(const string& log) const
+{
+ LONG res = RegDeleteKey(HKEY_LOCAL_MACHINE, createLog(log).c_str());
+
+ //
+ // We get ERROR_ACCESS_DENIED when the log is shared by several sources
+ //
+ if(res != ERROR_SUCCESS && res != ERROR_ACCESS_DENIED)
+ {
+ throw "Could not remove registry key '" + createLog(log) + "': " + formatMessage(res);
+ }
+}
+
+void
+IceServiceInstaller::addSource(const string& source, const string& log, const string& resourceFile) const
{
HKEY key = 0;
DWORD disposition = 0;
- LONG res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createEventLogKey(serviceName).c_str(),
+ LONG res = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createSource(source, log).c_str(),
0, "REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0,
&key, &disposition);
if(res != ERROR_SUCCESS)
{
- throw "Could not create Event Log key in registry: " + formatMessage(res);
+ throw "Could not create Event Log source in registry: " + formatMessage(res);
}
//
@@ -693,22 +766,76 @@ IceServiceInstaller::addEventLogKey(const string& serviceName, const string& res
}
}
-void
-IceServiceInstaller::removeEventLogKey(const string& serviceName) const
+string
+IceServiceInstaller::removeSource(const string& source) const
{
- LONG res = RegDeleteKey(HKEY_LOCAL_MACHINE, createEventLogKey(serviceName).c_str());
+ //
+ // Find the source and return the log
+ //
+
+ HKEY key = 0;
+
+ LONG res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Services\\EventLog", 0,
+ KEY_ENUMERATE_SUB_KEYS, &key);
+
if(res != ERROR_SUCCESS)
{
- throw "Could not remove registry key: " + formatMessage(res);
+ throw "Could not open EventLog key: " + formatMessage(res);
+ }
+
+ DWORD index = 0;
+ do
+ {
+ char subkey[4096];
+ DWORD subkeySize = 4096;
+
+ res = RegEnumKeyEx(key, index, subkey, &subkeySize, 0, 0, 0, 0);
+
+ if(res == ERROR_SUCCESS)
+ {
+ //
+ // Check if we can delete the source sub-key
+ //
+ LONG delRes = RegDeleteKey(HKEY_LOCAL_MACHINE, createSource(source, subkey).c_str());
+ if(delRes == ERROR_SUCCESS)
+ {
+ res = RegCloseKey(key);
+ if(res != ERROR_SUCCESS)
+ {
+ throw "Could not close registry key handle: " + formatMessage(res);
+ }
+ return subkey;
+ }
+
+ ++index;
+ }
+ } while(res == ERROR_SUCCESS);
+
+
+ if(res == ERROR_NO_MORE_ITEMS)
+ {
+ RegCloseKey(key);
+ throw "Could not locate EventLog with source '" + source + "'";
+ }
+ else
+ {
+ RegCloseKey(key);
+ throw "Error while searching EventLog with source '" + source + "': " + formatMessage(res);
+ }
+
+ res = RegCloseKey(key);
+ if(res != ERROR_SUCCESS)
+ {
+ throw "Could not close registry key handle: " + formatMessage(res);
}
}
string
-IceServiceInstaller::mangleKey(const string& name) const
+IceServiceInstaller::mangleSource(const string& name) const
{
string result = name;
//
- // The service name cannot contain backslashes.
+ // The source cannot contain backslashes.
//
string::size_type pos = 0;
while((pos = result.find('\\', pos)) != string::npos)
@@ -719,14 +846,20 @@ IceServiceInstaller::mangleKey(const string& name) const
}
string
-IceServiceInstaller::createEventLogKey(const string& name) const
+IceServiceInstaller::createLog(const string& log) const
{
//
// The registry key is:
//
- // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application.
+ // HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\<log>.
//
- return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleKey(name);
+ return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\" + log;
+}
+
+string
+IceServiceInstaller::createSource(const string& name, const string& log) const
+{
+ return createLog(log) + "\\" + mangleSource(name);
}
string
@@ -769,7 +902,7 @@ IceServiceInstaller::getIceDLLPath(const string& imagePath) const
}
else
{
- throw string("Could not find Ice DLL");
+ throw "Could not find Ice DLL";
}
}
}
diff --git a/cpp/src/iceserviceinstall/ServiceInstaller.h b/cpp/src/iceserviceinstall/ServiceInstaller.h
index ef35cca4b4d..88c3edea2d7 100755
--- a/cpp/src/iceserviceinstall/ServiceInstaller.h
+++ b/cpp/src/iceserviceinstall/ServiceInstaller.h
@@ -24,10 +24,19 @@ class ICE_SERVICE_INSTALLER_API IceServiceInstaller
{
public:
+#if defined(_MSC_VER) && _MSC_VER < 1300
+ enum {
+ icegridregistry = 0,
+ icegridnode = 1,
+ glacier2router = 2,
+ serviceCount = 3
+ };
+#else
static const int icegridregistry = 0;
static const int icegridnode = 1;
static const int glacier2router = 2;
static const int serviceCount = 3;
+#endif
IceServiceInstaller(int, const std::string&, const Ice::CommunicatorPtr&);
~IceServiceInstaller();
@@ -50,10 +59,14 @@ private:
bool mkdir(const std::string&) const;
std::string formatMessage(DWORD) const;
- void addEventLogKey(const std::string&, const std::string&) const;
- void removeEventLogKey(const std::string&) const;
- std::string mangleKey(const std::string&) const;
- std::string createEventLogKey(const std::string&) const;
+ void addLog(const std::string&) const;
+ void removeLog(const std::string&) const;
+ std::string createLog(const std::string&) const;
+ void addSource(const std::string&, const std::string&, const std::string&) const;
+ std::string removeSource(const std::string&) const;
+ std::string mangleSource(const std::string&) const;
+ std::string createSource(const std::string&, const std::string&) const;
+
std::string getIceDLLPath(const std::string&) const;
int _serviceType;
diff --git a/cs/src/Ice/PropertyNames.cs b/cs/src/Ice/PropertyNames.cs
index 82034c35cad..28ddcbbb220 100644
--- a/cs/src/Ice/PropertyNames.cs
+++ b/cs/src/Ice/PropertyNames.cs
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Fri Oct 12 15:45:46 2007
+// Generated by makeprops.py from file ..\config\PropertyNames.xml, Mon Oct 29 16:59:13 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -68,6 +68,7 @@ namespace IceInternal
new Property(@"^Ice\.Default\.Router\.CollocationOptimized$", false, null),
new Property(@"^Ice\.Default\.Router\.ThreadPerConnection$", false, null),
new Property(@"^Ice\.Default\.Router$", false, null),
+ new Property(@"^Ice\.EventLog\.Source$", false, null),
new Property(@"^Ice\.GC\.Interval$", false, null),
new Property(@"^Ice\.ImplicitContext$", false, null),
new Property(@"^Ice\.InitPlugins$", false, null),
diff --git a/java/src/IceInternal/PropertyNames.java b/java/src/IceInternal/PropertyNames.java
index 50a288ac18e..1476d65929d 100644
--- a/java/src/IceInternal/PropertyNames.java
+++ b/java/src/IceInternal/PropertyNames.java
@@ -7,7 +7,7 @@
//
// **********************************************************************
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Fri Oct 12 15:45:46 2007
+// Generated by makeprops.py from file ..\config\PropertyNames.xml, Mon Oct 29 16:59:13 2007
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -68,6 +68,7 @@ public final class PropertyNames
new Property("Ice\\.Default\\.Router\\.CollocationOptimized", false, null),
new Property("Ice\\.Default\\.Router\\.ThreadPerConnection", false, null),
new Property("Ice\\.Default\\.Router", false, null),
+ new Property("Ice\\.EventLog\\.Source", false, null),
new Property("Ice\\.GC\\.Interval", false, null),
new Property("Ice\\.ImplicitContext", false, null),
new Property("Ice\\.InitPlugins", false, null),