summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/FreezeScript/Functions.cpp4
-rw-r--r--cpp/src/FreezeScript/Scanner.l6
-rw-r--r--cpp/src/FreezeScript/TransformVisitor.cpp2
-rw-r--r--cpp/src/Glacier2/ProxyVerifier.cpp4
-rw-r--r--cpp/src/Ice/Instance.cpp31
-rw-r--r--cpp/src/Ice/Instance.h3
-rw-r--r--cpp/src/Ice/Makefile1
-rw-r--r--cpp/src/Ice/Makefile.mak1
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp24
-rw-r--r--cpp/src/Ice/ProxyFactory.cpp59
-rw-r--r--cpp/src/Ice/RetryQueue.cpp92
-rw-r--r--cpp/src/Ice/RetryQueue.h62
-rw-r--r--cpp/src/Ice/RetryQueueF.h24
-rw-r--r--cpp/src/Ice/StreamI.cpp9
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp1
-rw-r--r--cpp/src/IceBox/Makefile.mak6
-rw-r--r--cpp/src/IceGrid/Activator.cpp13
-rw-r--r--cpp/src/IceGrid/Activator.h1
-rw-r--r--cpp/src/IceGrid/Internal.ice3
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp316
-rw-r--r--cpp/src/IceGrid/LocatorI.h19
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp18
-rw-r--r--cpp/src/IceGrid/NodeI.cpp46
-rw-r--r--cpp/src/IceGrid/NodeI.h2
-rw-r--r--cpp/src/IceGrid/Scanner.l2
-rw-r--r--cpp/src/IceGrid/ServerI.cpp20
-rw-r--r--cpp/src/IcePatch2/Calc.cpp7
-rw-r--r--cpp/src/IcePatch2/Client.cpp3
-rw-r--r--cpp/src/IcePatch2/Util.cpp9
-rw-r--r--cpp/src/IceSSL/Instance.cpp6
-rw-r--r--cpp/src/IceSSL/RFC2253.cpp13
-rw-r--r--cpp/src/IceStorm/Makefile.mak9
-rw-r--r--cpp/src/IceStorm/Scanner.l2
-rw-r--r--cpp/src/IceStorm/Service.cpp4
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp2
-rw-r--r--cpp/src/IceUtil/InputUtil.cpp6
-rw-r--r--cpp/src/IceUtil/Options.cpp13
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp38
-rw-r--r--cpp/src/Slice/CPlusPlusUtil.cpp2
-rw-r--r--cpp/src/Slice/CsUtil.cpp2
-rw-r--r--cpp/src/Slice/DotNetNames.cpp2
-rw-r--r--cpp/src/Slice/Parser.cpp87
-rw-r--r--cpp/src/Slice/Preprocessor.cpp6
-rw-r--r--cpp/src/Slice/Scanner.l6
-rw-r--r--cpp/src/slice2cs/Gen.cpp2
-rw-r--r--cpp/src/slice2docbook/Gen.cpp2
-rw-r--r--cpp/src/slice2docbook/Main.cpp4
-rw-r--r--cpp/src/slice2freeze/Main.cpp18
-rw-r--r--cpp/src/slice2freezej/Main.cpp12
-rw-r--r--cpp/src/slice2html/Gen.cpp2
-rw-r--r--cpp/src/slice2java/Gen.cpp4
51 files changed, 634 insertions, 396 deletions
diff --git a/cpp/src/FreezeScript/Functions.cpp b/cpp/src/FreezeScript/Functions.cpp
index fe5a3192d77..69a7ab8ae46 100644
--- a/cpp/src/FreezeScript/Functions.cpp
+++ b/cpp/src/FreezeScript/Functions.cpp
@@ -10,6 +10,7 @@
#include <FreezeScript/Functions.h>
#include <FreezeScript/Util.h>
#include <IceUtil/UUID.h>
+#include <IceUtil/StringUtil.h>
using namespace std;
@@ -177,8 +178,7 @@ FreezeScript::invokeGlobalFunction(const Ice::CommunicatorPtr& communicator, con
{
errorReporter->error("lowercase() requires a string argument");
}
- string val = str->stringValue();
- transform(val.begin(), val.end(), val.begin(), ::tolower);
+ string val = IceUtilInternal::toLower(str->stringValue());
result = factory->createString(val, false);
return true;
}
diff --git a/cpp/src/FreezeScript/Scanner.l b/cpp/src/FreezeScript/Scanner.l
index 972a147dbfd..31a4586c789 100644
--- a/cpp/src/FreezeScript/Scanner.l
+++ b/cpp/src/FreezeScript/Scanner.l
@@ -330,14 +330,14 @@ parseString(char start)
case 'x':
{
IceUtil::Int64 ull = 0;
- while(isxdigit(next = static_cast<char>(yyinput())))
+ while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput()))))
{
ull *= 16;
- if(isdigit(next))
+ if(isdigit(static_cast<unsigned char>(next)))
{
ull += next - '0';
}
- else if(islower(next))
+ else if(islower(static_cast<unsigned char>(next)))
{
ull += next - 'a' + 10;
}
diff --git a/cpp/src/FreezeScript/TransformVisitor.cpp b/cpp/src/FreezeScript/TransformVisitor.cpp
index 7b7e41197ed..c62db545f27 100644
--- a/cpp/src/FreezeScript/TransformVisitor.cpp
+++ b/cpp/src/FreezeScript/TransformVisitor.cpp
@@ -123,7 +123,7 @@ FreezeScript::TransformVisitor::visitDouble(const DoubleDataPtr& dest)
{
while(*end)
{
- if(!isspace(*end))
+ if(!isspace(static_cast<unsigned char>(*end)))
{
conversionError(type, _src->getType(), str);
return;
diff --git a/cpp/src/Glacier2/ProxyVerifier.cpp b/cpp/src/Glacier2/ProxyVerifier.cpp
index 71a7f475472..5724ddfe902 100644
--- a/cpp/src/Glacier2/ProxyVerifier.cpp
+++ b/cpp/src/Glacier2/ProxyVerifier.cpp
@@ -707,8 +707,8 @@ parseProperty(const Ice::CommunicatorPtr& communicator, const string& property,
// TODO: assuming that there is no leading or trailing whitespace. This
// should probably be confirmed.
//
- assert(!isspace(parameter[current]));
- assert(!isspace(addr[addr.size() -1]));
+ assert(!isspace(static_cast<unsigned char>(parameter[current])));
+ assert(!isspace(static_cast<unsigned char>(addr[addr.size() -1])));
if(current != 0)
{
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 8a1e5f45405..315eaeba8c5 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -29,6 +29,7 @@
#include <Ice/LoggerI.h>
#include <Ice/Network.h>
#include <Ice/EndpointFactoryManager.h>
+#include <Ice/RetryQueue.h>
#include <Ice/TcpEndpointI.h>
#include <Ice/UdpEndpointI.h>
#include <Ice/DynamicLibrary.h>
@@ -285,6 +286,19 @@ IceInternal::Instance::endpointHostResolver()
return _endpointHostResolver;
}
+RetryQueuePtr
+IceInternal::Instance::retryQueue()
+{
+ IceUtil::RecMutex::Lock sync(*this);
+
+ if(_state == StateDestroyed)
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+
+ return _retryQueue;
+}
+
IceUtil::TimerPtr
IceInternal::Instance::timer()
{
@@ -991,6 +1005,8 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_servantFactoryManager = new ObjectFactoryManager();
_objectAdapterFactory = new ObjectAdapterFactory(this, communicator);
+
+ _retryQueue = new RetryQueue(this);
if(_initData.wstringConverter == 0)
{
@@ -1039,6 +1055,7 @@ IceInternal::Instance::~Instance()
assert(!_serverThreadPool);
assert(!_selectorThread);
assert(!_endpointHostResolver);
+ assert(!_retryQueue);
assert(!_timer);
assert(!_routerManager);
assert(!_locatorManager);
@@ -1129,7 +1146,9 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
}
//
- // Start connection monitor if necessary.
+ // Start connection monitor if necessary. Set the check interval to
+ // 1/10 of the ACM timeout with a minmal value of 1 second and a
+ // maximum value of 5 minutes.
//
Int interval = 0;
if(_clientACM > 0 && _serverACM > 0)
@@ -1144,6 +1163,10 @@ IceInternal::Instance::finishSetup(int& argc, char* argv[])
{
interval = _serverACM;
}
+ if(interval > 0)
+ {
+ interval = min(300, max(1, (int)interval / 10));
+ }
interval = _initData.properties->getPropertyAsIntWithDefault("Ice.MonitorConnections", interval);
if(interval > 0)
{
@@ -1200,6 +1223,11 @@ IceInternal::Instance::destroy()
_outgoingConnectionFactory->waitUntilFinished();
}
+ if(_retryQueue)
+ {
+ _retryQueue->destroy();
+ }
+
ThreadPoolPtr serverThreadPool;
ThreadPoolPtr clientThreadPool;
SelectorThreadPtr selectorThread;
@@ -1210,6 +1238,7 @@ IceInternal::Instance::destroy()
_objectAdapterFactory = 0;
_outgoingConnectionFactory = 0;
+ _retryQueue = 0;
if(_connectionMonitor)
{
diff --git a/cpp/src/Ice/Instance.h b/cpp/src/Ice/Instance.h
index f0aa50a80b8..721b347b238 100644
--- a/cpp/src/Ice/Instance.h
+++ b/cpp/src/Ice/Instance.h
@@ -30,6 +30,7 @@
#include <Ice/ObjectFactoryManagerF.h>
#include <Ice/ObjectAdapterFactoryF.h>
#include <Ice/EndpointFactoryManagerF.h>
+#include <Ice/RetryQueueF.h>
#include <Ice/DynamicLibraryF.h>
#include <Ice/PluginF.h>
#include <Ice/Initialize.h>
@@ -71,6 +72,7 @@ public:
ThreadPoolPtr serverThreadPool();
SelectorThreadPtr selectorThread();
EndpointHostResolverPtr endpointHostResolver();
+ RetryQueuePtr retryQueue();
IceUtil::TimerPtr timer();
EndpointFactoryManagerPtr endpointFactoryManager() const;
DynamicLibraryListPtr dynamicLibraryList() const;
@@ -134,6 +136,7 @@ private:
ThreadPoolPtr _serverThreadPool;
SelectorThreadPtr _selectorThread;
EndpointHostResolverPtr _endpointHostResolver;
+ RetryQueuePtr _retryQueue;
IceUtil::TimerPtr _timer;
EndpointFactoryManagerPtr _endpointFactoryManager;
DynamicLibraryListPtr _dynamicLibraryList;
diff --git a/cpp/src/Ice/Makefile b/cpp/src/Ice/Makefile
index f0bdb7fff21..6947f7f3b6d 100644
--- a/cpp/src/Ice/Makefile
+++ b/cpp/src/Ice/Makefile
@@ -80,6 +80,7 @@ OBJS = Acceptor.o \
Proxy.o \
ReferenceFactory.o \
Reference.o \
+ RetryQueue.o \
RequestHandler.o \
RouterInfo.o \
Router.o \
diff --git a/cpp/src/Ice/Makefile.mak b/cpp/src/Ice/Makefile.mak
index 9b759ae8038..338e86890dc 100644
--- a/cpp/src/Ice/Makefile.mak
+++ b/cpp/src/Ice/Makefile.mak
@@ -81,6 +81,7 @@ OBJS = Acceptor.obj \
Proxy.obj \
ReferenceFactory.obj \
Reference.obj \
+ RetryQueue.obj \
RequestHandler.obj \
RouterInfo.obj \
Router.obj \
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index 788cb2cb373..3ef1a299197 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -24,6 +24,7 @@
#include <Ice/ReplyStatus.h>
#include <Ice/ImplicitContextI.h>
#include <Ice/ThreadPool.h>
+#include <Ice/RetryQueue.h>
using namespace std;
using namespace Ice;
@@ -454,6 +455,24 @@ IceInternal::OutgoingAsync::__finished(const LocalExceptionWrapper& exc)
}
}
+void
+IceInternal::OutgoingAsync::__retry(int interval)
+{
+ //
+ // This method is called by the proxy to retry an invocation, no
+ // other threads can access this object.
+ //
+ if(interval > 0)
+ {
+ assert(__os);
+ __os->instance()->retryQueue()->add(this, interval);
+ }
+ else
+ {
+ __send();
+ }
+}
+
bool
IceInternal::OutgoingAsync::__send()
{
@@ -466,11 +485,11 @@ IceInternal::OutgoingAsync::__send()
}
catch(const LocalExceptionWrapper& ex)
{
- handleException(ex);
+ handleException(ex); // Might call __send() again upon retry and assign _sentSynchronously
}
catch(const Ice::LocalException& ex)
{
- handleException(ex);
+ handleException(ex); // Might call __send() again upon retry and assign _sentSynchronously
}
return _sentSynchronously;
}
@@ -483,6 +502,7 @@ IceInternal::OutgoingAsync::__prepare(const ObjectPrx& prx, const string& operat
_delegate = 0;
_cnt = 0;
_mode = mode;
+ _sentSynchronously = false;
//
// Can't call async via a batch proxy.
diff --git a/cpp/src/Ice/ProxyFactory.cpp b/cpp/src/Ice/ProxyFactory.cpp
index 2fc5316eb6d..eeb554d3e4a 100644
--- a/cpp/src/Ice/ProxyFactory.cpp
+++ b/cpp/src/Ice/ProxyFactory.cpp
@@ -25,32 +25,8 @@ using namespace std;
using namespace Ice;
using namespace IceInternal;
-namespace
-{
-
-class RetryTask : public IceUtil::TimerTask
-{
-public:
-
- RetryTask(const OutgoingAsyncPtr& out) : _out(out)
- {
- }
-
- virtual void
- runTimerTask()
- {
- _out->__send();
- }
-
-private:
-
- const OutgoingAsyncPtr _out;
-};
-
-}
-
IceUtil::Shared* IceInternal::upCast(ProxyFactory* p) { return p; }
-
+
ObjectPrx
IceInternal::ProxyFactory::stringToProxy(const string& str) const
{
@@ -243,34 +219,17 @@ IceInternal::ProxyFactory::checkRetryAfterException(const LocalException& ex,
}
out << " because of exception\n" << ex;
}
-
- if(interval > 0)
+
+ if(out)
{
- if(out)
- {
- try
- {
- _instance->timer()->schedule(new RetryTask(out), IceUtil::Time::milliSeconds(interval));
- }
- catch(const IceUtil::IllegalArgumentException&) // Expected if the communicator destroyed the timer.
- {
- throw CommunicatorDestroyedException(__FILE__, __LINE__);
- }
- }
- else
- {
- //
- // Sleep before retrying.
- //
- IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
- }
+ out->__retry(interval);
}
- else
+ else if(interval > 0)
{
- if(out)
- {
- out->__send();
- }
+ //
+ // Sleep before retrying.
+ //
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(interval));
}
}
diff --git a/cpp/src/Ice/RetryQueue.cpp b/cpp/src/Ice/RetryQueue.cpp
new file mode 100644
index 00000000000..d6aba62f844
--- /dev/null
+++ b/cpp/src/Ice/RetryQueue.cpp
@@ -0,0 +1,92 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#include <Ice/RetryQueue.h>
+#include <Ice/OutgoingAsync.h>
+#include <Ice/LocalException.h>
+#include <Ice/Instance.h>
+
+using namespace std;
+using namespace Ice;
+using namespace IceInternal;
+
+IceUtil::Shared* IceInternal::upCast(RetryQueue* p) { return p; }
+
+IceInternal::RetryTask::RetryTask(const RetryQueuePtr& queue, const OutgoingAsyncPtr& outAsync) :
+ _queue(queue), _outAsync(outAsync)
+{
+}
+
+void
+IceInternal::RetryTask::runTimerTask()
+{
+ if(_queue->remove(this))
+ {
+ try
+ {
+ _outAsync->__send();
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ _outAsync->__releaseCallback(ex);
+ }
+ }
+}
+
+void
+IceInternal::RetryTask::destroy()
+{
+ _outAsync->__releaseCallback(CommunicatorDestroyedException(__FILE__, __LINE__));
+}
+
+bool
+IceInternal::RetryTask::operator<(const RetryTask& rhs) const
+{
+ return this < &rhs;
+}
+
+IceInternal::RetryQueue::RetryQueue(const InstancePtr& instance) : _instance(instance)
+{
+}
+
+void
+IceInternal::RetryQueue::add(const OutgoingAsyncPtr& out, int interval)
+{
+ Lock sync(*this);
+ RetryTaskPtr task = new RetryTask(this, out);
+ try
+ {
+ _instance->timer()->schedule(task, IceUtil::Time::milliSeconds(interval));
+ }
+ catch(const IceUtil::IllegalArgumentException&) // Expected if the communicator destroyed the timer.
+ {
+ throw CommunicatorDestroyedException(__FILE__, __LINE__);
+ }
+ _requests.insert(task);
+}
+
+void
+IceInternal::RetryQueue::destroy()
+{
+ Lock sync(*this);
+ for(set<RetryTaskPtr>::const_iterator p = _requests.begin(); p != _requests.end(); ++p)
+ {
+ _instance->timer()->cancel(*p);
+ (*p)->destroy();
+ }
+ _requests.clear();
+}
+
+bool
+IceInternal::RetryQueue::remove(const RetryTaskPtr& task)
+{
+ Lock sync(*this);
+ return _requests.erase(task) > 0;
+}
+
diff --git a/cpp/src/Ice/RetryQueue.h b/cpp/src/Ice/RetryQueue.h
new file mode 100644
index 00000000000..960b4a8d220
--- /dev/null
+++ b/cpp/src/Ice/RetryQueue.h
@@ -0,0 +1,62 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_RETRY_QUEUE_H
+#define ICE_RETRY_QUEUE_H
+
+#include <IceUtil/Shared.h>
+#include <IceUtil/Mutex.h>
+#include <IceUtil/Timer.h>
+#include <Ice/RetryQueueF.h>
+#include <Ice/OutgoingAsyncF.h>
+#include <Ice/InstanceF.h>
+
+namespace IceInternal
+{
+
+class RetryTask : public IceUtil::TimerTask
+{
+public:
+
+ RetryTask(const RetryQueuePtr&, const OutgoingAsyncPtr&);
+
+ virtual void runTimerTask();
+ void destroy();
+
+ bool operator<(const RetryTask&) const;
+
+private:
+
+ const RetryQueuePtr _queue;
+ const OutgoingAsyncPtr _outAsync;
+};
+typedef IceUtil::Handle<RetryTask> RetryTaskPtr;
+
+class RetryQueue : public IceUtil::Shared, public IceUtil::Mutex
+{
+public:
+
+ RetryQueue(const InstancePtr&);
+
+ void add(const OutgoingAsyncPtr&, int);
+ void destroy();
+
+private:
+
+ bool remove(const RetryTaskPtr&);
+ friend class RetryTask;
+
+ const InstancePtr _instance;
+ std::set<RetryTaskPtr> _requests;
+};
+
+}
+
+#endif
+
diff --git a/cpp/src/Ice/RetryQueueF.h b/cpp/src/Ice/RetryQueueF.h
new file mode 100644
index 00000000000..0e99fd7e881
--- /dev/null
+++ b/cpp/src/Ice/RetryQueueF.h
@@ -0,0 +1,24 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+#ifndef ICE_RETRY_QUEUE_F_H
+#define ICE_RETRY_QUEUE_F_H
+
+#include <Ice/Handle.h>
+
+namespace IceInternal
+{
+
+class RetryQueue;
+IceUtil::Shared* upCast(RetryQueue*);
+typedef Handle<RetryQueue> RetryQueuePtr;
+
+}
+
+#endif
diff --git a/cpp/src/Ice/StreamI.cpp b/cpp/src/Ice/StreamI.cpp
index 26ecc8acb19..9a6d4cfca04 100644
--- a/cpp/src/Ice/StreamI.cpp
+++ b/cpp/src/Ice/StreamI.cpp
@@ -698,7 +698,14 @@ Ice::UserExceptionWriter::~UserExceptionWriter() throw()
void
Ice::UserExceptionWriter::__write(BasicStream* os) const
{
- OutputStreamPtr stream = new OutputStreamI(_communicator, os);
+ OutputStreamI* stream = reinterpret_cast<OutputStreamI*>(os->closure());
+ if(!stream)
+ {
+ //
+ // Required for IcePy usage
+ //
+ stream = new OutputStreamI(_communicator, os);
+ }
write(stream);
}
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index e535a6c23af..04446c0daaf 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -282,6 +282,7 @@ IceInternal::UdpEndpointI::UdpEndpointI(const InstancePtr& instance, const strin
{
EndpointParseException ex(__FILE__, __LINE__);
ex.str = "udp " + str;
+ throw ex;
}
}
diff --git a/cpp/src/IceBox/Makefile.mak b/cpp/src/IceBox/Makefile.mak
index bfb33891aac..8b2262b8405 100644
--- a/cpp/src/IceBox/Makefile.mak
+++ b/cpp/src/IceBox/Makefile.mak
@@ -15,11 +15,7 @@ DLLNAME = $(top_srcdir)\bin\icebox$(SOVERSION)$(LIBSUFFIX).dll
SERVER_D = $(top_srcdir)\bin\iceboxd.exe
SERVER_R = $(top_srcdir)\bin\icebox.exe
-!if "$(OPTIMIZE)" != "yes"
-SERVER = $(SERVER_D)
-!else
-SERVER = $(SERVER_R)
-!endif
+SERVER = $(top_srcdir)\bin\icebox$(LIBSUFFIX).exe
ADMIN = $(top_srcdir)\bin\iceboxadmin.exe
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index d585a11eb15..1075348e348 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -514,8 +514,7 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = IceUtilInternal::toUpper(s.substr(0, pos));
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
var += s.size();
@@ -528,8 +527,7 @@ Activator::activate(const string& name,
string::size_type pos = s.find('=');
if(pos != string::npos)
{
- string key = s.substr(0, pos);
- std::transform(key.begin(), key.end(), key.begin(), toupper);
+ string key = IceUtilInternal::toUpper(s.substr(0, pos));
envMap.erase(key);
envMap.insert(map<string, string>::value_type(key, s.substr(pos + 1)));
}
@@ -1005,6 +1003,13 @@ Activator::destroy()
assert(_processes.empty());
}
+bool
+Activator::isActive()
+{
+ IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
+ return !_deactivating;
+}
+
void
Activator::runTerminationListener()
{
diff --git a/cpp/src/IceGrid/Activator.h b/cpp/src/IceGrid/Activator.h
index 37cd27f10d4..b5be8fd62e1 100644
--- a/cpp/src/IceGrid/Activator.h
+++ b/cpp/src/IceGrid/Activator.h
@@ -51,6 +51,7 @@ public:
virtual void shutdown();
virtual void destroy();
+ bool isActive();
void sendSignal(const std::string&, int);
void runTerminationListener();
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index 48419c3f531..ef3d4ab8725 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -69,6 +69,9 @@ class InternalServerDescriptor
/** The application revision. */
int revision;
+ /** The Ice version. */
+ int iceVersion;
+
/** The id of the session which allocated the server. */
string sessionId;
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index 3fbe3a146f1..d8162b85709 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -26,67 +26,51 @@ class AMI_Adapter_getDirectProxyI : public AMI_Adapter_getDirectProxy
{
public:
- AMI_Adapter_getDirectProxyI(const LocatorI::RequestPtr& request, const string& id) :
- _request(request), _id(id)
+ AMI_Adapter_getDirectProxyI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
+ _locator(locator), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
assert(obj);
- _request->response(_id, obj);
+ _locator->getDirectProxyResponse(_adapter, obj);
}
virtual void ice_exception(const ::Ice::Exception& e)
{
- try
- {
- e.ice_throw();
- }
- catch(const AdapterNotActiveException& ex)
- {
- if(ex.activatable)
- {
- _request->activate(_id);
- return;
- }
- }
- catch(const Ice::Exception&)
- {
- }
-
- _request->exception(_id, e);
+ _locator->getDirectProxyException(_adapter, e);
}
private:
- const LocatorI::RequestPtr _request;
- const string _id;
+ const LocatorIPtr _locator;
+ const LocatorAdapterInfo _adapter;
};
class AMI_Adapter_activateI : public AMI_Adapter_activate
{
public:
- AMI_Adapter_activateI(const LocatorIPtr& locator, const string& id) :
- _locator(locator), _id(id)
+ AMI_Adapter_activateI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
+ _locator(locator), _adapter(adapter)
{
}
virtual void ice_response(const ::Ice::ObjectPrx& obj)
{
- _locator->activateFinished(_id, obj);
+ _locator->getDirectProxyResponse(_adapter, obj);
}
virtual void ice_exception(const ::Ice::Exception& ex)
{
- _locator->activateException(_id, ex);
+ _locator->getDirectProxyException(_adapter, ex);
}
private:
const LocatorIPtr _locator;
- const string _id;
+ const LocatorAdapterInfo _adapter;
};
//
@@ -223,50 +207,35 @@ LocatorI::Request::execute()
for(LocatorAdapterInfoSeq::const_iterator p = adapters.begin(); p != adapters.end(); ++p)
{
- p->proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, p->id));
+ if(_locator->getDirectProxy(*p, this))
+ {
+ activating();
+ }
}
}
void
-LocatorI::Request::activate(const string& id)
+LocatorI::Request::activating()
{
//
- // Activate the adapter
- //
- // NOTE: we use a timeout large enough to ensure that the activate() call won't
- // timeout if the server hangs in deactivation and/or activation.
- //
- {
- Lock sync(*this);
- for(LocatorAdapterInfoSeq::const_iterator p = _adapters.begin(); p != _adapters.end(); ++p)
- {
- if(p->id == id)
- {
- _locator->activate(*p, this);
- _activating.insert(id);
- }
- }
- }
-
- //
- // If this is a request for a replica group, don't wait for the activation to
- // complete. Instead, we query the next adapter which might be already active.
+ // An adapter is being activated. If this is a request for a replica group, don't
+ // wait for the activation to complete. Instead, we query the next adapter which
+ // might be already active.
//
if(_replicaGroup)
{
LocatorAdapterInfo adapter;
+ do
{
Lock sync(*this);
- if(_lastAdapter != _adapters.end())
+ if(_lastAdapter == _adapters.end())
{
- adapter = *_lastAdapter;
- ++_lastAdapter;
+ break;
}
+ adapter = *_lastAdapter;
+ ++_lastAdapter;
}
- if(adapter.proxy)
- {
- adapter.proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, adapter.id));
- }
+ while(_locator->getDirectProxy(adapter, this));
}
}
@@ -276,13 +245,15 @@ LocatorI::Request::exception(const string& id, const Ice::Exception& ex)
LocatorAdapterInfo adapter;
{
Lock sync(*this);
+ if(_proxies.size() == _count) // Nothing to do if we already sent the response.
+ {
+ return;
+ }
if(!_exception.get())
{
_exception.reset(ex.ice_clone());
}
- _activating.erase(id);
-
if(_lastAdapter == _adapters.end())
{
--_count; // Expect one less adapter proxy if there's no more adapters to query.
@@ -305,7 +276,10 @@ LocatorI::Request::exception(const string& id, const Ice::Exception& ex)
if(adapter.proxy)
{
- adapter.proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, adapter.id));
+ if(_locator->getDirectProxy(adapter, this))
+ {
+ activating();
+ }
}
}
@@ -319,10 +293,11 @@ LocatorI::Request::response(const string& id, const Ice::ObjectPrx& proxy)
}
Lock sync(*this);
- assert(proxy);
-
- _activating.erase(id);
-
+ if(_proxies.size() == _count) // Nothing to do if we already sent the response.
+ {
+ return;
+ }
+
_proxies[id] = proxy->ice_identity(_locator->getCommunicator()->stringToIdentity("dummy"));
//
@@ -397,18 +372,13 @@ LocatorI::Request::sendResponse()
}
}
- for(set<string>::const_iterator q = _activating.begin(); q != _activating.end(); ++q)
- {
- _locator->cancelActivate(*q, this);
- }
-
Ice::ObjectPrx proxy = _locator->getCommunicator()->stringToProxy("dummy:default");
_amdCB->ice_response(proxy->ice_endpoints(endpoints));
}
if(_roundRobin)
{
- _locator->removePendingResolve(_id, roundRobinCount);
+ _locator->removePendingRoundRobinRequest(_id, roundRobinCount);
}
}
@@ -474,7 +444,9 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
const Ice::Current&) const
{
LocatorIPtr self = const_cast<LocatorI*>(this);
- if(self->addPendingResolve(id, cb))
+ bool pending = false;
+ if(self->addPendingRoundRobinRequest(id, cb, true, pending)) // Add only if there's already round robin requests
+ // pending.
{
//
// Another request is currently resolving the adapter endpoints. We'll
@@ -508,9 +480,16 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
// adapters, and replica groups, there's no need to serialize
// the requests.
//
- if(!roundRobin)
+ if(roundRobin)
{
- self->removePendingResolve(id, 0);
+ if(self->addPendingRoundRobinRequest(id, cb, false, pending))
+ {
+ return;
+ }
+ }
+ else if(pending)
+ {
+ self->removePendingRoundRobinRequest(id, 0);
}
RequestPtr request = new Request(cb, self, id, replicaGroup, roundRobin, adapters, count);
@@ -518,6 +497,11 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
}
catch(const AdapterNotExistException&)
{
+ if(pending)
+ {
+ self->removePendingRoundRobinRequest(id, 0);
+ }
+
try
{
cb->ice_response(_database->getAdapterDirectProxy(id));
@@ -526,11 +510,15 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
{
cb->ice_exception(Ice::AdapterNotFoundException());
}
- self->removePendingResolve(id, 0);
return;
}
catch(const Ice::Exception& ex)
{
+ if(pending)
+ {
+ self->removePendingRoundRobinRequest(id, 0);
+ }
+
const TraceLevelsPtr traceLevels = _database->getTraceLevels();
if(traceLevels->locator > 0)
{
@@ -545,7 +533,6 @@ LocatorI::findAdapterById_async(const Ice::AMD_Locator_findAdapterByIdPtr& cb,
}
}
cb->ice_response(0);
- self->removePendingResolve(id, 0);
return;
}
}
@@ -580,91 +567,26 @@ LocatorI::getTraceLevels() const
return _database->getTraceLevels();
}
-void
-LocatorI::activate(const LocatorAdapterInfo& adapter, const RequestPtr& request)
-{
- {
- Lock sync(*this);
-
- //
- // Check if there's already pending requests for this adapter. If that's the case,
- // we just add this one to the queue. If not, we add it to the queue and initiate
- // a call on the adapter to get its direct proxy.
- //
- PendingRequestsMap::iterator p = _pendingRequests.find(adapter.id);
- if(p != _pendingRequests.end())
- {
- p->second.insert(request);
- return;
- }
-
- p = _pendingRequests.insert(make_pair(adapter.id, PendingRequests())).first;
- p->second.insert(request);
- }
-
- AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, adapter.id);
- int timeout = adapter.activationTimeout + adapter.deactivationTimeout;
- AdapterPrx::uncheckedCast(adapter.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
-}
-
-void
-LocatorI::cancelActivate(const string& id, const RequestPtr& request)
-{
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(id);
- if(p != _pendingRequests.end())
- {
- p->second.erase(request);
- }
-}
-
-void
-LocatorI::activateFinished(const string& id, const Ice::ObjectPrx& proxy)
-{
- PendingRequests requests;
- {
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(id);
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
- }
-
- for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->response(id, proxy);
- }
-}
-
-void
-LocatorI::activateException(const string& id, const Ice::Exception& ex)
-{
- PendingRequests requests;
- {
- Lock sync(*this);
- PendingRequestsMap::iterator p = _pendingRequests.find(id);
- assert(p != _pendingRequests.end());
- requests.swap(p->second);
- _pendingRequests.erase(p);
- }
-
- for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
- {
- (*q)->exception(id, ex);
- }
-}
-
bool
-LocatorI::addPendingResolve(const string& adapterId, const Ice::AMD_Locator_findAdapterByIdPtr& cb)
+LocatorI::addPendingRoundRobinRequest(const string& adapterId,
+ const Ice::AMD_Locator_findAdapterByIdPtr& cb,
+ bool addIfExists,
+ bool& pending)
{
Lock sync(*this);
+ pending = false;
map<string, deque<Ice::AMD_Locator_findAdapterByIdPtr> >::iterator p = _resolves.find(adapterId);
if(p == _resolves.end())
{
+ if(addIfExists)
+ {
+ return false;
+ }
p = _resolves.insert(make_pair(adapterId, deque<Ice::AMD_Locator_findAdapterByIdPtr>())).first;
}
else if(p->second.front().get() == cb.get())
{
+ pending = true;
return false;
}
@@ -673,7 +595,7 @@ LocatorI::addPendingResolve(const string& adapterId, const Ice::AMD_Locator_find
}
void
-LocatorI::removePendingResolve(const string& adapterId, int roundRobinCount)
+LocatorI::removePendingRoundRobinRequest(const string& adapterId, int roundRobinCount)
{
Ice::AMD_Locator_findAdapterByIdPtr cb;
{
@@ -716,3 +638,97 @@ LocatorI::removePendingResolve(const string& adapterId, int roundRobinCount)
findAdapterById_async(cb, adapterId);
}
}
+
+bool
+LocatorI::getDirectProxy(const LocatorAdapterInfo& adapter, const RequestPtr& request)
+{
+ {
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adapter.id);
+ if(p != _pendingRequests.end())
+ {
+ p->second.push_back(request);
+ return _activating.find(adapter.id) != _activating.end();
+ }
+
+ PendingRequests requests;
+ requests.push_back(request);
+ _pendingRequests.insert(make_pair(adapter.id, requests));
+ }
+
+ adapter.proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, adapter));
+ return false;
+}
+
+void
+LocatorI::getDirectProxyResponse(const LocatorAdapterInfo& adapter, const Ice::ObjectPrx& proxy)
+{
+ PendingRequests requests;
+ {
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adapter.id);
+ assert(p != _pendingRequests.end());
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
+ _activating.erase(adapter.id);
+ }
+
+ for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->response(adapter.id, proxy);
+ }
+}
+
+void
+LocatorI::getDirectProxyException(const LocatorAdapterInfo& adapter, const Ice::Exception& ex)
+{
+ bool activate = false;
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const AdapterNotActiveException& e)
+ {
+ activate = e.activatable;
+ }
+ catch(const Ice::Exception&)
+ {
+ }
+
+ PendingRequests requests;
+ {
+ Lock sync(*this);
+ PendingRequestsMap::iterator p = _pendingRequests.find(adapter.id);
+ assert(p != _pendingRequests.end());
+ if(activate)
+ {
+ _activating.insert(adapter.id);
+ requests = p->second;
+ }
+ else
+ {
+ requests.swap(p->second);
+ _pendingRequests.erase(p);
+ _activating.erase(adapter.id);
+ }
+ }
+
+ if(activate)
+ {
+ for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->activating();
+ }
+
+ AMI_Adapter_activatePtr amiCB = new AMI_Adapter_activateI(this, adapter);
+ int timeout = adapter.activationTimeout + adapter.deactivationTimeout;
+ AdapterPrx::uncheckedCast(adapter.proxy->ice_timeout(timeout * 1000))->activate_async(amiCB);
+ }
+ else
+ {
+ for(PendingRequests::iterator q = requests.begin(); q != requests.end(); ++q)
+ {
+ (*q)->exception(adapter.id, ex);
+ }
+ }
+}
diff --git a/cpp/src/IceGrid/LocatorI.h b/cpp/src/IceGrid/LocatorI.h
index cd7aeffe8df..452afd2c03b 100644
--- a/cpp/src/IceGrid/LocatorI.h
+++ b/cpp/src/IceGrid/LocatorI.h
@@ -43,7 +43,7 @@ public:
void execute();
void response(const std::string&, const Ice::ObjectPrx&);
- void activate(const std::string&);
+ void activating();
void exception(const std::string&, const Ice::Exception&);
virtual bool
@@ -68,7 +68,6 @@ public:
LocatorAdapterInfoSeq::const_iterator _lastAdapter;
std::map<std::string, Ice::ObjectPrx> _proxies;
std::auto_ptr<Ice::Exception> _exception;
- std::set<std::string> _activating;
};
typedef IceUtil::Handle<Request> RequestPtr;
@@ -88,14 +87,12 @@ public:
const Ice::CommunicatorPtr& getCommunicator() const;
const TraceLevelsPtr& getTraceLevels() const;
- void activate(const LocatorAdapterInfo&, const RequestPtr&);
- void cancelActivate(const std::string&, const RequestPtr&);
+ bool addPendingRoundRobinRequest(const std::string&, const Ice::AMD_Locator_findAdapterByIdPtr&, bool, bool&);
+ void removePendingRoundRobinRequest(const std::string&, int);
- void activateFinished(const std::string&, const Ice::ObjectPrx&);
- void activateException(const std::string&, const Ice::Exception&);
-
- bool addPendingResolve(const std::string&, const Ice::AMD_Locator_findAdapterByIdPtr&);
- void removePendingResolve(const std::string&, int);
+ bool getDirectProxy(const LocatorAdapterInfo&, const RequestPtr&);
+ void getDirectProxyResponse(const LocatorAdapterInfo&, const Ice::ObjectPrx&);
+ void getDirectProxyException(const LocatorAdapterInfo&, const Ice::Exception&);
protected:
@@ -105,10 +102,10 @@ protected:
const RegistryPrx _localRegistry;
const QueryPrx _localQuery;
- typedef std::set<RequestPtr> PendingRequests;
+ typedef std::vector<RequestPtr> PendingRequests;
typedef std::map<std::string, PendingRequests> PendingRequestsMap;
-
PendingRequestsMap _pendingRequests;
+ std::set<std::string> _activating;
std::map<std::string, std::deque<Ice::AMD_Locator_findAdapterByIdPtr> > _resolves;
};
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index b9b8b478243..01e308fed58 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -746,8 +746,12 @@ NodeEntry::__decRef()
void
NodeEntry::checkSession() const
{
- if(_session && !_session->isDestroyed())
+ if(_session)
{
+ if(_session->isDestroyed())
+ {
+ throw NodeUnreachableException(_name, "the node is not active");
+ }
return;
}
else if(!_proxy && !_registering)
@@ -787,7 +791,7 @@ NodeEntry::checkSession() const
}
}
- if(!_session)
+ if(!_session || _session->isDestroyed())
{
throw NodeUnreachableException(_name, "the node is not active");
}
@@ -894,14 +898,14 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
//
// For newer versions of Ice, we generate Ice.Admin properties:
//
- int iceVersion = 0;
+ server->iceVersion = 0;
if(info.descriptor->iceVersion != "")
{
- iceVersion = getMMVersion(info.descriptor->iceVersion);
+ server->iceVersion = getMMVersion(info.descriptor->iceVersion);
}
server->processRegistered = false;
- if(iceVersion == 0 || iceVersion >= 30300)
+ if(server->iceVersion == 0 || server->iceVersion >= 30300)
{
props.push_back(createProperty("Ice.Admin.ServerId", info.descriptor->id));
if(hasProperty(info.descriptor->propertySet.properties, "Ice.Admin.Endpoints"))
@@ -945,7 +949,7 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
}
props.push_back(createProperty("IceBox.LoadOrder", servicesStr));
- if(iceVersion != 0 && iceVersion < 30300)
+ if(server->iceVersion != 0 && server->iceVersion < 30300)
{
if(hasProperty(iceBox->propertySet.properties, "IceBox.ServiceManager.RegisterProcess"))
{
@@ -971,7 +975,7 @@ NodeEntry::getInternalServerDescriptor(const ServerInfo& info) const
// logs, adapters, db envs and properties to the internal server
// descriptor.
//
- forEachCommunicator(ToInternalServerDescriptor(server, _session->getInfo(), iceVersion))(info.descriptor);
+ forEachCommunicator(ToInternalServerDescriptor(server, _session->getInfo(), server->iceVersion))(info.descriptor);
return server;
}
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index b721c553271..067a61f548d 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -197,7 +197,7 @@ public:
{
}
- virtual void
+ virtual bool
send()
{
try
@@ -206,8 +206,9 @@ public:
}
catch(const Ice::LocalException&)
{
- finished(false);
+ return false;
}
+ return true;
}
virtual void
@@ -236,7 +237,7 @@ public:
{
}
- virtual void
+ virtual bool
send()
{
try
@@ -245,8 +246,9 @@ public:
}
catch(const Ice::LocalException&)
{
- finished(false);
+ return false;
}
+ return true;
}
virtual void
@@ -275,7 +277,7 @@ public:
{
}
- virtual void
+ virtual bool
send()
{
try
@@ -284,8 +286,9 @@ public:
}
catch(const Ice::LocalException&)
{
- finished(false);
+ return false;
}
+ return true;
}
virtual void
@@ -1074,11 +1077,17 @@ void
NodeI::queueUpdate(const NodeObserverPrx& proxy, const UpdatePtr& update)
{
//Lock sync(*this); Called within the synchronization
- deque<UpdatePtr>& queue = _observerUpdates[proxy];
- queue.push_back(update);
- if(queue.size() == 1)
+ map<NodeObserverPrx, deque<UpdatePtr> >::iterator p = _observerUpdates.find(proxy);
+ if(p == _observerUpdates.end())
{
- queue.front()->send();
+ if(update->send())
+ {
+ _observerUpdates[proxy].push_back(update);
+ }
+ }
+ else
+ {
+ p->second.push_back(update);
}
}
@@ -1092,21 +1101,14 @@ NodeI::dequeueUpdate(const NodeObserverPrx& proxy, const UpdatePtr& update, bool
return;
}
- deque<UpdatePtr>& queue = p->second;
- if(all)
- {
- queue.clear();
- }
- else
- {
- queue.pop_front();
- }
+ p->second.pop_front();
- if(!queue.empty())
+ if(all || (!p->second.empty() && !p->second.front()->send()))
{
- queue.front()->send();
+ p->second.clear();
}
- else
+
+ if(p->second.empty())
{
_observerUpdates.erase(p);
}
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 6ecb9df70a8..cced301a806 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -48,7 +48,7 @@ public:
Update(const NodeIPtr&, const NodeObserverPrx&);
virtual ~Update();
- virtual void send() = 0;
+ virtual bool send() = 0;
void finished(bool);
diff --git a/cpp/src/IceGrid/Scanner.l b/cpp/src/IceGrid/Scanner.l
index cfb70a50aa5..2c1fc68b64f 100644
--- a/cpp/src/IceGrid/Scanner.l
+++ b/cpp/src/IceGrid/Scanner.l
@@ -209,7 +209,7 @@ keyword [[:alpha:]]*
{
break;
}
- else if(isspace(c) || c == ';')
+ else if(isspace(static_cast<unsigned char>(c)) || c == ';')
{
unput(c);
break;
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 9879fc99ca7..1ebd9e84ba3 100644
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -320,7 +320,7 @@ struct EnvironmentEval : std::unary_function<string, string>
else
{
end = beg + 1;
- while((isalnum(v[end]) || v[end] == '_') && end < v.size())
+ while((isalnum(static_cast<unsigned char>(v[end])) || v[end] == '_') && end < v.size())
{
++end;
}
@@ -914,7 +914,8 @@ ServerI::isAdapterActivatable(const string& id) const
}
else if(_state < Destroying)
{
- return true; // The server is being deactivated.
+ return _node->getActivator()->isActive(); // The server is being deactivated and the
+ // node isn't shutting down yet.
}
else
{
@@ -2126,6 +2127,12 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
// Create the configuration files, remove the old ones.
//
{
+ //
+ // We do not want to esapce the properties if the Ice version is
+ // previous to Ice 3.3.
+ //
+ bool escapeProperties = (_desc->iceVersion == 0 || _desc->iceVersion > 30300);
+
Ice::StringSeq knownFiles;
for(PropertyDescriptorSeqDict::const_iterator p = properties.begin(); p != properties.end(); ++p)
{
@@ -2146,7 +2153,14 @@ ServerI::updateImpl(const InternalServerDescriptorPtr& descriptor)
}
else
{
- configfile << escapeProperty(r->name) << "=" << escapeProperty(r->value) << endl;
+ if(escapeProperties)
+ {
+ configfile << escapeProperty(r->name) << "=" << escapeProperty(r->value) << endl;
+ }
+ else
+ {
+ configfile << r->name << "=" << r->value << endl;
+ }
}
}
configfile.close();
diff --git a/cpp/src/IcePatch2/Calc.cpp b/cpp/src/IcePatch2/Calc.cpp
index 9ed422548da..92bd17c9510 100644
--- a/cpp/src/IcePatch2/Calc.cpp
+++ b/cpp/src/IcePatch2/Calc.cpp
@@ -43,7 +43,7 @@ struct IFileInfoPathEqual: public binary_function<const FileInfo&, const FileInf
for(string::size_type i = 0; i < lhs.path.size(); ++i)
{
- if(::tolower(lhs.path[i]) != ::tolower(rhs.path[i]))
+ if(::tolower(static_cast<unsigned char>(lhs.path[i])) != ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return false;
}
@@ -60,11 +60,12 @@ struct IFileInfoPathLess: public binary_function<const FileInfo&, const FileInfo
{
for(string::size_type i = 0; i < lhs.path.size() && i < rhs.path.size(); ++i)
{
- if(::tolower(lhs.path[i]) < ::tolower(rhs.path[i]))
+ if(::tolower(static_cast<unsigned char>(lhs.path[i])) < ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return true;
}
- else if(::tolower(lhs.path[i]) > ::tolower(rhs.path[i]))
+ else if(::tolower(static_cast<unsigned char>(lhs.path[i])) >
+ ::tolower(static_cast<unsigned char>(rhs.path[i])))
{
return false;
}
diff --git a/cpp/src/IcePatch2/Client.cpp b/cpp/src/IcePatch2/Client.cpp
index 3040c22d66b..52ac2bf2b17 100644
--- a/cpp/src/IcePatch2/Client.cpp
+++ b/cpp/src/IcePatch2/Client.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Ice/Application.h>
#include <IcePatch2/Util.h>
#include <IcePatch2/ClientUtil.h>
@@ -54,7 +55,7 @@ public:
{
cout << "Do a thorough patch? (yes/no)" << endl;
cin >> answer;
- transform(answer.begin(), answer.end(), answer.begin(), ::tolower);
+ answer = IceUtilInternal::toLower(answer);
if(answer == "no")
{
return false;
diff --git a/cpp/src/IcePatch2/Util.cpp b/cpp/src/IcePatch2/Util.cpp
index 2b572c27e57..f4f6c32ddf6 100644
--- a/cpp/src/IcePatch2/Util.cpp
+++ b/cpp/src/IcePatch2/Util.cpp
@@ -280,7 +280,8 @@ IcePatch2::simplify(const string& path)
}
if(result == "/." ||
- (result.size() == 4 && isalpha(result[0]) && result[1] == ':' && result[2] == '/' && result[3] == '.'))
+ (result.size() == 4 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/' && result[3] == '.'))
{
return result.substr(0, result.size() - 1);
}
@@ -290,7 +291,8 @@ IcePatch2::simplify(const string& path)
result.erase(result.size() - 2, 2);
}
- if(result == "/" || (result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/'))
+ if(result == "/" || (result.size() == 3 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/'))
{
return result;
}
@@ -313,7 +315,8 @@ IcePatch2::isRoot(const string& pa)
{
string path = simplify(pa);
#ifdef _WIN32
- return path == "/" || path.size() == 3 && isalpha(path[0]) && path[1] == ':' && path[2] == '/';
+ return path == "/" || path.size() == 3 && isalpha(static_cast<unsigned char>(path[0])) && path[1] == ':' &&
+ path[2] == '/';
#else
return path == "/";
#endif
diff --git a/cpp/src/IceSSL/Instance.cpp b/cpp/src/IceSSL/Instance.cpp
index a40dc5275cd..c2899b35f77 100644
--- a/cpp/src/IceSSL/Instance.cpp
+++ b/cpp/src/IceSSL/Instance.cpp
@@ -800,12 +800,10 @@ IceSSL::Instance::verifyPeer(SSL* ssl, SOCKET fd, const string& address, const s
if(!certNameOK && !dnsNames.empty())
{
- string host = address;
- transform(host.begin(), host.end(), host.begin(), ::tolower);
+ string host = IceUtilInternal::toLower(address);
for(vector<string>::const_iterator p = dnsNames.begin(); p != dnsNames.end() && !certNameOK; ++p)
{
- string s = *p;
- transform(s.begin(), s.end(), s.begin(), ::tolower);
+ string s = IceUtilInternal::toLower(*p);
if(host == s)
{
certNameOK = true;
diff --git a/cpp/src/IceSSL/RFC2253.cpp b/cpp/src/IceSSL/RFC2253.cpp
index ec547ce6c49..c6a19254358 100644
--- a/cpp/src/IceSSL/RFC2253.cpp
+++ b/cpp/src/IceSSL/RFC2253.cpp
@@ -253,10 +253,10 @@ parseAttributeType(const string& data, size_t& pos)
//
// First the OID case.
//
- if(isdigit(data[pos]) ||
+ if(isdigit(static_cast<unsigned char>(data[pos])) ||
(data.size() - pos >= 4 && (data.substr(pos, 4) == "oid." || data.substr(pos, 4) == "OID.")))
{
- if(!isdigit(data[pos]))
+ if(!isdigit(static_cast<unsigned char>(data[pos])))
{
result += data.substr(pos, 4);
pos += 4;
@@ -265,7 +265,7 @@ parseAttributeType(const string& data, size_t& pos)
while(true)
{
// 1*DIGIT
- while(pos < data.size() && isdigit(data[pos]))
+ while(pos < data.size() && isdigit(static_cast<unsigned char>(data[pos])))
{
result += data[pos];
++pos;
@@ -276,7 +276,7 @@ parseAttributeType(const string& data, size_t& pos)
result += data[pos];
++pos;
// 1*DIGIT must follow "."
- if(pos < data.size() && !isdigit(data[pos]))
+ if(pos < data.size() && !isdigit(static_cast<unsigned char>(data[pos])))
{
throw ParseException(__FILE__, __LINE__, "invalid attribute type (expected end of data)");
}
@@ -287,7 +287,7 @@ parseAttributeType(const string& data, size_t& pos)
}
}
}
- else if(isalpha(data[pos]))
+ else if(isalpha(static_cast<unsigned char>(data[pos])))
{
//
// The grammar is wrong in this case. It should be ALPHA
@@ -297,7 +297,8 @@ parseAttributeType(const string& data, size_t& pos)
result += data[pos];
++pos;
// 1* KEYCHAR
- while(pos < data.size() && (isalpha(data[pos]) || isdigit(data[pos]) || data[pos] == '-'))
+ while(pos < data.size() && (isalpha(static_cast<unsigned char>(data[pos])) ||
+ isdigit(static_cast<unsigned char>(data[pos])) || data[pos] == '-'))
{
result += data[pos];
++pos;
diff --git a/cpp/src/IceStorm/Makefile.mak b/cpp/src/IceStorm/Makefile.mak
index 5d6680b0249..87136b69d4f 100644
--- a/cpp/src/IceStorm/Makefile.mak
+++ b/cpp/src/IceStorm/Makefile.mak
@@ -18,13 +18,8 @@ SVCDLLNAME_D = $(top_srcdir)\bin\icestormservice$(SOVERSION)d.dll
SVCLIBNAME_R = $(top_srcdir)\lib\icestormservice.lib
SVCDLLNAME_R = $(top_srcdir)\bin\icestormservice$(SOVERSION).dll
-!if "$(OPTIMIZE)" != "yes"
-SVCLIBNAME = $(SVCLIBNAME_D)
-SVCDLLNAME = $(SVCDLLNAME_D)
-!else
-SVCLIBNAME = $(SVCLIBNAME_R)
-SVCDLLNAME = $(SVCDLLNAME_R)
-!endif
+SVCLIBNAME = $(top_srcdir)\lib\icestormservice$(LIBSUFFIX).lib
+SVCDLLNAME = $(top_srcdir)\bin\icestormservice$(SOVERSION)$(LIBSUFFIX).dll
ADMIN = $(top_srcdir)\bin\icestormadmin.exe
MIGRATE = $(top_srcdir)\bin\icestormmigrate.exe
diff --git a/cpp/src/IceStorm/Scanner.l b/cpp/src/IceStorm/Scanner.l
index 3b922de2332..24e238b5f3c 100644
--- a/cpp/src/IceStorm/Scanner.l
+++ b/cpp/src/IceStorm/Scanner.l
@@ -209,7 +209,7 @@ keyword [[:alpha:]]*
{
break;
}
- else if(isspace(c) || c == ';')
+ else if(isspace(static_cast<unsigned char>(c)) || c == ';')
{
unput(c);
break;
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index 4049b6b1017..519678d32b0 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -246,12 +246,12 @@ ServiceI::start(
// start of the node id, and then the end of the
// digits).
string::size_type start = instanceName.size();
- while(start < adapterid.size() && !isdigit(adapterid[start]))
+ while(start < adapterid.size() && !isdigit(static_cast<unsigned char>(adapterid[start])))
{
++start;
}
string::size_type end = start;
- while(end < adapterid.size() && isdigit(adapterid[end]))
+ while(end < adapterid.size() && isdigit(static_cast<unsigned char>(adapterid[end])))
{
++end;
}
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index c387115fee1..37d05249a49 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -21,7 +21,7 @@ IceUtilInternal::isAbsolutePath(const string& path)
size_t size = path.size();
// Skip whitespace
- while(i < size && isspace(path[i]))
+ while(i < size && isspace(static_cast<unsigned char>(path[i])))
{
++i;
}
diff --git a/cpp/src/IceUtil/InputUtil.cpp b/cpp/src/IceUtil/InputUtil.cpp
index d4d6253b589..5d5f8a616d0 100644
--- a/cpp/src/IceUtil/InputUtil.cpp
+++ b/cpp/src/IceUtil/InputUtil.cpp
@@ -58,7 +58,7 @@ strToInt64Impl(const char* s, char** endptr, int base)
//
// Skip leading whitespace
//
- while(*s && isspace(*s))
+ while(*s && isspace(static_cast<unsigned char>(*s)))
{
++s;
}
@@ -127,12 +127,12 @@ strToInt64Impl(const char* s, char** endptr, int base)
bool overflow = false;
bool digitFound = false;
const string validDigits(allDigits.begin(), allDigits.begin() + base);
- while(*s && validDigits.find_first_of(toupper(*s)) != validDigits.npos)
+ while(*s && validDigits.find_first_of(toupper(static_cast<unsigned char>(*s))) != validDigits.npos)
{
digitFound = true;
if(!overflow)
{
- int digit = digitVal[toupper(*s) - '0'];
+ int digit = digitVal[toupper(static_cast<unsigned char>(*s)) - '0'];
assert(digit != 100);
if(result < _I64_MAX / base)
{
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index 444c71d96cc..9c79e5b1130 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -455,7 +455,7 @@ IceUtilInternal::Options::split(const string& line)
//
case 'x':
{
- if(i < l.size() - 1 && !isxdigit(l[i + 1]))
+ if(i < l.size() - 1 && !isxdigit(static_cast<unsigned char>(l[i + 1])))
{
arg.push_back('\\');
arg.push_back('x');
@@ -464,14 +464,15 @@ IceUtilInternal::Options::split(const string& line)
Int64 ull = 0;
string::size_type j;
- for(j = i + 1; j < i + 3 && j < l.size() && isxdigit(c = l[j]); ++j)
+ for(j = i + 1; j < i + 3 && j < l.size() &&
+ isxdigit(static_cast<unsigned char>(c = l[j])); ++j)
{
ull *= 16;
- if(isdigit(c))
+ if(isdigit(static_cast<unsigned char>(c)))
{
ull += c - '0';
}
- else if(islower(c))
+ else if(islower(static_cast<unsigned char>(c)))
{
ull += c - 'a' + 10;
}
@@ -491,9 +492,9 @@ IceUtilInternal::Options::split(const string& line)
case 'c':
{
c = l[++i];
- if(isalpha(c) || c == '@' || (c >= '[' && c <= '_'))
+ if(isalpha(static_cast<unsigned char>(c)) || c == '@' || (c >= '[' && c <= '_'))
{
- arg.push_back(static_cast<char>(toupper(c) - '@'));
+ arg.push_back(static_cast<char>(toupper(static_cast<unsigned char>(c)) - '@'));
}
else
{
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 99c4d759724..a963428aa08 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -324,7 +324,6 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri
quoteChar = str[pos];
++pos;
}
- bool trim = true;
while(pos < length)
{
if(quoteChar != '\0' && str[pos] == '\\' && pos + 1 < length && str[pos + 1] == quoteChar)
@@ -333,7 +332,6 @@ IceUtilInternal::splitString(const string& str, const string& delim, vector<stri
}
else if(quoteChar != '\0' && str[pos] == quoteChar)
{
- trim = false;
++pos;
quoteChar = '\0';
break;
@@ -687,4 +685,40 @@ IceUtilInternal::lastErrorToString()
return errorToString(errno);
}
+string
+IceUtilInternal::toLower(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ result += tolower(static_cast<unsigned char>(s[i]));
+ }
+ return result;
+}
+
+string
+IceUtilInternal::toUpper(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ result += toupper(static_cast<unsigned char>(s[i]));
+ }
+ return result;
+}
+
+string
+IceUtilInternal::removeWhitespace(const std::string& s)
+{
+ string result;
+ for(unsigned int i = 0; i < s.length(); ++ i)
+ {
+ if(!isspace(static_cast<unsigned char>(s[i])))
+ {
+ result += s[i];
+ }
+ }
+ return result;
+}
+
#endif
diff --git a/cpp/src/Slice/CPlusPlusUtil.cpp b/cpp/src/Slice/CPlusPlusUtil.cpp
index bb6e5db83b4..7620e50e9c9 100644
--- a/cpp/src/Slice/CPlusPlusUtil.cpp
+++ b/cpp/src/Slice/CPlusPlusUtil.cpp
@@ -25,7 +25,7 @@ Slice::FeatureProfile Slice::featureProfile = Slice::Ice;
char
Slice::ToIfdef::operator()(char c)
{
- if(!isalnum(c))
+ if(!isalnum(static_cast<unsigned char>(c)))
{
return '_';
}
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index f329eb84606..a3197c1796b 100644
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -887,7 +887,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
}
default:
{
- typeS[0] = toupper(typeS[0]);
+ typeS[0] = toupper(static_cast<unsigned char>(typeS[0]));
if(marshal)
{
out << nl << stream << ".write" << typeS << "Seq(";
diff --git a/cpp/src/Slice/DotNetNames.cpp b/cpp/src/Slice/DotNetNames.cpp
index cd3b3187f47..6e1be365a3b 100644
--- a/cpp/src/Slice/DotNetNames.cpp
+++ b/cpp/src/Slice/DotNetNames.cpp
@@ -84,7 +84,7 @@ ciEquals(const string& s, const char* p)
string::const_iterator i = s.begin();
while(i != s.end())
{
- if(tolower(*i++) != tolower(*p++))
+ if(tolower(static_cast<unsigned char>(*i++)) != tolower(static_cast<unsigned char>(*p++)))
{
return false;
}
diff --git a/cpp/src/Slice/Parser.cpp b/cpp/src/Slice/Parser.cpp
index c93de96da22..98206069b03 100644
--- a/cpp/src/Slice/Parser.cpp
+++ b/cpp/src/Slice/Parser.cpp
@@ -48,16 +48,6 @@ Unit* unit;
}
// ----------------------------------------------------------------------
-// toLower() helper function
-// ----------------------------------------------------------------------
-
-static void
-toLower(string& s)
-{
- transform(s.begin(), s.end(), s.begin(), ::tolower);
-}
-
-// ----------------------------------------------------------------------
// DefinitionContext
// ----------------------------------------------------------------------
@@ -2044,10 +2034,8 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
}
if(!_unit->caseSensitive())
{
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
+ string name = IceUtilInternal::toLower(newName);
+ string thisName = IceUtilInternal::toLower(module->name());
if(name == thisName)
{
string msg = newConstruct;
@@ -2075,10 +2063,8 @@ Slice::Container::nameIsLegal(const string& newName, const char* newConstruct)
}
if(!_unit->caseSensitive())
{
- string name = newName;
- toLower(name);
- string thisName = module->name();
- toLower(thisName);
+ string name = IceUtilInternal::toLower(newName);
+ string thisName = IceUtilInternal::toLower(module->name());
if(name == thisName)
{
string msg = newConstruct;
@@ -2125,9 +2111,9 @@ Slice::Container::checkPrefix(const string& name) const
if(name.size() >= 3)
{
string prefix3;
- prefix3 += ::tolower(name[0]);
- prefix3 += ::tolower(name[1]);
- prefix3 += ::tolower(name[2]);
+ prefix3 += ::tolower(static_cast<unsigned char>(name[0]));
+ prefix3 += ::tolower(static_cast<unsigned char>(name[1]));
+ prefix3 += ::tolower(static_cast<unsigned char>(name[2]));
if(prefix3 == "ice")
{
_unit->error("illegal identifier `" + name + "': `" + name.substr(0, 3) + "' prefix is reserved");
@@ -2649,10 +2635,8 @@ Slice::ClassDef::createOperation(const string& name,
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "operation `" + name + "' differs only in capitalization from enclosing ";
@@ -2690,10 +2674,8 @@ Slice::ClassDef::createOperation(const string& name,
}
if(!_unit->caseSensitive())
{
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*q)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "operation `" + name + "' differs only in capitalization from " + (*q)->kindOf();
@@ -2788,10 +2770,8 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "data member `" + name + "' differs only in capitalization from enclosing class name `";
@@ -2828,10 +2808,8 @@ Slice::ClassDef::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string baseName = (*q)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*q)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "data member `" + name + "' differs only in capitalization from " + (*q)->kindOf();
@@ -3266,10 +3244,8 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "exception member `" + name + "' differs only in capitalization ";
@@ -3297,10 +3273,8 @@ Slice::Exception::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string baseName = (*r)->name();
- toLower(baseName);
- string newName = name;
- toLower(newName);
+ string baseName = IceUtilInternal::toLower((*r)->name());
+ string newName = IceUtilInternal::toLower(name);
if(baseName == newName)
{
string msg = "exception member `" + name + "' differs only in capitalization from exception member `";
@@ -3578,10 +3552,8 @@ Slice::Struct::createDataMember(const string& name, const TypePtr& type)
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "struct member `" + name + "' differs only in capitalization from enclosing struct name `";
@@ -4503,10 +4475,8 @@ Slice::Operation::createParamDecl(const string& name, const TypePtr& type, bool
}
if(!_unit->caseSensitive())
{
- string newName = name;
- toLower(newName);
- string thisName = this->name();
- toLower(thisName);
+ string newName = IceUtilInternal::toLower(name);
+ string thisName = IceUtilInternal::toLower(this->name());
if(newName == thisName)
{
string msg = "parameter `" + name + "' differs only in capitalization from operation name `";
@@ -5279,7 +5249,7 @@ Slice::Unit::addContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ scoped = IceUtilInternal::toLower(scoped);
}
_contentMap[scoped].push_back(contained);
}
@@ -5290,7 +5260,7 @@ Slice::Unit::removeContent(const ContainedPtr& contained)
string scoped = contained->scoped();
if(!caseSensitive())
{
- toLower(scoped);
+ scoped = IceUtilInternal::toLower(scoped);
}
map<string, ContainedList>::iterator p = _contentMap.find(scoped);
assert(p != _contentMap.end());
@@ -5315,7 +5285,7 @@ Slice::Unit::findContents(const string& scoped) const
string name = scoped;
if(!_unit->caseSensitive())
{
- toLower(name);
+ name = IceUtilInternal::toLower(name);
}
map<string, ContainedList>::const_iterator p = _contentMap.find(name);
@@ -5600,7 +5570,8 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
{
string::const_iterator p1 = s1.begin();
string::const_iterator p2 = s2.begin();
- while(p1 != s1.end() && p2 != s2.end() && ::tolower(*p1) == ::tolower(*p2))
+ while(p1 != s1.end() && p2 != s2.end() &&
+ ::tolower(static_cast<unsigned char>(*p1)) == ::tolower(static_cast<unsigned char>(*p2)))
{
++p1;
++p2;
@@ -5619,7 +5590,7 @@ Slice::CICompare::operator()(const string& s1, const string& s2) const
}
else
{
- return ::tolower(*p1) < ::tolower(*p2);
+ return ::tolower(static_cast<unsigned char>(*p1)) < ::tolower(static_cast<unsigned char>(*p2));
}
}
diff --git a/cpp/src/Slice/Preprocessor.cpp b/cpp/src/Slice/Preprocessor.cpp
index e2ddc5cbe09..ac62657e59a 100644
--- a/cpp/src/Slice/Preprocessor.cpp
+++ b/cpp/src/Slice/Preprocessor.cpp
@@ -112,7 +112,8 @@ Slice::Preprocessor::normalizeIncludePath(const string& path)
result.replace(pos, 2, "/");
}
- if(result == "/" || (result.size() == 3 && isalpha(result[0]) && result[1] == ':' && result[2] == '/'))
+ if(result == "/" || (result.size() == 3 && isalpha(static_cast<unsigned char>(result[0])) && result[1] == ':' &&
+ result[2] == '/'))
{
return result;
}
@@ -477,8 +478,7 @@ Slice::Preprocessor::checkInputFile()
string::size_type pos = base.rfind('.');
if(pos != string::npos)
{
- suffix = base.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = IceUtilInternal::toLower(base.substr(pos));
}
if(suffix != ".ice")
{
diff --git a/cpp/src/Slice/Scanner.l b/cpp/src/Slice/Scanner.l
index be0dedaf96b..e836da8cf51 100644
--- a/cpp/src/Slice/Scanner.l
+++ b/cpp/src/Slice/Scanner.l
@@ -291,15 +291,15 @@ floating_literal (({fractional_constant}{exponent_part}?)|((\+|-)?[[:digit:]]+{e
case 'x':
{
IceUtil::Int64 ull = 0;
- while(isxdigit(next = static_cast<char>(yyinput())))
+ while(isxdigit(static_cast<unsigned char>(next = static_cast<char>(yyinput()))))
{
str->literal += next;
ull *= 16;
- if(isdigit(next))
+ if(isdigit(static_cast<unsigned char>(next)))
{
ull += next - '0';
}
- else if(islower(next))
+ else if(islower(static_cast<unsigned char>(next)))
{
ull += next - 'a' + 10;
}
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index a3aa45c4ce9..a3a02ab55c9 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -1223,7 +1223,7 @@ Slice::Gen::generateChecksums(const UnitPtr& u)
string className = "X" + IceUtil::generateUUID();
for(string::size_type pos = 1; pos < className.size(); ++pos)
{
- if(!isalnum(className[pos]))
+ if(!isalnum(static_cast<unsigned char>(className[pos])))
{
className[pos] = '_';
}
diff --git a/cpp/src/slice2docbook/Gen.cpp b/cpp/src/slice2docbook/Gen.cpp
index f8950f72d46..3521184c01c 100644
--- a/cpp/src/slice2docbook/Gen.cpp
+++ b/cpp/src/slice2docbook/Gen.cpp
@@ -932,7 +932,7 @@ Slice::Gen::getComment(const ContainedPtr& contained, const ContainerPtr& contai
}
comment += toString(literal, container);
}
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
comment += '.';
break;
diff --git a/cpp/src/slice2docbook/Main.cpp b/cpp/src/slice2docbook/Main.cpp
index 4f1bd207afb..4386ceae454 100644
--- a/cpp/src/slice2docbook/Main.cpp
+++ b/cpp/src/slice2docbook/Main.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/SignalHandler.h>
#include <Gen.h>
@@ -130,8 +131,7 @@ main(int argc, char* argv[])
string::size_type pos = docbook.rfind('.');
if(pos != string::npos)
{
- suffix = docbook.substr(pos);
- transform(suffix.begin(), suffix.end(), suffix.begin(), ::tolower);
+ suffix = IceUtilInternal::toLower(docbook.substr(pos));
}
if(suffix != ".sgml")
{
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 417f50ad6aa..d89b03670eb 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -13,6 +13,7 @@
#include <Slice/Util.h>
#include <Slice/CPlusPlusUtil.h>
#include <IceUtil/OutputUtil.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/SignalHandler.h>
#include <cstring>
@@ -221,7 +222,7 @@ usage(const char* n)
bool
checkIdentifier(string n, string t, string s)
{
- if(s.empty() || (!isalpha(s[0]) && s[0] != '_'))
+ if(s.empty() || (!isalpha(static_cast<unsigned char>(s[0])) && s[0] != '_'))
{
cerr << n << ": `" << t << "' is not a valid type name" << endl;
return false;
@@ -229,7 +230,7 @@ checkIdentifier(string n, string t, string s)
for(unsigned int i = 1; i < s.size(); ++i)
{
- if(!isalnum(s[i]) && s[i] != '_')
+ if(!isalnum(static_cast<unsigned char>(s[i])) && s[i] != '_')
{
cerr << n << ": `" << t << "' is not a valid type name" << endl;
return false;
@@ -409,7 +410,7 @@ writeDictWithIndicesH(const string& name, const Dict& dict,
if(!member.empty())
{
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
}
else
@@ -604,7 +605,7 @@ writeDictWithIndicesC(const string& name, const string& absolute, const Dict& di
if(!member.empty())
{
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
}
else
@@ -1429,8 +1430,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Dict dict;
@@ -1562,8 +1562,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Index index;
@@ -1629,8 +1628,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict-index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
string dictName;
DictIndex index;
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index f8c51ab112b..709de7a58cb 100644
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -8,6 +8,7 @@
// **********************************************************************
#include <IceUtil/Options.h>
+#include <IceUtil/StringUtil.h>
#include <Slice/Preprocessor.h>
#include <Slice/JavaUtil.h>
#include <Slice/SignalHandler.h>
@@ -351,7 +352,7 @@ FreezeGenerator::generate(UnitPtr& u, const Dict& dict)
indexTypes.push_back(dataMemberType);
string capitalizedMember = member;
- capitalizedMember[0] = toupper(capitalizedMember[0]);
+ capitalizedMember[0] = toupper(static_cast<unsigned char>(capitalizedMember[0]));
capitalizedMembers.push_back(capitalizedMember);
indexNames.push_back(member);
}
@@ -1203,8 +1204,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("dict");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Dict dict;
@@ -1251,8 +1251,7 @@ main(int argc, char* argv[])
optargs = opts.argVec("index");
for(i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
Index index;
@@ -1320,8 +1319,7 @@ main(int argc, char* argv[])
vector<string> optargs = opts.argVec("dict-index");
for(vector<string>::const_iterator i = optargs.begin(); i != optargs.end(); ++i)
{
- string s = *i;
- s.erase(remove_if(s.begin(), s.end(), ::isspace), s.end());
+ string s = IceUtilInternal::removeWhitespace(*i);
string dictName;
DictIndex index;
diff --git a/cpp/src/slice2html/Gen.cpp b/cpp/src/slice2html/Gen.cpp
index f1e9e5b02e0..c2a6ff52bbe 100644
--- a/cpp/src/slice2html/Gen.cpp
+++ b/cpp/src/slice2html/Gen.cpp
@@ -1116,7 +1116,7 @@ Slice::GeneratorBase::getComment(const ContainedPtr& contained, const ContainerP
comment += toString(literal, container, false, forIndex, summary ? &sz : 0);
summarySize += sz;
}
- else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(s[i + 1])))
+ else if(summary && s[i] == '.' && (i + 1 >= s.size() || isspace(static_cast<unsigned char>(s[i + 1]))))
{
comment += '.';
++summarySize;
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 974d0b6e647..e8f7145afc3 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -2670,7 +2670,7 @@ Slice::Gen::TypesVisitor::visitDataMember(const DataMemberPtr& p)
if(p->hasMetaData(_getSetMetaData) || contained->hasMetaData(_getSetMetaData))
{
string capName = p->name();
- capName[0] = toupper(capName[0]);
+ capName[0] = toupper(static_cast<unsigned char>(capName[0]));
//
// If container is a class, get all of its operations so that we can check for conflicts.
@@ -3057,7 +3057,7 @@ Slice::Gen::TypesVisitor::visitConst(const ConstPtr& p)
const string val = p->value();
for(string::const_iterator c = val.begin(); c != val.end(); ++c)
{
- if(isascii(*c) && isprint(*c))
+ if(isascii(static_cast<unsigned char>(*c)) && isprint(static_cast<unsigned char>(*c)))
{
switch(*c)
{