summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Freeze/TransactionalEvictorContext.cpp6
-rw-r--r--cpp/src/Freeze/TransactionalEvictorI.cpp8
-rwxr-xr-xcpp/src/Glacier2/Blobject.cpp190
-rw-r--r--cpp/src/Glacier2/Blobject.h25
-rw-r--r--cpp/src/Glacier2/RouterI.cpp6
-rw-r--r--cpp/src/Glacier2/RouterI.h2
-rw-r--r--cpp/src/Glacier2/SessionRouterI.cpp356
-rw-r--r--cpp/src/Glacier2/SessionRouterI.h4
-rw-r--r--cpp/src/Glacier2Lib/Application.cpp59
-rw-r--r--cpp/src/Glacier2Lib/SessionHelper.cpp14
-rw-r--r--cpp/src/Ice/CommunicatorI.cpp8
-rw-r--r--cpp/src/Ice/CommunicatorI.h12
-rw-r--r--cpp/src/Ice/ConnectRequestHandler.cpp8
-rwxr-xr-xcpp/src/Ice/ConnectionFactory.cpp6
-rw-r--r--cpp/src/Ice/ConnectionI.cpp10
-rw-r--r--cpp/src/Ice/ConnectionI.h12
-rw-r--r--cpp/src/Ice/Direct.cpp2
-rw-r--r--cpp/src/Ice/DynamicLibrary.cpp58
-rw-r--r--cpp/src/Ice/EventHandler.h4
-rw-r--r--cpp/src/Ice/HashUtil.h7
-rw-r--r--cpp/src/Ice/Initialize.cpp8
-rw-r--r--cpp/src/Ice/LocatorInfo.cpp44
-rw-r--r--cpp/src/Ice/LocatorInfo.h6
-rw-r--r--cpp/src/Ice/Makefile.mak1
-rw-r--r--cpp/src/Ice/Network.cpp10
-rw-r--r--cpp/src/Ice/Object.cpp2
-rw-r--r--cpp/src/Ice/OpaqueEndpointI.cpp3
-rw-r--r--cpp/src/Ice/Outgoing.cpp8
-rw-r--r--cpp/src/Ice/OutgoingAsync.cpp2
-rw-r--r--cpp/src/Ice/PluginManagerI.cpp119
-rw-r--r--cpp/src/Ice/PluginManagerI.h14
-rw-r--r--cpp/src/Ice/Proxy.cpp20
-rw-r--r--cpp/src/Ice/Reference.cpp16
-rw-r--r--cpp/src/Ice/RouterInfo.cpp150
-rw-r--r--cpp/src/Ice/RouterInfo.h34
-rw-r--r--cpp/src/Ice/Service.cpp591
-rw-r--r--cpp/src/Ice/TcpEndpointI.cpp7
-rw-r--r--cpp/src/Ice/ThreadPool.cpp8
-rw-r--r--cpp/src/Ice/UdpEndpointI.cpp7
-rw-r--r--cpp/src/Ice/winrt/StreamEndpointI.cpp7
-rw-r--r--cpp/src/IceBox/ServiceManagerI.cpp189
-rw-r--r--cpp/src/IceBox/ServiceManagerI.h3
-rw-r--r--cpp/src/IceGrid/Activator.cpp76
-rw-r--r--cpp/src/IceGrid/AdminCallbackRouter.cpp40
-rw-r--r--cpp/src/IceGrid/AdminCallbackRouter.h24
-rw-r--r--cpp/src/IceGrid/AdminI.cpp137
-rw-r--r--cpp/src/IceGrid/Internal.ice22
-rw-r--r--cpp/src/IceGrid/LocatorI.cpp28
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.cpp43
-rw-r--r--cpp/src/IceGrid/LocatorRegistryI.h12
-rw-r--r--cpp/src/IceGrid/NodeCache.cpp56
-rw-r--r--cpp/src/IceGrid/NodeI.cpp66
-rw-r--r--cpp/src/IceGrid/NodeI.h3
-rwxr-xr-xcpp/src/IceGrid/ServerI.cpp35
-rw-r--r--cpp/src/IceGrid/ServerI.h2
-rwxr-xr-xcpp/src/IcePatch2Lib/ClientUtil.cpp151
-rw-r--r--cpp/src/IceSSL/Certificate.cpp6
-rw-r--r--cpp/src/IceSSL/EndpointI.cpp7
-rw-r--r--cpp/src/IceStorm/Election.ice8
-rw-r--r--cpp/src/IceStorm/IceStormInternal.ice4
-rw-r--r--cpp/src/IceStorm/NodeI.cpp15
-rw-r--r--cpp/src/IceStorm/Observers.cpp100
-rw-r--r--cpp/src/IceStorm/Observers.h19
-rw-r--r--cpp/src/IceStorm/Replica.h6
-rw-r--r--cpp/src/IceStorm/Service.cpp2
-rwxr-xr-xcpp/src/IceStorm/Subscriber.cpp184
-rw-r--r--cpp/src/IceStorm/Subscriber.h2
-rw-r--r--cpp/src/IceStorm/TopicI.cpp13
-rw-r--r--cpp/src/IceUtil/CtrlCHandler.cpp2
-rw-r--r--cpp/src/IceUtil/Exception.cpp117
-rw-r--r--cpp/src/IceUtil/FileUtil.cpp5
-rw-r--r--cpp/src/IceUtil/Makefile.mak2
-rw-r--r--cpp/src/IceUtil/Options.cpp4
-rw-r--r--cpp/src/IceUtil/OutputUtil.cpp4
-rw-r--r--cpp/src/IceUtil/ThreadException.cpp12
-rw-r--r--cpp/src/IceUtil/Unicode.cpp2
-rw-r--r--cpp/src/IceXML/Parser.cpp2
-rw-r--r--cpp/src/Slice/CsUtil.cpp83
-rw-r--r--cpp/src/Slice/FileTracker.cpp8
-rw-r--r--cpp/src/slice2cpp/Gen.cpp344
-rw-r--r--cpp/src/slice2cpp/Main.cpp12
-rw-r--r--cpp/src/slice2cs/Gen.cpp524
-rw-r--r--cpp/src/slice2cs/Gen.h5
-rw-r--r--cpp/src/slice2cs/Main.cpp12
-rw-r--r--cpp/src/slice2freeze/Main.cpp14
-rwxr-xr-xcpp/src/slice2freezej/Main.cpp14
-rwxr-xr-xcpp/src/slice2html/Main.cpp14
-rw-r--r--cpp/src/slice2java/Gen.cpp118
-rw-r--r--cpp/src/slice2java/Main.cpp12
-rw-r--r--cpp/src/slice2php/Main.cpp12
-rw-r--r--cpp/src/slice2py/Main.cpp12
-rw-r--r--cpp/src/slice2rb/Main.cpp20
92 files changed, 2015 insertions, 2446 deletions
diff --git a/cpp/src/Freeze/TransactionalEvictorContext.cpp b/cpp/src/Freeze/TransactionalEvictorContext.cpp
index c65523fa836..b0dacafe261 100644
--- a/cpp/src/Freeze/TransactionalEvictorContext.cpp
+++ b/cpp/src/Freeze/TransactionalEvictorContext.cpp
@@ -39,7 +39,7 @@ Freeze::TransactionalEvictorDeadlockException::ice_name() const
return "Freeze::TransactionalEvictorDeadlockException";
}
-Ice::Exception*
+Freeze::TransactionalEvictorDeadlockException*
Freeze::TransactionalEvictorDeadlockException::ice_clone() const
{
return new TransactionalEvictorDeadlockException(*this);
@@ -197,7 +197,7 @@ Freeze::TransactionalEvictorContext::exception(const std::exception& ex)
if(dx != 0 && _owner == IceUtil::ThreadControl())
{
- _deadlockException.reset(dynamic_cast<DeadlockException*>(dx->ice_clone()));
+ _deadlockException.reset(dx->ice_clone());
return false;
}
@@ -205,7 +205,7 @@ Freeze::TransactionalEvictorContext::exception(const std::exception& ex)
dynamic_cast<const TransactionalEvictorDeadlockException*>(&ex);
if(edx != 0 && _owner == IceUtil::ThreadControl())
{
- _nestedCallDeadlockException.reset(dynamic_cast<TransactionalEvictorDeadlockException*>(edx->ice_clone()));
+ _nestedCallDeadlockException.reset(edx->ice_clone());
return false;
}
diff --git a/cpp/src/Freeze/TransactionalEvictorI.cpp b/cpp/src/Freeze/TransactionalEvictorI.cpp
index 27cae3e8282..5d984a5cf4f 100644
--- a/cpp/src/Freeze/TransactionalEvictorI.cpp
+++ b/cpp/src/Freeze/TransactionalEvictorI.cpp
@@ -422,7 +422,12 @@ Freeze::TransactionalEvictorI::dispatch(Request& request)
assert(sample != 0);
int operationAttributes = sample->ice_operationAttributes(current.operation);
-
+
+ if(operationAttributes < 0)
+ {
+ throw OperationNotExistException(__FILE__, __LINE__);
+ }
+
bool readOnly = (operationAttributes & 0x1) == 0;
int txMode = (operationAttributes & 0x6) >> 1;
@@ -467,6 +472,7 @@ Freeze::TransactionalEvictorI::dispatch(Request& request)
default:
{
assert(0);
+ throw OperationNotExistException(__FILE__, __LINE__);
}
}
diff --git a/cpp/src/Glacier2/Blobject.cpp b/cpp/src/Glacier2/Blobject.cpp
index ac0571fd6de..c64e3def10e 100755
--- a/cpp/src/Glacier2/Blobject.cpp
+++ b/cpp/src/Glacier2/Blobject.cpp
@@ -26,122 +26,10 @@ const string clientTraceRequest = "Glacier2.Client.Trace.Request";
const string serverTraceOverride = "Glacier2.Server.Trace.Override";
const string clientTraceOverride = "Glacier2.Client.Trace.Override";
-class AMI_Array_Object_ice_invokeTwowayI : public AMI_Array_Object_ice_invoke
-{
-public:
-
- AMI_Array_Object_ice_invokeTwowayI(const AMD_Object_ice_invokePtr& amdCB,
- const InstancePtr& instance,
- const ConnectionPtr& connection) :
- _amdCB(amdCB),
- _instance(instance),
- _connection(connection)
- {
- }
-
- virtual void
- ice_response(bool ok, const pair<const Byte*, const Byte*>& outParams)
- {
- _amdCB->ice_response(ok, outParams);
- }
-
- virtual void
- ice_exception(const Exception& ex)
- {
- //
- // If the connection has been lost, destroy the session.
- //
- if(_connection)
- {
- if(dynamic_cast<const Ice::SocketException*>(&ex) ||
- dynamic_cast<const Ice::TimeoutException*>(&ex) ||
- dynamic_cast<const Ice::ProtocolException*>(&ex))
- {
- try
- {
- _instance->sessionRouter()->destroySession(_connection);
- }
- catch(const Exception&)
- {
- }
- }
- }
-
- _amdCB->ice_exception(ex);
- }
-
-private:
-
- const AMD_Object_ice_invokePtr _amdCB;
- const InstancePtr _instance;
- const ConnectionPtr _connection;
-};
-
-class AMI_Array_Object_ice_invokeOnewayI : public AMI_Array_Object_ice_invoke, public Ice::AMISentCallback
-{
-public:
-
- AMI_Array_Object_ice_invokeOnewayI(const AMD_Object_ice_invokePtr& amdCB,
- const InstancePtr& instance,
- const ConnectionPtr& connection) :
- _amdCB(amdCB),
- _instance(instance),
- _connection(connection)
- {
- }
-
- virtual void
- ice_response(bool, const pair<const Byte*, const Byte*>&)
- {
- assert(false);
- }
-
- virtual void
- ice_sent()
- {
-#if (defined(_MSC_VER) && (_MSC_VER >= 1600))
- _amdCB->ice_response(true, pair<const Byte*, const Byte*>(nullptr, nullptr));
-#else
- _amdCB->ice_response(true, pair<const Byte*, const Byte*>(0, 0));
-#endif
- }
-
- virtual void
- ice_exception(const Exception& ex)
- {
- //
- // If the connection has been lost, destroy the session.
- //
- if(_connection)
- {
- if(dynamic_cast<const Ice::SocketException*>(&ex) ||
- dynamic_cast<const Ice::TimeoutException*>(&ex) ||
- dynamic_cast<const Ice::ProtocolException*>(&ex))
- {
- try
- {
- _instance->sessionRouter()->destroySession(_connection);
- }
- catch(const Exception&)
- {
- }
- }
- }
-
- _amdCB->ice_exception(ex);
- }
-
-private:
-
- const AMD_Object_ice_invokePtr _amdCB;
- const InstancePtr _instance;
- const ConnectionPtr _connection;
-};
-
}
Glacier2::Blobject::Blobject(const InstancePtr& instance, const ConnectionPtr& reverseConnection,
- const Ice::Context& context) :
+ const Context& context) :
_instance(instance),
_reverseConnection(reverseConnection),
_forwardContext(_reverseConnection ?
@@ -180,8 +68,52 @@ Glacier2::Blobject::destroy()
}
void
+Glacier2::Blobject::invokeResponse(bool ok, const pair<const Byte*, const Byte*>& outParams,
+ const InvokeCookiePtr& cookie)
+{
+ cookie->cb()->ice_response(ok, outParams);
+}
+
+void
+Glacier2::Blobject::invokeSent(bool sent, const InvokeCookiePtr& cookie)
+{
+ if(sent)
+ {
+#if (defined(_MSC_VER) && (_MSC_VER >= 1600))
+ cookie->cb()->ice_response(true, pair<const Byte*, const Byte*>(nullptr, nullptr));
+#else
+ cookie->cb()->ice_response(true, pair<const Byte*, const Byte*>(0, 0));
+#endif
+ }
+}
+
+void
+Glacier2::Blobject::invokeException(const Exception& ex, const InvokeCookiePtr& cookie)
+{
+ //
+ // If the connection has been lost, destroy the session.
+ //
+ if(_reverseConnection)
+ {
+ if(dynamic_cast<const SocketException*>(&ex) ||
+ dynamic_cast<const TimeoutException*>(&ex) ||
+ dynamic_cast<const ProtocolException*>(&ex))
+ {
+ try
+ {
+ _instance->sessionRouter()->destroySession(_reverseConnection);
+ }
+ catch(const Exception&)
+ {
+ }
+ }
+ }
+ cookie->cb()->ice_exception(ex);
+}
+
+void
Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amdCB,
- const std::pair<const Ice::Byte*, const Ice::Byte*>& inParams, const Current& current)
+ const std::pair<const Byte*, const Byte*>& inParams, const Current& current)
{
//
// Set the correct facet on the proxy.
@@ -398,50 +330,44 @@ Glacier2::Blobject::invoke(ObjectPrx& proxy, const AMD_Object_ice_invokePtr& amd
try
{
- AMI_Array_Object_ice_invokePtr amiCB;
- Ice::AMISentCallback* sentCB = 0;
+ Callback_Object_ice_invokePtr amiCB;
if(proxy->ice_isTwoway())
{
- amiCB = new AMI_Array_Object_ice_invokeTwowayI(amdCB, _instance, _reverseConnection);
+ amiCB = newCallback_Object_ice_invoke(this, &Blobject::invokeResponse, &Blobject::invokeException);
}
else
{
- AMI_Array_Object_ice_invokeOnewayI* cb =
- new AMI_Array_Object_ice_invokeOnewayI(amdCB, _instance, _reverseConnection);
- amiCB = cb;
- sentCB = cb;
+ amiCB = newCallback_Object_ice_invoke(this, &Blobject::invokeException, &Blobject::invokeSent);
}
- bool sent;
if(_forwardContext)
{
if(_context.size() > 0)
{
- Ice::Context ctx = current.ctx;
+ Context ctx = current.ctx;
ctx.insert(_context.begin(), _context.end());
- sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, ctx);
+ proxy->begin_ice_invoke(current.operation, current.mode, inParams, ctx, amiCB,
+ new InvokeCookie(amdCB));
}
else
{
- sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, current.ctx);
+ proxy->begin_ice_invoke(current.operation, current.mode, inParams, current.ctx, amiCB,
+ new InvokeCookie(amdCB));
}
}
else
{
if(_context.size() > 0)
{
- sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams, _context);
+ proxy->begin_ice_invoke(current.operation, current.mode, inParams, _context, amiCB,
+ new InvokeCookie(amdCB));
}
else
{
- sent = proxy->ice_invoke_async(amiCB, current.operation, current.mode, inParams);
+ proxy->begin_ice_invoke(current.operation, current.mode, inParams, amiCB,
+ new InvokeCookie(amdCB));
}
}
-
- if(sent && sentCB)
- {
- sentCB->ice_sent();
- }
}
catch(const LocalException& ex)
{
diff --git a/cpp/src/Glacier2/Blobject.h b/cpp/src/Glacier2/Blobject.h
index 05e6c63fe3b..dff1fbe91ca 100644
--- a/cpp/src/Glacier2/Blobject.h
+++ b/cpp/src/Glacier2/Blobject.h
@@ -25,6 +25,31 @@ public:
void destroy();
+ class InvokeCookie : public Ice::LocalObject
+ {
+ public:
+
+ InvokeCookie(const Ice::AMD_Object_ice_invokePtr& cb) :
+ _cb(cb)
+ {
+ }
+
+ Ice::AMD_Object_ice_invokePtr cb()
+ {
+ return _cb;
+ }
+
+ private:
+
+ Ice::AMD_Object_ice_invokePtr _cb;
+ };
+ typedef IceUtil::Handle<InvokeCookie> InvokeCookiePtr;
+
+ void invokeResponse(bool, const std::pair<const Ice::Byte*, const Ice::Byte*>&,
+ const InvokeCookiePtr&);
+ void invokeSent(bool, const InvokeCookiePtr&);
+ void invokeException(const Ice::Exception&, const InvokeCookiePtr&);
+
protected:
void invoke(Ice::ObjectPrx&, const Ice::AMD_Object_ice_invokePtr&,
diff --git a/cpp/src/Glacier2/RouterI.cpp b/cpp/src/Glacier2/RouterI.cpp
index 058b1bf7104..b0624578d41 100644
--- a/cpp/src/Glacier2/RouterI.cpp
+++ b/cpp/src/Glacier2/RouterI.cpp
@@ -65,7 +65,7 @@ Glacier2::RouterI::~RouterI()
}
void
-Glacier2::RouterI::destroy(const AMI_Session_destroyPtr& amiCB)
+Glacier2::RouterI::destroy(const Callback_Session_destroyPtr& asyncCB)
{
if(_session)
{
@@ -91,11 +91,11 @@ Glacier2::RouterI::destroy(const AMI_Session_destroyPtr& amiCB)
if(_context.size() > 0)
{
- _session->destroy_async(amiCB, _context);
+ _session->begin_destroy(_context, asyncCB);
}
else
{
- _session->destroy_async(amiCB);
+ _session->begin_destroy(asyncCB);
}
}
diff --git a/cpp/src/Glacier2/RouterI.h b/cpp/src/Glacier2/RouterI.h
index 619ef513b48..30ddb91024e 100644
--- a/cpp/src/Glacier2/RouterI.h
+++ b/cpp/src/Glacier2/RouterI.h
@@ -32,7 +32,7 @@ public:
const FilterManagerPtr&, const Ice::Context&);
virtual ~RouterI();
- void destroy(const AMI_Session_destroyPtr&);
+ void destroy(const Callback_Session_destroyPtr&);
virtual Ice::ObjectPrx getClientProxy(const Ice::Current& = Ice::Current()) const;
virtual Ice::ObjectPrx getServerProxy(const Ice::Current& = Ice::Current()) const;
diff --git a/cpp/src/Glacier2/SessionRouterI.cpp b/cpp/src/Glacier2/SessionRouterI.cpp
index 0764521248b..6f4546a5463 100644
--- a/cpp/src/Glacier2/SessionRouterI.cpp
+++ b/cpp/src/Glacier2/SessionRouterI.cpp
@@ -21,6 +21,7 @@
using namespace std;
using namespace Ice;
+using namespace Glacier2;
namespace Glacier2
{
@@ -146,48 +147,33 @@ public:
_password(password)
{
}
+
- class CheckPermissionsCB : public AMI_PermissionsVerifier_checkPermissions
+ void
+ checkPermissionsResponse(bool ok, const string& reason)
{
- public:
-
- CheckPermissionsCB(const UserPasswordCreateSessionPtr& session, bool hasSessionManager) :
- _session(session),
- _hasSessionManager(hasSessionManager)
+ if(ok)
{
+ authorized(_sessionRouter->_sessionManager);
}
-
- virtual void
- ice_response(bool ok, const string& reason)
+ else
{
- if(ok)
- {
- _session->authorized(_hasSessionManager);
- }
- else
- {
- _session->exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason));
- }
+ exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason));
}
+ }
- virtual void
- ice_exception(const Ice::Exception& ex)
+ void
+ checkPermissionsException(const Ice::Exception& ex)
+ {
+ if(dynamic_cast<const CollocationOptimizationException*>(&ex))
{
- if(dynamic_cast<const CollocationOptimizationException*>(&ex))
- {
- _session->authorizeCollocated();
- }
- else
- {
- _session->unexpectedAuthorizeException(ex);
- }
+ authorizeCollocated();
}
-
- private:
-
- const UserPasswordCreateSessionPtr _session;
- const bool _hasSessionManager;
- };
+ else
+ {
+ unexpectedAuthorizeException(ex);
+ }
+ }
virtual void
authorize()
@@ -196,8 +182,11 @@ public:
Ice::Context ctx = _current.ctx;
ctx.insert(_context.begin(), _context.end());
- AMI_PermissionsVerifier_checkPermissionsPtr cb = new CheckPermissionsCB(this, _sessionRouter->_sessionManager);
- _sessionRouter->_verifier->checkPermissions_async(cb, _user, _password, ctx);
+
+ _sessionRouter->_verifier->begin_checkPermissions(_user, _password, ctx,
+ newCallback_PermissionsVerifier_checkPermissions(this,
+ &UserPasswordCreateSession::checkPermissionsResponse,
+ &UserPasswordCreateSession::checkPermissionsException));
}
virtual void
@@ -229,48 +218,16 @@ public:
return FilterManager::create(_instance, _user, true);
}
- class CreateCB : public AMI_SessionManager_create
- {
- public:
-
- CreateCB(const CreateSessionPtr& session) : _session(session)
- {
- }
-
- virtual void
- ice_response(const SessionPrx& session)
- {
- _session->sessionCreated(session);
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- try
- {
- ex.ice_throw();
- }
- catch(const CannotCreateSessionException& ex)
- {
- _session->exception(ex);
- }
- catch(const Ice::Exception& ex)
- {
- _session->unexpectedCreateSessionException(ex);
- }
- }
-
- private:
-
- const CreateSessionPtr _session;
- };
-
virtual void
createSession()
{
Ice::Context ctx = _current.ctx;
ctx.insert(_context.begin(), _context.end());
- _sessionRouter->_sessionManager->create_async(new CreateCB(this), _user, _control, ctx);
+ _sessionRouter->_sessionManager->begin_create(_user, _control, ctx,
+ newCallback_SessionManager_create(
+ static_cast<CreateSession*>(this),
+ &CreateSession::sessionCreated,
+ &CreateSession::createException));
}
virtual void
@@ -302,49 +259,32 @@ public:
_sslInfo(sslInfo)
{
}
-
- class AuthorizeCB : public AMI_SSLPermissionsVerifier_authorize
+
+ void
+ authorizeResponse(bool ok, const string& reason)
{
- public:
-
- AuthorizeCB(const SSLCreateSessionPtr& session, bool hasSessionManager) :
- _session(session),
- _hasSessionManager(hasSessionManager)
+ if(ok)
{
+ authorized(_sessionRouter->_sslSessionManager);
}
-
- virtual void
- ice_response(bool ok, const string& reason)
+ else
{
- if(ok)
- {
- _session->authorized(_hasSessionManager);
- }
- else
- {
- _session->exception(PermissionDeniedException(reason.empty() ? string("permission denied")
- : reason));
- }
+ exception(PermissionDeniedException(reason.empty() ? string("permission denied") : reason));
}
+ }
- virtual void
- ice_exception(const Ice::Exception& ex)
+ void
+ authorizeException(const Ice::Exception& ex)
+ {
+ if(dynamic_cast<const CollocationOptimizationException*>(&ex))
{
- if(dynamic_cast<const CollocationOptimizationException*>(&ex))
- {
- _session->authorizeCollocated();
- }
- else
- {
- _session->unexpectedAuthorizeException(ex);
- }
+ authorizeCollocated();
}
-
- private:
-
- const SSLCreateSessionPtr _session;
- const bool _hasSessionManager;
- };
+ else
+ {
+ unexpectedAuthorizeException(ex);
+ }
+ }
virtual void
authorize()
@@ -353,9 +293,10 @@ public:
Ice::Context ctx = _current.ctx;
ctx.insert(_context.begin(), _context.end());
-
- AMI_SSLPermissionsVerifier_authorizePtr cb = new AuthorizeCB(this, _sessionRouter->_sslSessionManager);
- _sessionRouter->_sslVerifier->authorize_async(cb, _sslInfo, ctx);
+ _sessionRouter->_sslVerifier->begin_authorize(_sslInfo, ctx,
+ newCallback_SSLPermissionsVerifier_authorize(this,
+ &SSLCreateSession::authorizeResponse,
+ &SSLCreateSession::authorizeException));
}
virtual void
@@ -387,48 +328,16 @@ public:
return FilterManager::create(_instance, _user, false);
}
- class CreateCB : public AMI_SSLSessionManager_create
- {
- public:
-
- CreateCB(const CreateSessionPtr& session) : _session(session)
- {
- }
-
- virtual void
- ice_response(const SessionPrx& session)
- {
- _session->sessionCreated(session);
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- try
- {
- ex.ice_throw();
- }
- catch(const CannotCreateSessionException& ex)
- {
- _session->exception(ex);
- }
- catch(const Ice::Exception& ex)
- {
- _session->unexpectedCreateSessionException(ex);
- }
- }
-
- private:
-
- const CreateSessionPtr _session;
- };
-
virtual void
createSession()
{
Ice::Context ctx = _current.ctx;
ctx.insert(_context.begin(), _context.end());
- _sessionRouter->_sslSessionManager->create_async(new CreateCB(this), _sslInfo, _control, ctx);
+ _sessionRouter->_sslSessionManager->begin_create(_sslInfo, _control, ctx,
+ newCallback_SSLSessionManager_create(
+ static_cast<CreateSession*>(this),
+ &CreateSession::sessionCreated,
+ &CreateSession::createException));
}
virtual void
@@ -449,44 +358,9 @@ private:
const SSLInfo _sslInfo;
};
-class DestroyCB : public AMI_Session_destroy
-{
-public:
-
- DestroyCB(int traceLevel, const LoggerPtr& logger)
- {
- if(traceLevel > 0)
- {
- _logger = logger;
- }
- }
-
- virtual void
- ice_response()
- {
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- if(_logger)
- {
- Trace out(_logger, "Glacier2");
- out << "exception while destroying session\n" << ex;
- }
- }
-
-private:
-
- LoggerPtr _logger;
-};
-
}
-using namespace Glacier2;
-
-Glacier2::CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const string& user,
- const Ice::Current& current) :
+CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, const string& user, const Ice::Current& current) :
_instance(sessionRouter->_instance),
_sessionRouter(sessionRouter),
_user(user),
@@ -523,7 +397,7 @@ Glacier2::CreateSession::CreateSession(const SessionRouterIPtr& sessionRouter, c
}
void
-Glacier2::CreateSession::create()
+CreateSession::create()
{
try
{
@@ -539,13 +413,13 @@ Glacier2::CreateSession::create()
}
void
-Glacier2::CreateSession::addPendingCallback(const CreateSessionPtr& callback)
+CreateSession::addPendingCallback(const CreateSessionPtr& callback)
{
_pendingCallbacks.push_back(callback);
}
void
-Glacier2::CreateSession::authorized(bool createSession)
+CreateSession::authorized(bool createSession)
{
//
// Create the filter manager now as it's required for the session control object.
@@ -572,7 +446,7 @@ Glacier2::CreateSession::authorized(bool createSession)
}
void
-Glacier2::CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex)
+CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex)
{
if(_sessionRouter->sessionTraceLevel() >= 1)
{
@@ -583,7 +457,24 @@ Glacier2::CreateSession::unexpectedAuthorizeException(const Ice::Exception& ex)
}
void
-Glacier2::CreateSession::sessionCreated(const SessionPrx& session)
+CreateSession::createException(const Ice::Exception& ex)
+{
+ try
+ {
+ ex.ice_throw();
+ }
+ catch(const CannotCreateSessionException& ex)
+ {
+ exception(ex);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ unexpectedCreateSessionException(ex);
+ }
+}
+
+void
+CreateSession::sessionCreated(const SessionPrx& session)
{
//
// Create the session router object.
@@ -633,7 +524,7 @@ Glacier2::CreateSession::sessionCreated(const SessionPrx& session)
{
if(session)
{
- session->destroy_async(new DestroyCB(0, 0));
+ session->begin_destroy();
}
unexpectedCreateSessionException(ex);
return;
@@ -659,7 +550,7 @@ Glacier2::CreateSession::sessionCreated(const SessionPrx& session)
}
void
-Glacier2::CreateSession::unexpectedCreateSessionException(const Ice::Exception& ex)
+CreateSession::unexpectedCreateSessionException(const Ice::Exception& ex)
{
if(_sessionRouter->sessionTraceLevel() >= 1)
{
@@ -670,7 +561,7 @@ Glacier2::CreateSession::unexpectedCreateSessionException(const Ice::Exception&
}
void
-Glacier2::CreateSession::exception(const Ice::Exception& ex)
+CreateSession::exception(const Ice::Exception& ex)
{
try
{
@@ -699,11 +590,11 @@ Glacier2::CreateSession::exception(const Ice::Exception& ex)
}
}
-Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance,
- const PermissionsVerifierPrx& verifier,
- const SessionManagerPrx& sessionManager,
- const SSLPermissionsVerifierPrx& sslVerifier,
- const SSLSessionManagerPrx& sslSessionManager) :
+SessionRouterI::SessionRouterI(const InstancePtr& instance,
+ const PermissionsVerifierPrx& verifier,
+ const SessionManagerPrx& sessionManager,
+ const SSLPermissionsVerifierPrx& sslVerifier,
+ const SSLSessionManagerPrx& sslSessionManager) :
_instance(instance),
_sessionTraceLevel(_instance->properties()->getPropertyAsInt("Glacier2.Trace.Session")),
_rejectTraceLevel(_instance->properties()->getPropertyAsInt("Glacier2.Client.Trace.Reject")),
@@ -716,6 +607,7 @@ Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance,
_routersByConnectionHint(_routersByConnection.end()),
_routersByCategoryHint(_routersByCategory.end()),
_sessionPingCallback(newCallback_Object_ice_ping(this, &SessionRouterI::sessionPingException)),
+ _sessionDestroyCallback(newCallback_Session_destroy(this, &SessionRouterI::sessionDestroyException)),
_destroy(false)
{
@@ -772,7 +664,7 @@ Glacier2::SessionRouterI::SessionRouterI(const InstancePtr& instance,
_instance->setSessionRouter(this);
}
-Glacier2::SessionRouterI::~SessionRouterI()
+SessionRouterI::~SessionRouterI()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -784,11 +676,11 @@ Glacier2::SessionRouterI::~SessionRouterI()
}
void
-Glacier2::SessionRouterI::destroy()
+SessionRouterI::destroy()
{
map<ConnectionPtr, RouterIPtr> routers;
SessionThreadPtr sessionThread;
-
+ Callback_Session_destroyPtr destroyCallback;
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -805,6 +697,7 @@ Glacier2::SessionRouterI::destroy()
sessionThread = _sessionThread;
_sessionThread = 0;
+ swap(destroyCallback, _sessionDestroyCallback); // Break cyclic reference count.
_sessionPingCallback = 0; // Break cyclic reference count.
}
@@ -814,7 +707,7 @@ Glacier2::SessionRouterI::destroy()
//
for(map<ConnectionPtr, RouterIPtr>::iterator p = routers.begin(); p != routers.end(); ++p)
{
- p->second->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger()));
+ p->second->destroy(destroyCallback);
}
if(sessionThread)
@@ -825,19 +718,19 @@ Glacier2::SessionRouterI::destroy()
}
ObjectPrx
-Glacier2::SessionRouterI::getClientProxy(const Current& current) const
+SessionRouterI::getClientProxy(const Current& current) const
{
return getRouter(current.con, current.id)->getClientProxy(current); // Forward to the per-client router.
}
ObjectPrx
-Glacier2::SessionRouterI::getServerProxy(const Current& current) const
+SessionRouterI::getServerProxy(const Current& current) const
{
return getRouter(current.con, current.id)->getServerProxy(current); // Forward to the per-client router.
}
void
-Glacier2::SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& current)
+SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& current)
{
ObjectProxySeq seq;
seq.push_back(proxy);
@@ -845,7 +738,7 @@ Glacier2::SessionRouterI::addProxy(const ObjectPrx& proxy, const Current& curren
}
ObjectProxySeq
-Glacier2::SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Current& current)
+SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Current& current)
{
//
// Forward to the per-client router.
@@ -854,7 +747,7 @@ Glacier2::SessionRouterI::addProxies(const ObjectProxySeq& proxies, const Curren
}
string
-Glacier2::SessionRouterI::getCategoryForClient(const Ice::Current& current) const
+SessionRouterI::getCategoryForClient(const Ice::Current& current) const
{
// Forward to the per-client router.
if(_instance->serverObjectAdapter())
@@ -868,7 +761,7 @@ Glacier2::SessionRouterI::getCategoryForClient(const Ice::Current& current) cons
}
void
-Glacier2::SessionRouterI::createSession_async(const AMD_Router_createSessionPtr& amdCB, const std::string& userId,
+SessionRouterI::createSession_async(const AMD_Router_createSessionPtr& amdCB, const std::string& userId,
const std::string& password, const Current& current)
{
if(!_verifier)
@@ -882,7 +775,7 @@ Glacier2::SessionRouterI::createSession_async(const AMD_Router_createSessionPtr&
}
void
-Glacier2::SessionRouterI::createSessionFromSecureConnection_async(
+SessionRouterI::createSessionFromSecureConnection_async(
const AMD_Router_createSessionFromSecureConnectionPtr& amdCB, const Current& current)
{
if(!_sslVerifier)
@@ -932,13 +825,13 @@ Glacier2::SessionRouterI::createSessionFromSecureConnection_async(
}
void
-Glacier2::SessionRouterI::destroySession(const Current& current)
+SessionRouterI::destroySession(const Current& current)
{
destroySession(current.con);
}
void
-Glacier2::SessionRouterI::refreshSession(const Ice::Current& current)
+SessionRouterI::refreshSession(const Ice::Current& current)
{
RouterIPtr router = getRouter(current.con, current.id, false);
if(!router)
@@ -951,7 +844,7 @@ Glacier2::SessionRouterI::refreshSession(const Ice::Current& current)
// Ping the session to ensure it does not timeout.
//
assert(_sessionPingCallback);
- Glacier2::SessionPrx session = router->getSession();
+ SessionPrx session = router->getSession();
if(session)
{
session->begin_ice_ping(_sessionPingCallback, current.con);
@@ -959,7 +852,7 @@ Glacier2::SessionRouterI::refreshSession(const Ice::Current& current)
}
void
-Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection)
+SessionRouterI::destroySession(const ConnectionPtr& connection)
{
RouterIPtr router;
@@ -1010,18 +903,17 @@ Glacier2::SessionRouterI::destroySession(const ConnectionPtr& connection)
Trace out(_instance->logger(), "Glacier2");
out << "destroying session\n" << router->toString();
}
-
- router->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger()));
+ router->destroy(_sessionDestroyCallback);
}
Ice::Long
-Glacier2::SessionRouterI::getSessionTimeout(const Ice::Current&) const
+SessionRouterI::getSessionTimeout(const Ice::Current&) const
{
return _sessionTimeout.toSeconds();
}
RouterIPtr
-Glacier2::SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const
+SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::Identity& id, bool close) const
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -1059,7 +951,7 @@ Glacier2::SessionRouterI::getRouter(const ConnectionPtr& connection, const Ice::
}
RouterIPtr
-Glacier2::SessionRouterI::getRouter(const string& category) const
+SessionRouterI::getRouter(const string& category) const
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -1089,7 +981,7 @@ Glacier2::SessionRouterI::getRouter(const string& category) const
}
void
-Glacier2::SessionRouterI::expireSessions()
+SessionRouterI::expireSessions()
{
vector<RouterIPtr> routers;
@@ -1142,19 +1034,29 @@ Glacier2::SessionRouterI::expireSessions()
Trace out(_instance->logger(), "Glacier2");
out << "expiring session\n" << (*p)->toString();
}
-
- (*p)->destroy(new DestroyCB(_sessionTraceLevel, _instance->logger()));
+ (*p)->destroy(_sessionDestroyCallback);
}
}
void
-Glacier2::SessionRouterI::sessionPingException(const Ice::Exception&, const Ice::ConnectionPtr& con)
+SessionRouterI::sessionPingException(const Ice::Exception&, const Ice::ConnectionPtr& con)
{
destroySession(con);
}
+void
+SessionRouterI::sessionDestroyException(const Ice::Exception& ex)
+{
+ if(_sessionTraceLevel > 0)
+ {
+ Trace out(_instance->logger(), "Glacier2");
+ out << "exception while destroying session\n" << ex;
+ }
+}
+
+
bool
-Glacier2::SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const ConnectionPtr& connection)
+SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const ConnectionPtr& connection)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -1211,7 +1113,7 @@ Glacier2::SessionRouterI::startCreateSession(const CreateSessionPtr& cb, const C
}
void
-Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, const RouterIPtr& router)
+SessionRouterI::finishCreateSession(const ConnectionPtr& connection, const RouterIPtr& router)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -1229,7 +1131,7 @@ Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, c
if(_destroy)
{
- router->destroy(new DestroyCB(0, 0));
+ router->destroy(_sessionDestroyCallback);
CannotCreateSessionException exc;
exc.reason = "router is shutting down";
@@ -1256,7 +1158,7 @@ Glacier2::SessionRouterI::finishCreateSession(const ConnectionPtr& connection, c
}
}
-Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter,
+SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr& sessionRouter,
const IceUtil::Time& sessionTimeout) :
IceUtil::Thread("Glacier2 session thread"),
_sessionRouter(sessionRouter),
@@ -1264,13 +1166,13 @@ Glacier2::SessionRouterI::SessionThread::SessionThread(const SessionRouterIPtr&
{
}
-Glacier2::SessionRouterI::SessionThread::~SessionThread()
+SessionRouterI::SessionThread::~SessionThread()
{
assert(!_sessionRouter);
}
void
-Glacier2::SessionRouterI::SessionThread::destroy()
+SessionRouterI::SessionThread::destroy()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
_sessionRouter = 0;
@@ -1278,7 +1180,7 @@ Glacier2::SessionRouterI::SessionThread::destroy()
}
void
-Glacier2::SessionRouterI::SessionThread::run()
+SessionRouterI::SessionThread::run()
{
while(true)
{
diff --git a/cpp/src/Glacier2/SessionRouterI.h b/cpp/src/Glacier2/SessionRouterI.h
index a494d1158bf..ecf6ff120fc 100644
--- a/cpp/src/Glacier2/SessionRouterI.h
+++ b/cpp/src/Glacier2/SessionRouterI.h
@@ -51,6 +51,8 @@ public:
void unexpectedCreateSessionException(const Ice::Exception&);
void exception(const Ice::Exception&);
+
+ void createException(const Ice::Exception&);
virtual void authorize() = 0;
virtual void createSession() = 0;
@@ -110,6 +112,7 @@ public:
private:
void sessionPingException(const Ice::Exception&, const ::Ice::ConnectionPtr&);
+ void sessionDestroyException(const Ice::Exception&);
bool startCreateSession(const CreateSessionPtr&, const Ice::ConnectionPtr&);
void finishCreateSession(const Ice::ConnectionPtr&, const RouterIPtr&);
@@ -153,6 +156,7 @@ private:
std::map<Ice::ConnectionPtr, CreateSessionPtr> _pending;
Ice::Callback_Object_ice_pingPtr _sessionPingCallback;
+ Callback_Session_destroyPtr _sessionDestroyCallback;
bool _destroy;
};
diff --git a/cpp/src/Glacier2Lib/Application.cpp b/cpp/src/Glacier2Lib/Application.cpp
index 8b62671a3d9..806071206be 100644
--- a/cpp/src/Glacier2Lib/Application.cpp
+++ b/cpp/src/Glacier2Lib/Application.cpp
@@ -23,73 +23,44 @@ string Glacier2::Application::_category;
namespace
{
-class SessionPingThread : virtual public IceUtil::Shared
+class SessionPingThreadI : virtual public IceUtil::Thread
{
public:
- virtual void done() = 0;
-};
-typedef IceUtil::Handle<SessionPingThread> SessionPingThreadPtr;
-
-class AMI_Router_refreshSessionI : public Glacier2::AMI_Router_refreshSession
-{
-
-public:
-
- AMI_Router_refreshSessionI(Glacier2::Application* app, const SessionPingThreadPtr& pinger) :
+ SessionPingThreadI(Glacier2::Application* app, const Glacier2::RouterPrx& router, IceUtil::Int64 period) :
_app(app),
- _pinger(pinger)
- {
- }
-
- void
- ice_response()
+ _router(router),
+ _period(period),
+ _done(false)
{
+ assert(_period);
}
void
- ice_exception(const Ice::Exception& ex)
+ exception(const Ice::Exception& ex)
{
//
- // Here the session has gone. The thread
- // terminates, and we notify the
- // application that the session has been
+ // Here the session has been destroyed. The thread terminates,
+ // and we notify the application that the session has been
// destroyed.
//
- _pinger->done();
+ done();
_app->sessionDestroyed();
}
-private:
-
- Glacier2::Application* _app;
- SessionPingThreadPtr _pinger;
-};
-
-class SessionPingThreadI : virtual public IceUtil::Thread, virtual public SessionPingThread
-{
-
-public:
-
- SessionPingThreadI(Glacier2::Application* app, const Glacier2::RouterPrx& router, IceUtil::Int64 period) :
- _app(app),
- _router(router),
- _period(period),
- _done(false)
- {
- assert(_period);
- }
-
void
run()
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
+
+ Glacier2::Callback_Router_refreshSessionPtr callback =
+ Glacier2::newCallback_Router_refreshSession(this, &SessionPingThreadI::exception);
while(true)
{
try
{
- _router->refreshSession_async(new AMI_Router_refreshSessionI(_app, this));
+ _router->begin_refreshSession(callback);
}
catch(const Ice::CommunicatorDestroyedException&)
{
@@ -140,7 +111,7 @@ Glacier2::RestartSessionException::ice_name() const
return "RestartSessionException";
}
-Exception*
+Glacier2::RestartSessionException*
Glacier2::RestartSessionException::ice_clone() const
{
return new RestartSessionException(*this);
diff --git a/cpp/src/Glacier2Lib/SessionHelper.cpp b/cpp/src/Glacier2Lib/SessionHelper.cpp
index 046cc984d11..31cfc92fbee 100644
--- a/cpp/src/Glacier2Lib/SessionHelper.cpp
+++ b/cpp/src/Glacier2Lib/SessionHelper.cpp
@@ -70,7 +70,6 @@ public:
private:
- const Glacier2::Callback_Router_refreshSessionPtr _cb;
const Glacier2::SessionHelperPtr _session;
const Glacier2::RouterPrx _router;
Ice::Long _period;
@@ -130,8 +129,6 @@ typedef IceUtil::Handle<SessionHelperI> SessionHelperIPtr;
SessionRefreshThread::SessionRefreshThread(const Glacier2::SessionHelperPtr& session,
const Glacier2::RouterPrx& router, Ice::Long period) :
- _cb(Glacier2::newCallback_Router_refreshSession(this, &SessionRefreshThread::success,
- &SessionRefreshThread::failure)),
_session(session),
_router(router),
_period(period),
@@ -142,12 +139,14 @@ SessionRefreshThread::SessionRefreshThread(const Glacier2::SessionHelperPtr& ses
void
SessionRefreshThread::run()
{
+ Glacier2::Callback_Router_refreshSessionPtr cb =
+ Glacier2::newCallback_Router_refreshSession(this, &SessionRefreshThread::failure);
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
while(true)
{
try
{
- _router->begin_refreshSession(_cb);
+ _router->begin_refreshSession(cb);
}
catch(const Ice::CommunicatorDestroyedException&)
{
@@ -181,11 +180,6 @@ SessionRefreshThread::done()
}
void
-SessionRefreshThread::success()
-{
-}
-
-void
SessionRefreshThread::failure(const Ice::Exception&)
{
done();
@@ -517,7 +511,7 @@ public:
_callback(callback),
_session(session)
{
- _ex.reset(dynamic_cast<Ice::Exception*>(ex.ice_clone()));
+ _ex.reset(ex.ice_clone());
}
virtual void
diff --git a/cpp/src/Ice/CommunicatorI.cpp b/cpp/src/Ice/CommunicatorI.cpp
index a54c8bfb9b0..25762041b06 100644
--- a/cpp/src/Ice/CommunicatorI.cpp
+++ b/cpp/src/Ice/CommunicatorI.cpp
@@ -310,20 +310,20 @@ Ice::CommunicatorI::flushBatchRequests()
AsyncResultPtr
Ice::CommunicatorI::begin_flushBatchRequests()
{
- return begin_flushBatchRequestsInternal(::IceInternal::__dummyCallback, 0);
+ return __begin_flushBatchRequests(::IceInternal::__dummyCallback, 0);
}
AsyncResultPtr
Ice::CommunicatorI::begin_flushBatchRequests(const CallbackPtr& cb, const LocalObjectPtr& cookie)
{
- return begin_flushBatchRequestsInternal(cb, cookie);
+ return __begin_flushBatchRequests(cb, cookie);
}
AsyncResultPtr
Ice::CommunicatorI::begin_flushBatchRequests(const Callback_Communicator_flushBatchRequestsPtr& cb,
const LocalObjectPtr& cookie)
{
- return begin_flushBatchRequestsInternal(cb, cookie);
+ return __begin_flushBatchRequests(cb, cookie);
}
namespace
@@ -334,7 +334,7 @@ const ::std::string __flushBatchRequests_name = "flushBatchRequests";
}
AsyncResultPtr
-Ice::CommunicatorI::begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr& cb,
+Ice::CommunicatorI::__begin_flushBatchRequests(const IceInternal::CallbackBasePtr& cb,
const LocalObjectPtr& cookie)
{
OutgoingConnectionFactoryPtr connectionFactory = _instance->outgoingConnectionFactory();
diff --git a/cpp/src/Ice/CommunicatorI.h b/cpp/src/Ice/CommunicatorI.h
index dd21e0b941b..d9628478707 100644
--- a/cpp/src/Ice/CommunicatorI.h
+++ b/cpp/src/Ice/CommunicatorI.h
@@ -14,6 +14,7 @@
#include <Ice/DynamicLibraryF.h>
#include <Ice/Initialize.h>
#include <Ice/Communicator.h>
+#include <Ice/CommunicatorAsync.h>
namespace Ice
{
@@ -60,6 +61,15 @@ public:
virtual void flushBatchRequests();
+#ifdef ICE_CPP11
+ virtual ::Ice::AsyncResultPtr begin_flushBatchRequests(
+ const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception,
+ const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>())
+ {
+ return __begin_flushBatchRequests(new Cpp11FnCallbackNC_Communicator_flushBatchRequests(exception, sent), 0);
+ }
+#endif
+
virtual AsyncResultPtr begin_flushBatchRequests();
virtual AsyncResultPtr begin_flushBatchRequests(const CallbackPtr&, const LocalObjectPtr& = 0);
virtual AsyncResultPtr begin_flushBatchRequests(const Callback_Communicator_flushBatchRequestsPtr&,
@@ -86,7 +96,7 @@ private:
friend ICE_API CommunicatorPtr initialize(const InitializationData&, Int);
friend ICE_API ::IceInternal::InstancePtr IceInternal::getInstance(const ::Ice::CommunicatorPtr&);
- AsyncResultPtr begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&);
+ AsyncResultPtr __begin_flushBatchRequests(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&);
const ::IceInternal::InstancePtr _instance;
diff --git a/cpp/src/Ice/ConnectRequestHandler.cpp b/cpp/src/Ice/ConnectRequestHandler.cpp
index c04164af0d4..3d35eb40c10 100644
--- a/cpp/src/Ice/ConnectRequestHandler.cpp
+++ b/cpp/src/Ice/ConnectRequestHandler.cpp
@@ -34,7 +34,7 @@ public:
const Ice::LocalException& ex) :
DispatchWorkItem(instance),
_handler(handler),
- _exception(dynamic_cast<Ice::LocalException*>(ex.ice_clone()))
+ _exception(ex.ice_clone())
{
}
@@ -328,7 +328,7 @@ ConnectRequestHandler::setException(const Ice::LocalException& ex)
assert(!_initialized && !_exception.get());
assert(_updateRequestHandler || _requests.empty());
- _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
_proxy = 0; // Break cyclic reference count.
_delegate = 0; // Break cyclic reference count.
@@ -451,7 +451,7 @@ ConnectRequestHandler::flushRequests()
{
Lock sync(*this);
assert(!_exception.get() && !_requests.empty());
- _exception.reset(dynamic_cast<Ice::LocalException*>(ex.get()->ice_clone()));
+ _exception.reset(ex.get()->ice_clone());
const InstancePtr instance = _reference->getInstance();
instance->clientThreadPool()->execute(new FlushRequestsWithExceptionWrapper(instance, this, ex));
}
@@ -459,7 +459,7 @@ ConnectRequestHandler::flushRequests()
{
Lock sync(*this);
assert(!_exception.get() && !_requests.empty());
- _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
const InstancePtr instance = _reference->getInstance();
instance->clientThreadPool()->execute(new FlushRequestsWithException(instance, this, ex));
}
diff --git a/cpp/src/Ice/ConnectionFactory.cpp b/cpp/src/Ice/ConnectionFactory.cpp
index 3759ca19abe..2869d610748 100755
--- a/cpp/src/Ice/ConnectionFactory.cpp
+++ b/cpp/src/Ice/ConnectionFactory.cpp
@@ -206,7 +206,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
}
catch(const Ice::LocalException& ex)
{
- exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ exception.reset(ex.ice_clone());
handleException(ex, hasMore || p != endpoints.end() - 1);
}
}
@@ -276,7 +276,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
observer->failed(ex.ice_name());
observer->detach();
}
- exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ exception.reset(ex.ice_clone());
handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1);
connection = 0;
break; // No need to continue
@@ -288,7 +288,7 @@ IceInternal::OutgoingConnectionFactory::create(const vector<EndpointIPtr>& endpt
observer->failed(ex.ice_name());
observer->detach();
}
- exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ exception.reset(ex.ice_clone());
handleConnectionException(*exception.get(), hasMore || q != connectors.end() - 1);
connection = 0;
}
diff --git a/cpp/src/Ice/ConnectionI.cpp b/cpp/src/Ice/ConnectionI.cpp
index afc70dcf85f..fb38a16bc8a 100644
--- a/cpp/src/Ice/ConnectionI.cpp
+++ b/cpp/src/Ice/ConnectionI.cpp
@@ -924,7 +924,7 @@ Ice::ConnectionI::flushBatchRequests()
AsyncResultPtr
Ice::ConnectionI::begin_flushBatchRequests()
{
- return begin_flushBatchRequestsInternal(__dummyCallback, 0);
+ return __begin_flushBatchRequests(__dummyCallback, 0);
}
namespace
@@ -937,18 +937,18 @@ const ::std::string __flushBatchRequests_name = "flushBatchRequests";
AsyncResultPtr
Ice::ConnectionI::begin_flushBatchRequests(const CallbackPtr& cb, const LocalObjectPtr& cookie)
{
- return begin_flushBatchRequestsInternal(cb, cookie);
+ return __begin_flushBatchRequests(cb, cookie);
}
AsyncResultPtr
Ice::ConnectionI::begin_flushBatchRequests(const Callback_Connection_flushBatchRequestsPtr& cb,
const LocalObjectPtr& cookie)
{
- return begin_flushBatchRequestsInternal(cb, cookie);
+ return __begin_flushBatchRequests(cb, cookie);
}
AsyncResultPtr
-Ice::ConnectionI::begin_flushBatchRequestsInternal(const CallbackBasePtr& cb, const LocalObjectPtr& cookie)
+Ice::ConnectionI::__begin_flushBatchRequests(const CallbackBasePtr& cb, const LocalObjectPtr& cookie)
{
ConnectionBatchOutgoingAsyncPtr result =
new ConnectionBatchOutgoingAsync(this, _communicator, _instance, __flushBatchRequests_name, cb, cookie);
@@ -2018,7 +2018,7 @@ Ice::ConnectionI::setState(State state, const LocalException& ex)
//
assert(_state != StateClosed);
- _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
if(_warn)
{
diff --git a/cpp/src/Ice/ConnectionI.h b/cpp/src/Ice/ConnectionI.h
index 9fef29ea74e..57fd34d3e5f 100644
--- a/cpp/src/Ice/ConnectionI.h
+++ b/cpp/src/Ice/ConnectionI.h
@@ -31,6 +31,7 @@
#include <Ice/EventHandler.h>
#include <Ice/Dispatcher.h>
#include <Ice/ObserverHelper.h>
+#include <Ice/ConnectionAsync.h>
#include <deque>
#include <memory>
@@ -129,6 +130,15 @@ public:
void abortBatchRequest();
virtual void flushBatchRequests(); // From Connection.
+
+#ifdef ICE_CPP11
+ virtual ::Ice::AsyncResultPtr begin_flushBatchRequests(
+ const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception,
+ const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>())
+ {
+ return __begin_flushBatchRequests(new Cpp11FnCallbackNC_Connection_flushBatchRequests(exception, sent), 0);
+ }
+#endif
virtual AsyncResultPtr begin_flushBatchRequests();
virtual AsyncResultPtr begin_flushBatchRequests(const CallbackPtr&, const LocalObjectPtr& = 0);
@@ -294,7 +304,7 @@ private:
int connectTimeout();
int closeTimeout();
- AsyncResultPtr begin_flushBatchRequestsInternal(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&);
+ AsyncResultPtr __begin_flushBatchRequests(const IceInternal::CallbackBasePtr&, const LocalObjectPtr&);
Ice::CommunicatorPtr _communicator;
const IceInternal::InstancePtr _instance;
diff --git a/cpp/src/Ice/Direct.cpp b/cpp/src/Ice/Direct.cpp
index 64f61790abe..9c4d906d9ec 100644
--- a/cpp/src/Ice/Direct.cpp
+++ b/cpp/src/Ice/Direct.cpp
@@ -107,7 +107,7 @@ IceInternal::Direct::throwUserException()
void
IceInternal::Direct::setUserException(const Ice::UserException& ue)
{
- _userException.reset(dynamic_cast<Ice::UserException*>(ue.ice_clone()));
+ _userException.reset(ue.ice_clone());
}
void
diff --git a/cpp/src/Ice/DynamicLibrary.cpp b/cpp/src/Ice/DynamicLibrary.cpp
index 5b690df5f2b..ab724a9847a 100644
--- a/cpp/src/Ice/DynamicLibrary.cpp
+++ b/cpp/src/Ice/DynamicLibrary.cpp
@@ -50,7 +50,28 @@ IceInternal::DynamicLibrary::~DynamicLibrary()
IceInternal::DynamicLibrary::symbol_type
IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIceVersion)
{
+
+#ifdef _WIN32
+ bool isFilePath = entryPoint.find('\\') != string::npos || entryPoint.find('/') != string::npos;
+#else
+ bool isFilePath = entryPoint.find('/') != string::npos;
+#endif
+
string::size_type colon = entryPoint.rfind(':');
+
+#ifdef _WIN32
+ const string driveLetters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ if(colon == 1 && driveLetters.find(entryPoint[0]) != string::npos &&
+ (entryPoint[2] == '\\' || entryPoint[2] == '/'))
+ {
+ //
+ // The only colon we found is in the drive specification, as in "C:\MyDir".
+ // This means the function name is missing.
+ //
+ colon = string::npos;
+ }
+#endif
+
string::size_type comma = entryPoint.find(',');
if(colon == string::npos || colon == entryPoint.size() - 1 ||
(comma != string::npos && (comma > colon || comma == colon - 1)))
@@ -58,9 +79,22 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
_err = "invalid entry point format `" + entryPoint + "'";
return 0;
}
+
string libSpec = entryPoint.substr(0, colon);
string funcName = entryPoint.substr(colon + 1);
- string libName, version, debug;
+ string libPath, libName, version, debug;
+
+ if(isFilePath)
+ {
+#ifdef _WIN32
+ string::size_type separator = entryPoint.find_last_of("/\\");
+#else
+ string::size_type separator = entryPoint.rfind('/');
+#endif
+ libPath = libSpec.substr(0, separator + 1);
+ libSpec = libSpec.substr(separator + 1);
+ }
+
if(comma == string::npos)
{
libName = libSpec;
@@ -70,7 +104,7 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
int minorVersion = (ICE_INT_VERSION / 100) - majorVersion * 100;
ostringstream os;
os << majorVersion * 10 + minorVersion;
-
+
int patchVersion = ICE_INT_VERSION % 100;
if(patchVersion > 50)
{
@@ -89,10 +123,10 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
version = libSpec.substr(comma + 1);
}
- string lib;
+ string lib = libPath;
#ifdef _WIN32
- lib = libName;
+ lib += libName;
# ifdef COMPSUFFIX
//
@@ -114,13 +148,13 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
lib += ".dll";
#elif defined(__APPLE__)
- lib = "lib" + libName;
- if(!version.empty())
+ lib += "lib" + libName;
+ if(!version.empty())
{
lib += "." + version;
}
#elif defined(__hpux)
- lib = "lib" + libName;
+ lib += "lib" + libName;
if(!version.empty())
{
lib += "." + version;
@@ -130,14 +164,14 @@ IceInternal::DynamicLibrary::loadEntryPoint(const string& entryPoint, bool useIc
lib += ".sl";
}
#elif defined(_AIX)
- lib = "lib" + libName + ".a(lib" + libName + ".so";
+ lib += "lib" + libName + ".a(lib" + libName + ".so";
if(!version.empty())
{
lib += "." + version;
}
lib += ")";
#else
- lib = "lib" + libName + ".so";
+ lib += "lib" + libName + ".so";
if(!version.empty())
{
lib += "." + version;
@@ -217,16 +251,16 @@ IceInternal::DynamicLibrary::getSymbol(const string& name)
#else
symbol_type result = dlsym(_hnd, name.c_str());
#endif
-
+
if(result == 0)
{
//
// Remember the most recent error in _err.
//
#ifdef _WIN32
- _err = IceUtilInternal::lastErrorToString();
+ _err = IceUtilInternal::lastErrorToString();
#else
- const char* err = dlerror();
+ const char* err = dlerror();
if(err)
{
_err = err;
diff --git a/cpp/src/Ice/EventHandler.h b/cpp/src/Ice/EventHandler.h
index 3c7ece52a57..04200f2d29e 100644
--- a/cpp/src/Ice/EventHandler.h
+++ b/cpp/src/Ice/EventHandler.h
@@ -19,7 +19,7 @@
namespace IceInternal
{
-class EventHandler : virtual public ::IceUtil::Shared
+class ICE_API EventHandler : virtual public ::IceUtil::Shared
{
public:
@@ -54,7 +54,7 @@ public:
protected:
EventHandler();
- ICE_API virtual ~EventHandler();
+ virtual ~EventHandler();
#if defined(ICE_USE_IOCP) || defined(ICE_OS_WINRT)
SocketOperation _ready;
diff --git a/cpp/src/Ice/HashUtil.h b/cpp/src/Ice/HashUtil.h
index 7b6c7f6a27b..d23ee90ff0c 100644
--- a/cpp/src/Ice/HashUtil.h
+++ b/cpp/src/Ice/HashUtil.h
@@ -15,13 +15,13 @@ namespace IceInternal
inline void
hashAdd(Ice::Int& hashCode, Ice::Int value)
{
- hashCode = hashCode * 5 + value;
+ hashCode = ((hashCode << 5) + hashCode) ^ (2654435761u * value);
}
inline void
hashAdd(Ice::Int& hashCode, bool value)
{
- hashCode = hashCode * 5 + static_cast<Ice::Int>(value);
+ hashCode = ((hashCode << 5) + hashCode) ^ (value ? 1 : 0);
}
inline void
@@ -29,7 +29,7 @@ hashAdd(Ice::Int& hashCode, const std::string& value)
{
for(std::string::const_iterator p = value.begin(); p != value.end(); ++p)
{
- hashCode = 5 * hashCode + *p;
+ hashCode = ((hashCode << 5) + hashCode) ^ *p;
}
}
@@ -52,5 +52,4 @@ hashAdd(Ice::Int& hashCode, const std::map<K, V>& map)
}
}
-
}
diff --git a/cpp/src/Ice/Initialize.cpp b/cpp/src/Ice/Initialize.cpp
index f8b7f2a3cd4..adbd58424dc 100644
--- a/cpp/src/Ice/Initialize.cpp
+++ b/cpp/src/Ice/Initialize.cpp
@@ -323,3 +323,11 @@ IceInternal::getInstance(const CommunicatorPtr& communicator)
assert(p);
return p->_instance;
}
+
+#ifdef ICE_CPP11
+void
+IceInternal::Cpp11Dispatcher::dispatch(const ::Ice::DispatcherCallPtr& call, const ::Ice::ConnectionPtr& conn)
+{
+ _cb(call, conn);
+}
+#endif
diff --git a/cpp/src/Ice/LocatorInfo.cpp b/cpp/src/Ice/LocatorInfo.cpp
index 15c78d1fcd7..ac693041b2e 100644
--- a/cpp/src/Ice/LocatorInfo.cpp
+++ b/cpp/src/Ice/LocatorInfo.cpp
@@ -31,7 +31,7 @@ IceUtil::Shared* IceInternal::upCast(LocatorTable* p) { return p; }
namespace
{
-class ObjectRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findObjectById
+class ObjectRequest : public LocatorInfo::Request
{
public:
@@ -40,37 +40,31 @@ public:
assert(ref->isWellKnown());
}
- virtual void ice_response(const Ice::ObjectPrx& proxy)
- {
- response(proxy);
- }
-
- virtual void ice_exception(const Ice::Exception& ex)
- {
- exception(ex);
- }
-
virtual void send(bool async)
{
try
{
if(async)
{
- _locatorInfo->getLocator()->findObjectById_async(this, _ref->getIdentity());
+ _locatorInfo->getLocator()->begin_findObjectById(
+ _ref->getIdentity(),
+ newCallback_Locator_findObjectById(static_cast<LocatorInfo::Request*>(this),
+ &LocatorInfo::Request::response,
+ &LocatorInfo::Request::exception));
}
else
{
- ice_response(_locatorInfo->getLocator()->findObjectById(_ref->getIdentity()));
+ response(_locatorInfo->getLocator()->findObjectById(_ref->getIdentity()));
}
}
catch(const Ice::Exception& ex)
{
- ice_exception(ex);
+ exception(ex);
}
}
};
-class AdapterRequest : public LocatorInfo::Request, public Ice::AMI_Locator_findAdapterById
+class AdapterRequest : public LocatorInfo::Request
{
public:
@@ -79,32 +73,26 @@ public:
assert(ref->isIndirect() && !ref->isWellKnown());
}
- virtual void ice_response(const Ice::ObjectPrx& proxy)
- {
- response(proxy);
- }
-
- virtual void ice_exception(const Ice::Exception& ex)
- {
- exception(ex);
- }
-
virtual void send(bool async)
{
try
{
if(async)
{
- _locatorInfo->getLocator()->findAdapterById_async(this, _ref->getAdapterId());
+ _locatorInfo->getLocator()->begin_findAdapterById(
+ _ref->getAdapterId(),
+ newCallback_Locator_findAdapterById(static_cast<LocatorInfo::Request*>(this),
+ &LocatorInfo::Request::response,
+ &LocatorInfo::Request::exception));
}
else
{
- ice_response(_locatorInfo->getLocator()->findAdapterById(_ref->getAdapterId()));
+ response(_locatorInfo->getLocator()->findAdapterById(_ref->getAdapterId()));
}
}
catch(const Ice::Exception& ex)
{
- ice_exception(ex);
+ exception(ex);
}
}
};
diff --git a/cpp/src/Ice/LocatorInfo.h b/cpp/src/Ice/LocatorInfo.h
index 4abbfac03ff..09f114663cc 100644
--- a/cpp/src/Ice/LocatorInfo.h
+++ b/cpp/src/Ice/LocatorInfo.h
@@ -109,14 +109,14 @@ public:
void addCallback(const ReferencePtr&, const ReferencePtr&, int, const GetEndpointsCallbackPtr&);
std::vector<EndpointIPtr> getEndpoints(const ReferencePtr&, const ReferencePtr&, int, bool&);
+
+ void response(const Ice::ObjectPrx&);
+ void exception(const Ice::Exception&);
protected:
Request(const LocatorInfoPtr&, const ReferencePtr&);
- void response(const Ice::ObjectPrx&);
- void exception(const Ice::Exception&);
-
virtual void send(bool) = 0;
const LocatorInfoPtr _locatorInfo;
diff --git a/cpp/src/Ice/Makefile.mak b/cpp/src/Ice/Makefile.mak
index 37f401cc50d..e07cc6833bc 100644
--- a/cpp/src/Ice/Makefile.mak
+++ b/cpp/src/Ice/Makefile.mak
@@ -130,7 +130,6 @@ CPPFLAGS = $(CPPFLAGS) -DCOMPSUFFIX=\"$(COMPSUFFIX)\"
SLICE2CPPFLAGS = --ice --include-dir Ice --dll-export ICE_API $(SLICE2CPPFLAGS)
LINKWITH = $(BASELIBS) $(BZIP2_LIBS) $(ICE_OS_LIBS) ws2_32.lib Iphlpapi.lib
-
PDBFLAGS = /pdb:$(DLLNAME:.dll=.pdb)
LD_DLLFLAGS = $(LD_DLLFLAGS) /entry:"ice_DLL_Main"
RES_FILE = Ice.res
diff --git a/cpp/src/Ice/Network.cpp b/cpp/src/Ice/Network.cpp
index a86f23f2834..9ab03d9827c 100644
--- a/cpp/src/Ice/Network.cpp
+++ b/cpp/src/Ice/Network.cpp
@@ -17,6 +17,14 @@
# include <netinet/in.h>
#endif
+//
+// The following is required for MinGW to bring in
+// some definitions.
+//
+#if defined(__MINGW32__)
+# define _WIN32_WINNT 0x0501
+#endif
+
#include <IceUtil/DisableWarnings.h>
#include <Ice/Network.h>
#include <IceUtil/StringUtil.h>
@@ -1630,7 +1638,7 @@ IceInternal::doBind(SOCKET fd, const Address& addr)
size = 0; // Keep the compiler happy.
}
- if(bind(fd, reinterpret_cast<const struct sockaddr*>(&addr), size) == SOCKET_ERROR)
+ if(::bind(fd, reinterpret_cast<const struct sockaddr*>(&addr), size) == SOCKET_ERROR)
{
closeSocketNoThrow(fd);
SocketException ex(__FILE__, __LINE__);
diff --git a/cpp/src/Ice/Object.cpp b/cpp/src/Ice/Object.cpp
index 879f486b78b..d5048326e93 100644
--- a/cpp/src/Ice/Object.cpp
+++ b/cpp/src/Ice/Object.cpp
@@ -86,7 +86,7 @@ Ice::Object::ice_staticId()
return __Ice__Object_ids[0];
}
-ObjectPtr
+Ice::ObjectPtr
Ice::Object::ice_clone() const
{
throw CloneNotImplementedException(__FILE__, __LINE__);
diff --git a/cpp/src/Ice/OpaqueEndpointI.cpp b/cpp/src/Ice/OpaqueEndpointI.cpp
index 42918b04fa9..6ce56874f74 100644
--- a/cpp/src/Ice/OpaqueEndpointI.cpp
+++ b/cpp/src/Ice/OpaqueEndpointI.cpp
@@ -433,7 +433,8 @@ IceInternal::OpaqueEndpointI::operator<(const LocalObject& r) const
Ice::Int
IceInternal::OpaqueEndpointI::hashInit() const
{
- Ice::Int h = _type;
+ Ice::Int h = 5381;
+ hashAdd(h, _type);
hashAdd(h, _rawEncoding.major);
hashAdd(h, _rawEncoding.minor);
hashAdd(h, _rawBytes);
diff --git a/cpp/src/Ice/Outgoing.cpp b/cpp/src/Ice/Outgoing.cpp
index d6d09d1271a..23fc92af5df 100644
--- a/cpp/src/Ice/Outgoing.cpp
+++ b/cpp/src/Ice/Outgoing.cpp
@@ -28,13 +28,13 @@ using namespace IceInternal;
IceInternal::LocalExceptionWrapper::LocalExceptionWrapper(const LocalException& ex, bool r) :
_retry(r)
{
- _ex.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ _ex.reset(ex.ice_clone());
}
IceInternal::LocalExceptionWrapper::LocalExceptionWrapper(const LocalExceptionWrapper& ex) :
_retry(ex._retry)
{
- _ex.reset(dynamic_cast<LocalException*>(ex.get()->ice_clone()));
+ _ex.reset(ex.get()->ice_clone());
}
void
@@ -527,7 +527,7 @@ IceInternal::Outgoing::finished(const LocalException& ex, bool sent)
_remoteObserver.detach();
_state = StateFailed;
- _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
_sent = sent;
_monitor.notify();
}
@@ -601,6 +601,6 @@ void
IceInternal::BatchOutgoing::finished(const Ice::LocalException& ex, bool)
{
IceUtil::Monitor<IceUtil::Mutex>::Lock sync(_monitor);
- _exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
_monitor.notify();
}
diff --git a/cpp/src/Ice/OutgoingAsync.cpp b/cpp/src/Ice/OutgoingAsync.cpp
index 3a158848376..6f96ed33a8e 100644
--- a/cpp/src/Ice/OutgoingAsync.cpp
+++ b/cpp/src/Ice/OutgoingAsync.cpp
@@ -55,7 +55,7 @@ public:
AsynchronousException(const IceInternal::InstancePtr& instance,
const Ice::AsyncResultPtr& result,
const Ice::Exception& ex) :
- DispatchWorkItem(instance), _result(result), _exception(dynamic_cast<Ice::LocalException*>(ex.ice_clone()))
+ DispatchWorkItem(instance), _result(result), _exception(ex.ice_clone())
{
}
diff --git a/cpp/src/Ice/PluginManagerI.cpp b/cpp/src/Ice/PluginManagerI.cpp
index 513a3036ea6..bb2bcd37959 100644
--- a/cpp/src/Ice/PluginManagerI.cpp
+++ b/cpp/src/Ice/PluginManagerI.cpp
@@ -7,6 +7,7 @@
//
// **********************************************************************
+#include <IceUtil/Options.h>
#include <Ice/PluginManagerI.h>
#include <Ice/DynamicLibrary.h>
#include <Ice/Communicator.h>
@@ -40,10 +41,10 @@ Ice::PluginManagerI::initializePlugins()
vector<PluginPtr> initializedPlugins;
try
{
- for(vector<PluginPtr>::iterator p = _initOrder.begin(); p != _initOrder.end(); ++p)
+ for(PluginInfoList::iterator p = _plugins.begin(); p != _plugins.end(); ++p)
{
- (*p)->initialize();
- initializedPlugins.push_back(*p);
+ p->plugin->initialize();
+ initializedPlugins.push_back(p->plugin);
}
}
catch(...)
@@ -75,10 +76,9 @@ Ice::PluginManagerI::getPlugins()
IceUtil::Mutex::Lock sync(*this);
StringSeq names;
- map<string, PluginPtr>::iterator r;
- for(r = _plugins.begin(); r != _plugins.end(); ++r)
+ for(PluginInfoList::iterator p = _plugins.begin(); p != _plugins.end(); ++p)
{
- names.push_back((*r).first);
+ names.push_back(p->name);
}
return names;
}
@@ -93,10 +93,10 @@ Ice::PluginManagerI::getPlugin(const string& name)
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- map<string, PluginPtr>::const_iterator r = _plugins.find(name);
- if(r != _plugins.end())
+ PluginPtr p = findPlugin(name);
+ if(p)
{
- return (*r).second;
+ return p;
}
NotRegisteredException ex(__FILE__, __LINE__);
@@ -115,15 +115,18 @@ Ice::PluginManagerI::addPlugin(const string& name, const PluginPtr& plugin)
throw CommunicatorDestroyedException(__FILE__, __LINE__);
}
- map<string, PluginPtr>::const_iterator r = _plugins.find(name);
- if(r != _plugins.end())
+ if(findPlugin(name))
{
AlreadyRegisteredException ex(__FILE__, __LINE__);
ex.kindOfObject = _kindOfObject;
ex.id = name;
throw ex;
}
- _plugins[name] = plugin;
+
+ PluginInfo info;
+ info.name = name;
+ info.plugin = plugin;
+ _plugins.push_back(info);
}
void
@@ -135,40 +138,44 @@ Ice::PluginManagerI::destroy()
{
if(_initialized)
{
- map<string, PluginPtr>::iterator r;
- for(r = _plugins.begin(); r != _plugins.end(); ++r)
+
+ //
+ // Destroy the plug-ins that have been successfully initialized, in the
+ // reverse order.
+ //
+ for(PluginInfoList::reverse_iterator p = _plugins.rbegin(); p != _plugins.rend(); ++p)
{
try
{
- r->second->destroy();
- r->second = 0;
+ p->plugin->destroy();
}
catch(const std::exception& ex)
{
Warning out(getProcessLogger());
- out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << ex.what();
+ out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << ex.what();
}
catch(const std::string& str)
{
Warning out(getProcessLogger());
- out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << str;
+ out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << str;
}
catch(const char* msg)
{
Warning out(getProcessLogger());
- out << "unexpected exception raised by plug-in `" << r->first << "' destruction:\n" << msg;
+ out << "unexpected exception raised by plug-in `" << p->name << "' destruction:\n" << msg;
}
catch(...)
{
Warning out(getProcessLogger());
- out << "unexpected exception raised by plug-in `" << r->first << "' destruction";
+ out << "unexpected exception raised by plug-in `" << p->name << "' destruction";
}
}
}
-
+
_communicator = 0;
}
+ _plugins.clear();
_libraries = 0;
}
@@ -206,7 +213,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
{
string name = *p;
- if(_plugins.find(name) != _plugins.end())
+ if(findPlugin(name))
{
PluginInitializationException ex(__FILE__, __LINE__);
ex.reason = "plug-in `" + name + "' already loaded";
@@ -239,7 +246,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
//
// Load any remaining plug-ins that weren't specified in PluginLoadOrder.
//
-
+
while(!plugins.empty())
{
PropertyDict::iterator p = plugins.begin();
@@ -262,7 +269,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
name = name.substr(0, dotPos);
loadPlugin(name, p->second, cmdArgs);
plugins.erase(p);
-
+
plugins.erase("Ice.Plugin." + name);
}
else
@@ -273,7 +280,7 @@ Ice::PluginManagerI::loadPlugins(int& argc, char* argv[])
dotPos = string::npos;
}
}
-
+
if(dotPos == string::npos)
{
//
@@ -299,36 +306,29 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
{
assert(_communicator);
//
- // Separate the entry point from the arguments.
+ // Split the entire property value into arguments. An entry point containing spaces
+ // must be enclosed in quotes.
//
- string entryPoint;
StringSeq args;
- const string delim = " \t\n";
- string::size_type pos = pluginSpec.find_first_of(delim);
- if(pos == string::npos)
+ try
{
- entryPoint = pluginSpec;
+ args = IceUtilInternal::Options::split(pluginSpec);
}
- else
+ catch(const IceUtilInternal::BadOptException& ex)
{
- entryPoint = pluginSpec.substr(0, pos);
- string::size_type beg = pluginSpec.find_first_not_of(delim, pos);
- while(beg != string::npos)
- {
- string::size_type end = pluginSpec.find_first_of(delim, beg);
- if(end == string::npos)
- {
- args.push_back(pluginSpec.substr(beg));
- beg = end;
- }
- else
- {
- args.push_back(pluginSpec.substr(beg, end - beg));
- beg = pluginSpec.find_first_not_of(delim, end);
- }
- }
+ PluginInitializationException e(__FILE__, __LINE__);
+ e.reason = "invalid arguments for plug-in `" + name + "':\n" + ex.reason;
+ throw e;
}
+ assert(!args.empty());
+
+ //
+ // Shift the arguments.
+ //
+ const string entryPoint = args[0];
+ args.erase(args.begin());
+
//
// Convert command-line options into properties. First we
// convert the options from the plug-in configuration, then
@@ -373,15 +373,30 @@ Ice::PluginManagerI::loadPlugin(const string& name, const string& pluginSpec, St
throw e;
}
- _plugins[name] = plugin;
- _initOrder.push_back(plugin);
+ PluginInfo info;
+ info.name = name;
+ info.plugin = plugin;
+ _plugins.push_back(info);
_libraries->add(library);
}
+Ice::PluginPtr
+Ice::PluginManagerI::findPlugin(const string& name) const
+{
+ for(PluginInfoList::const_iterator p = _plugins.begin(); p != _plugins.end(); ++p)
+ {
+ if(name == p->name)
+ {
+ return p->plugin;
+ }
+ }
+ return 0;
+}
+
void
-IceInternal::loadPlugin(const Ice::CommunicatorPtr& communicator,
- const string& name,
+IceInternal::loadPlugin(const Ice::CommunicatorPtr& communicator,
+ const string& name,
const string& pluginSpec,
Ice::StringSeq& cmdArgs)
{
diff --git a/cpp/src/Ice/PluginManagerI.h b/cpp/src/Ice/PluginManagerI.h
index ecb73fa3a43..a7b7578ebaa 100644
--- a/cpp/src/Ice/PluginManagerI.h
+++ b/cpp/src/Ice/PluginManagerI.h
@@ -41,17 +41,25 @@ private:
PluginManagerI(const CommunicatorPtr&, const IceInternal::DynamicLibraryListPtr&);
friend class IceInternal::Instance;
- friend void IceInternal::loadPlugin(const Ice::CommunicatorPtr&, const std::string&, const std::string&,
+ friend void IceInternal::loadPlugin(const Ice::CommunicatorPtr&, const std::string&, const std::string&,
Ice::StringSeq&);
void loadPlugins(int&, char*[]);
void loadPlugin(const std::string&, const std::string&, StringSeq&);
+ PluginPtr findPlugin(const std::string&) const;
+
CommunicatorPtr _communicator;
IceInternal::DynamicLibraryListPtr _libraries;
- std::map<std::string, PluginPtr> _plugins;
- std::vector<PluginPtr> _initOrder;
+ struct PluginInfo
+ {
+ std::string name;
+ PluginPtr plugin;
+ };
+ typedef std::vector<PluginInfo> PluginInfoList;
+
+ PluginInfoList _plugins;
bool _initialized;
static const char * const _kindOfObject;
};
diff --git a/cpp/src/Ice/Proxy.cpp b/cpp/src/Ice/Proxy.cpp
index f2e20d3ee50..69da155dd9d 100644
--- a/cpp/src/Ice/Proxy.cpp
+++ b/cpp/src/Ice/Proxy.cpp
@@ -70,6 +70,26 @@ IceInternal::checkedCastImpl(const ObjectPrx& b, const string& f, const string&
return 0;
}
+#ifdef ICE_CPP11
+void
+IceInternal::Cpp11FnOnewayCallbackNC::__completed(const ::Ice::AsyncResultPtr& result) const
+{
+ try
+ {
+ result->getProxy()->__end(result, result->getOperation());
+ }
+ catch(const ::Ice::Exception& ex)
+ {
+ Cpp11FnCallbackNC::__exception(result, ex);
+ return;
+ }
+ if(_cb != nullptr)
+ {
+ _cb();
+ }
+}
+#endif
+
bool
IceProxy::Ice::Object::operator==(const Object& r) const
{
diff --git a/cpp/src/Ice/Reference.cpp b/cpp/src/Ice/Reference.cpp
index 3ec8385c214..1d5f4dd1b91 100644
--- a/cpp/src/Ice/Reference.cpp
+++ b/cpp/src/Ice/Reference.cpp
@@ -483,12 +483,20 @@ IceInternal::Reference::Reference(const Reference& r) :
int
IceInternal::Reference::hashInit() const
{
- Int h = static_cast<Int>(_mode);
+ Int h = 5381;
+ hashAdd(h, static_cast<Int>(_mode));
+ hashAdd(h, _secure);
hashAdd(h, _identity.name);
hashAdd(h, _identity.category);
hashAdd(h, _context->getValue());
hashAdd(h, _facet);
- hashAdd(h, _secure);
+ hashAdd(h, _overrideCompress);
+ if(_overrideCompress)
+ {
+ hashAdd(h, _compress);
+ }
+ hashAdd(h, _encoding.major);
+ hashAdd(h, _encoding.minor);
return h;
}
@@ -1681,7 +1689,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
}
catch(const LocalException& ex)
{
- exception.reset(dynamic_cast<LocalException*>(ex.ice_clone()));
+ exception.reset(ex.ice_clone());
}
}
@@ -1793,7 +1801,7 @@ IceInternal::RoutableReference::createConnection(const vector<EndpointIPtr>& all
{
if(!_exception.get())
{
- _exception.reset(dynamic_cast<Ice::LocalException*>(ex.ice_clone()));
+ _exception.reset(ex.ice_clone());
}
if(++_i == _endpoints.size())
diff --git a/cpp/src/Ice/RouterInfo.cpp b/cpp/src/Ice/RouterInfo.cpp
index a07ff0d6cf9..291e0ec03d9 100644
--- a/cpp/src/Ice/RouterInfo.cpp
+++ b/cpp/src/Ice/RouterInfo.cpp
@@ -166,6 +166,32 @@ IceInternal::RouterInfo::getClientEndpoints()
}
void
+IceInternal::RouterInfo::getClientProxyResponse(const Ice::ObjectPrx& proxy, const GetClientEndpointsCallbackPtr& callback)
+{
+ callback->setEndpoints(setClientEndpoints(proxy));
+}
+
+void
+IceInternal::RouterInfo::getClientProxyException(const Ice::Exception& ex, const GetClientEndpointsCallbackPtr& callback)
+{
+ if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex))
+ {
+ try
+ {
+ callback->setEndpoints(getClientEndpoints());
+ }
+ catch(const Ice::LocalException& e)
+ {
+ callback->setException(e);
+ }
+ }
+ else
+ {
+ callback->setException(dynamic_cast<const Ice::LocalException&>(ex));
+ }
+}
+
+void
IceInternal::RouterInfo::getClientEndpoints(const GetClientEndpointsCallbackPtr& callback)
{
vector<EndpointIPtr> clientEndpoints;
@@ -180,48 +206,10 @@ IceInternal::RouterInfo::getClientEndpoints(const GetClientEndpointsCallbackPtr&
return;
}
- class Callback : public AMI_Router_getClientProxy
- {
- public:
-
- virtual void
- ice_response(const Ice::ObjectPrx& clientProxy)
- {
- _callback->setEndpoints(_routerInfo->setClientEndpoints(clientProxy));
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex))
- {
- try
- {
- _callback->setEndpoints(_routerInfo->getClientEndpoints());
- }
- catch(const Ice::LocalException& e)
- {
- _callback->setException(e);
- }
- }
- else
- {
- _callback->setException(dynamic_cast<const Ice::LocalException&>(ex));
- }
- }
-
- Callback(const RouterInfoPtr& routerInfo, const GetClientEndpointsCallbackPtr& callback) :
- _routerInfo(routerInfo), _callback(callback)
- {
- }
-
- private:
-
- const RouterInfoPtr _routerInfo;
- const GetClientEndpointsCallbackPtr _callback;
- };
-
- _router->getClientProxy_async(new Callback(this, callback));
+ _router->begin_getClientProxy(newCallback_Router_getClientProxy(this,
+ &RouterInfo::getClientProxyResponse,
+ &RouterInfo::getClientProxyException),
+ callback);
}
vector<EndpointIPtr>
@@ -259,6 +247,34 @@ IceInternal::RouterInfo::addProxy(const ObjectPrx& proxy)
addAndEvictProxies(proxy, _router->addProxies(proxies));
}
+void
+IceInternal::RouterInfo::addProxyResponse(const Ice::ObjectProxySeq& proxies, const AddProxyCookiePtr& cookie)
+{
+ addAndEvictProxies(cookie->proxy(), proxies);
+ cookie->cb()->addedProxy();
+}
+
+void
+IceInternal::RouterInfo::addProxyException(const Ice::Exception& ex, const AddProxyCookiePtr& cookie)
+{
+ if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex))
+ {
+ try
+ {
+ addProxy(cookie->proxy());
+ cookie->cb()->addedProxy();
+ }
+ catch(const Ice::LocalException& e)
+ {
+ cookie->cb()->setException(e);
+ }
+ }
+ else
+ {
+ cookie->cb()->setException(dynamic_cast<const Ice::LocalException&>(ex));
+ }
+}
+
bool
IceInternal::RouterInfo::addProxy(const Ice::ObjectPrx& proxy, const AddProxyCallbackPtr& callback)
{
@@ -274,53 +290,15 @@ IceInternal::RouterInfo::addProxy(const Ice::ObjectPrx& proxy, const AddProxyCal
}
}
- class Callback : public AMI_Router_addProxies
- {
- public:
-
- virtual void
- ice_response(const Ice::ObjectProxySeq& evictedProxies)
- {
- _routerInfo->addAndEvictProxies(_proxy, evictedProxies);
- _callback->addedProxy();
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- if(dynamic_cast<const Ice::CollocationOptimizationException*>(&ex))
- {
- try
- {
- _routerInfo->addProxy(_proxy);
- _callback->addedProxy();
- }
- catch(const Ice::LocalException& e)
- {
- _callback->setException(e);
- }
- }
- else
- {
- _callback->setException(dynamic_cast<const Ice::LocalException&>(ex));
- }
- }
-
- Callback(const RouterInfoPtr& routerInfo, const Ice::ObjectPrx& proxy, const AddProxyCallbackPtr& callback) :
- _routerInfo(routerInfo), _proxy(proxy), _callback(callback)
- {
- }
-
- private:
-
- const RouterInfoPtr _routerInfo;
- const Ice::ObjectPrx _proxy;
- const AddProxyCallbackPtr _callback;
- };
Ice::ObjectProxySeq proxies;
proxies.push_back(proxy);
- _router->addProxies_async(new Callback(this, proxy, callback), proxies);
+ AddProxyCookiePtr cookie = new AddProxyCookie(callback, proxy);
+ _router->begin_addProxies(proxies,
+ newCallback_Router_addProxies(this,
+ &RouterInfo::addProxyResponse,
+ &RouterInfo::addProxyException),
+ cookie);
return false;
}
diff --git a/cpp/src/Ice/RouterInfo.h b/cpp/src/Ice/RouterInfo.h
index 52801b57651..b1c80ed07fb 100644
--- a/cpp/src/Ice/RouterInfo.h
+++ b/cpp/src/Ice/RouterInfo.h
@@ -47,7 +47,7 @@ class RouterInfo : public IceUtil::Shared, public IceUtil::Mutex
{
public:
- class GetClientEndpointsCallback : virtual public IceUtil::Shared
+ class GetClientEndpointsCallback : virtual public Ice::LocalObject
{
public:
@@ -74,9 +74,41 @@ public:
bool operator<(const RouterInfo&) const;
Ice::RouterPrx getRouter() const;
+ void getClientProxyResponse(const Ice::ObjectPrx&, const GetClientEndpointsCallbackPtr&);
+ void getClientProxyException(const Ice::Exception&, const GetClientEndpointsCallbackPtr&);
std::vector<EndpointIPtr> getClientEndpoints();
void getClientEndpoints(const GetClientEndpointsCallbackPtr&);
std::vector<EndpointIPtr> getServerEndpoints();
+
+ class AddProxyCookie : public Ice::LocalObject
+ {
+ public:
+
+ AddProxyCookie(const AddProxyCallbackPtr cb, const Ice::ObjectPrx& proxy) :
+ _cb(cb),
+ _proxy(proxy)
+ {
+ }
+
+ AddProxyCallbackPtr cb() const
+ {
+ return _cb;
+ }
+
+ Ice::ObjectPrx proxy() const
+ {
+ return _proxy;
+ }
+
+ private:
+
+ const AddProxyCallbackPtr _cb;
+ const Ice::ObjectPrx _proxy;
+ };
+ typedef IceUtil::Handle<AddProxyCookie> AddProxyCookiePtr;
+
+ void addProxyResponse(const Ice::ObjectProxySeq&, const AddProxyCookiePtr&);
+ void addProxyException(const Ice::Exception&, const AddProxyCookiePtr&);
void addProxy(const Ice::ObjectPrx&);
bool addProxy(const Ice::ObjectPrx&, const AddProxyCallbackPtr&);
diff --git a/cpp/src/Ice/Service.cpp b/cpp/src/Ice/Service.cpp
index 7800b392076..722a729229d 100644
--- a/cpp/src/Ice/Service.cpp
+++ b/cpp/src/Ice/Service.cpp
@@ -22,6 +22,7 @@
#include <Ice/Communicator.h>
#include <Ice/LocalException.h>
#include <Ice/Properties.h>
+#include <Ice/Instance.h>
#ifdef _WIN32
# include <winsock2.h>
@@ -57,7 +58,7 @@ ctrlCHandlerCallback(int sig)
// Main function for Win32 service.
//
void WINAPI
-Ice_Service_ServiceMain(DWORD argc, LPTSTR* argv)
+Ice_Service_ServiceMain(DWORD argc, LPWSTR* argv)
{
Ice::Service* service = Ice::Service::instance();
assert(service != 0);
@@ -202,9 +203,11 @@ class SMEventLoggerI : public Ice::Logger, public SMEventLogger
{
public:
- SMEventLoggerI(const string& source)
+ SMEventLoggerI(const string& source, const StringConverterPtr& stringConverter) :
+ _stringConverter(stringConverter)
{
- _source = RegisterEventSource(0, mangleSource(source).c_str());
+ _source = RegisterEventSourceW(0, IceUtil::stringToWstring(
+ nativeToUTF8(_stringConverter, mangleSource(source))).c_str());
if(_source == 0)
{
SyscallException ex(__FILE__, __LINE__);
@@ -220,12 +223,14 @@ public:
}
static void
- addKeys(const string& source)
+ addKeys(const string& source, const StringConverterPtr& stringConverter)
{
HKEY hKey;
DWORD d;
- LONG err = RegCreateKeyEx(HKEY_LOCAL_MACHINE, createKey(source).c_str(), 0, "REG_SZ",
- REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d);
+ LONG err = RegCreateKeyExW(HKEY_LOCAL_MACHINE,
+ IceUtil::stringToWstring(nativeToUTF8(stringConverter, createKey(source))).c_str(),
+ 0, L"REG_SZ", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, &d);
+
if(err != ERROR_SUCCESS)
{
SyscallException ex(__FILE__, __LINE__);
@@ -236,9 +241,9 @@ public:
//
// Get the filename of this DLL.
//
- char path[_MAX_PATH];
+ wchar_t path[_MAX_PATH];
assert(_module != 0);
- if(!GetModuleFileName(_module, path, _MAX_PATH))
+ if(!GetModuleFileNameW(_module, path, _MAX_PATH))
{
RegCloseKey(hKey);
SyscallException ex(__FILE__, __LINE__);
@@ -251,8 +256,9 @@ public:
// the "EventMessageFile" key should contain the path to this
// DLL.
//
- err = RegSetValueEx(hKey, "EventMessageFile", 0, REG_EXPAND_SZ,
- reinterpret_cast<unsigned char*>(path), static_cast<DWORD>(strlen(path) + 1));
+ err = RegSetValueExW(hKey, L"EventMessageFile", 0, REG_EXPAND_SZ, reinterpret_cast<unsigned char*>(path),
+ static_cast<DWORD>((wcslen(path) * sizeof(wchar_t)) + 1));
+
if(err == ERROR_SUCCESS)
{
//
@@ -260,8 +266,8 @@ public:
// types.
//
DWORD typesSupported = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE | EVENTLOG_INFORMATION_TYPE;
- err = RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD,
- reinterpret_cast<unsigned char*>(&typesSupported), sizeof(typesSupported));
+ err = RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD,
+ reinterpret_cast<unsigned char*>(&typesSupported), sizeof(typesSupported));
}
if(err != ERROR_SUCCESS)
{
@@ -275,9 +281,10 @@ public:
}
static void
- removeKeys(const string& source)
+ removeKeys(const string& source, const StringConverterPtr& stringConverter)
{
- LONG err = RegDeleteKey(HKEY_LOCAL_MACHINE, createKey(source).c_str());
+ LONG err = RegDeleteKeyW(HKEY_LOCAL_MACHINE,
+ IceUtil::stringToWstring(nativeToUTF8(stringConverter, createKey(source))).c_str());
if(err != ERROR_SUCCESS)
{
SyscallException ex(__FILE__, __LINE__);
@@ -302,13 +309,14 @@ public:
virtual void
print(const string& message)
{
- const char* str[1];
- str[0] = message.c_str();
+ wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message));
+ const wchar_t* messages[1];
+ messages[0] = msg.c_str();
//
// We ignore any failures from ReportEvent since there isn't
// anything we can do about it.
//
- ReportEvent(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0);
+ ReportEventW(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0);
}
virtual void
@@ -335,13 +343,14 @@ public:
}
s.append(message);
- const char* str[1];
- str[0] = s.c_str();
+ wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, s));
+ const wchar_t* messages[1];
+ messages[0] = msg.c_str();
//
// We ignore any failures from ReportEvent since there isn't
// anything we can do about it.
//
- ReportEvent(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0);
+ ReportEventW(_source, EVENTLOG_INFORMATION_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0);
}
virtual void
@@ -360,13 +369,14 @@ public:
virtual void
warning(const string& message)
{
- const char* str[1];
- str[0] = message.c_str();
+ wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message));
+ const wchar_t* messages[1];
+ messages[0] = msg.c_str();
//
// We ignore any failures from ReportEvent since there isn't
// anything we can do about it.
//
- ReportEvent(_source, EVENTLOG_WARNING_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0);
+ ReportEventW(_source, EVENTLOG_WARNING_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0);
}
virtual void
@@ -385,13 +395,14 @@ public:
virtual void
error(const string& message)
{
- const char* str[1];
- str[0] = message.c_str();
+ wstring msg = IceUtil::stringToWstring(nativeToUTF8(_stringConverter, message));
+ const wchar_t* messages[1];
+ messages[0] = msg.c_str();
//
// We ignore any failures from ReportEvent since there isn't
// anything we can do about it.
//
- ReportEvent(_source, EVENTLOG_ERROR_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, str, 0);
+ ReportEventW(_source, EVENTLOG_ERROR_TYPE, 0, EVENT_LOGGER_MSG, 0, 1, 0, messages, 0);
}
virtual Ice::LoggerPtr
@@ -433,7 +444,7 @@ private:
return "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\" + mangleSource(name);
}
-
+ StringConverterPtr _stringConverter;
HANDLE _source;
static HMODULE _module;
};
@@ -552,7 +563,7 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa
if(LoggerIPtr::dynamicCast(_logger))
{
string eventLogSource = initData.properties->getPropertyWithDefault("Ice.EventLog.Source", name);
- _logger = new SMEventLoggerIWrapper(new SMEventLoggerI(eventLogSource), "");
+ _logger = new SMEventLoggerIWrapper(new SMEventLoggerI(eventLogSource, initData.stringConverter), "");
setProcessLogger(_logger);
}
@@ -568,160 +579,6 @@ Ice::Service::main(int& argc, char* argv[], const InitializationData& initializa
}
}
- //
- // Next check for service control options.
- //
- string op;
- idx = 1;
- while(idx < argc)
- {
- if(strcmp(argv[idx], "--install") == 0 ||
- strcmp(argv[idx], "--uninstall") == 0 ||
- strcmp(argv[idx], "--start") == 0 ||
- strcmp(argv[idx], "--stop") == 0)
- {
- if(!op.empty())
- {
- error("cannot specify `" + op + "' and `" + string(argv[idx]) + "'");
- return EXIT_FAILURE;
- }
-
- if(!name.empty())
- {
- error("cannot specify `--service' and `" + string(argv[idx]) + "'");
- return EXIT_FAILURE;
- }
-
- if(idx + 1 >= argc)
- {
- error("service name argument expected for `" + string(argv[idx]) + "'");
- return EXIT_FAILURE;
- }
-
- op = argv[idx];
- name = argv[idx + 1];
-
- warning("the " + op + " option is deprecated");
-
- for(int i = idx ; i + 2 < argc ; ++i)
- {
- argv[i] = argv[i + 2];
- }
- argc -= 2;
- }
- else
- {
- ++idx;
- }
- }
-
- if(!op.empty())
- {
- if(op == "--install")
- {
- //
- // Check for --display, --executable.
- //
- string display, executable;
- idx = 1;
- while(idx < argc)
- {
- if(strcmp(argv[idx], "--display") == 0)
- {
- if(idx + 1 >= argc)
- {
- error("argument expected for `" + string(argv[idx]) + "'");
- return EXIT_FAILURE;
- }
-
- display = argv[idx + 1];
-
- for(int i = idx ; i + 2 < argc ; ++i)
- {
- argv[i] = argv[i + 2];
- }
- argc -= 2;
- }
- else if(strcmp(argv[idx], "--executable") == 0)
- {
- if(idx + 1 >= argc)
- {
- error("argument expected for `" + string(argv[idx]) + "'");
- return EXIT_FAILURE;
- }
-
- executable = argv[idx + 1];
-
- for(int i = idx ; i + 2 < argc ; ++i)
- {
- argv[i] = argv[i + 2];
- }
- argc -= 2;
- }
- else
- {
- ++idx;
- }
- }
-
- vector<string> args;
- //
- // Prepend the arguments "--service NAME" so that the service
- // starts properly.
- //
- args.push_back("--service");
- args.push_back(name);
- for(idx = 1; idx < argc; ++idx)
- {
- args.push_back(argv[idx]);
- }
- try
- {
- //
- // Add the registry keys for the event logger if
- // initData.logger is empty (which is the case if the
- // user wants to use the service default logger).
- //
- return installService(!initData.logger, name, display, executable, args);
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error(ostr.str());
- return EXIT_FAILURE;
- }
- }
- else if(op == "--uninstall")
- {
- try
- {
- return uninstallService(!initData.logger, name);
- }
- catch(const Ice::Exception& ex)
- {
- ostringstream ostr;
- ostr << ex;
- error(ostr.str());
- return EXIT_FAILURE;
- }
- }
- else if(op == "--start")
- {
- vector<string> args;
- for(idx = 1; idx < argc; ++idx)
- {
- args.push_back(argv[idx]);
- }
- return startService(name, args);
- }
- else
- {
- assert(op == "--stop");
- return stopService(name);
- }
- }
-
if(!name.empty())
{
configureService(name);
@@ -913,6 +770,16 @@ Ice::Service::checkSystem() const
#endif
}
+#ifdef _WIN32
+int
+Ice::Service::run(int& argc, wchar_t* argv[], const InitializationData& initData)
+{
+ StringSeq args = Ice::argsToStringSeq(argc, argv, initData.stringConverter);
+ IceUtilInternal::ArgVector av(args);
+ return run(av.argc, av.argv, initData);
+}
+#endif
+
int
Ice::Service::run(int& argc, char* argv[], const InitializationData& initData)
{
@@ -1019,292 +886,6 @@ Ice::Service::configureService(const string& name)
_name = name;
}
-int
-Ice::Service::installService(bool useEventLogger, const string& name, const string& display, const string& executable,
- const vector<string>& args)
-{
- string disp, exec;
-
- disp = display;
- if(disp.empty())
- {
- disp = name;
- }
-
- exec = executable;
- if(exec.empty())
- {
- //
- // Use this executable if none is specified.
- //
- char buf[_MAX_PATH];
- if(GetModuleFileName(0, buf, _MAX_PATH) == 0)
- {
- error("unable to obtain file name of executable");
- return EXIT_FAILURE;
- }
- exec = buf;
- }
-
- //
- // Compose service command line. The executable and any arguments must
- // be enclosed in quotes if they contain whitespace.
- //
- string command;
- if(executable.find(' ') != string::npos)
- {
- command.push_back('"');
- command.append(exec);
- command.push_back('"');
- }
- else
- {
- command = exec;
- }
- for(vector<string>::const_iterator p = args.begin(); p != args.end(); ++p)
- {
- command.push_back(' ');
-
- if(p->find_first_of(" \t\n\r") != string::npos)
- {
- command.push_back('"');
- command.append(*p);
- command.push_back('"');
- }
- else
- {
- command.append(*p);
- }
- }
-
- SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
- if(hSCM == 0)
- {
- syserror("failure in OpenSCManager");
- return EXIT_FAILURE;
- }
- SC_HANDLE hService = CreateService(
- hSCM,
- name.c_str(),
- disp.c_str(),
- SERVICE_ALL_ACCESS,
- SERVICE_WIN32_OWN_PROCESS,
- SERVICE_AUTO_START,
- SERVICE_ERROR_NORMAL,
- command.c_str(),
- 0,
- 0,
- 0,
- 0,
- 0);
-
- if(hService == 0)
- {
- syserror("unable to install service `" + name + "'");
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- CloseServiceHandle(hSCM);
- CloseServiceHandle(hService);
-
- //
- // Add the registry keys for the event logger if _logger is
- // empty (which is the case if the user wants to use
- // the service default logger).
- //
- if(useEventLogger)
- {
- SMEventLoggerI::addKeys(name);
- }
-
- return EXIT_SUCCESS;
-}
-
-int
-Ice::Service::uninstallService(bool useEventLogger, const string& name)
-{
- SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
- if(hSCM == 0)
- {
- syserror("failure in OpenSCManager");
- return EXIT_FAILURE;
- }
-
- SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS);
- if(hService == 0)
- {
- syserror("unable to open service `" + name + "'");
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- BOOL b = DeleteService(hService);
-
- if(!b)
- {
- syserror("unable to uninstall service `" + name + "'");
- CloseServiceHandle(hSCM);
- CloseServiceHandle(hService);
- return EXIT_FAILURE;
- }
-
- CloseServiceHandle(hSCM);
- CloseServiceHandle(hService);
-
- //
- // Remove the registry keys for the event logger if necessary.
- //
- if(useEventLogger)
- {
- SMEventLoggerI::removeKeys(name);
- }
-
- return EXIT_SUCCESS;
-}
-
-int
-Ice::Service::startService(const string& name, const vector<string>& args)
-{
- SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
- if(hSCM == 0)
- {
- syserror("failure in OpenSCManager");
- return EXIT_FAILURE;
- }
-
- SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS);
- if(hService == 0)
- {
- syserror("unable to open service `" + name + "'");
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- //
- // Create argument vector. Note that StartService() automatically
- // adds the service name in argv[0], so the argv that is passed to
- // StartService() must *not* include the the service name in
- // argv[0].
- //
- const int argc = static_cast<int>(args.size());
- LPCSTR* argv = new LPCSTR[argc];
- int i = 0;
- for(vector<string>::const_iterator p = args.begin(); p != args.end(); ++p)
- {
- argv[i++] = _strdup(p->c_str());
- }
-
- //
- // Start service.
- //
- BOOL b = StartService(hService, argc, argv);
-
- //
- // Clean up argument vector.
- //
- for(i = 0; i < argc; ++i)
- {
- free(const_cast<char*>(argv[i]));
- }
- delete[] argv;
-
- if(!b)
- {
- syserror("unable to start service `" + name + "'");
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- trace("Service start pending.");
-
- //
- // Wait until the service is started or an error is detected.
- //
- SERVICE_STATUS status;
- if(!waitForServiceState(hService, SERVICE_START_PENDING, status))
- {
- syserror("unable to query status of service `" + name + "'");
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCM);
-
- if(status.dwCurrentState == SERVICE_RUNNING)
- {
- trace("Service is running.");
- }
- else
- {
- showServiceStatus("Service failed to start.", status);
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
-int
-Ice::Service::stopService(const string& name)
-{
- SC_HANDLE hSCM = OpenSCManager(0, 0, SC_MANAGER_ALL_ACCESS);
- if(hSCM == 0)
- {
- syserror("failure in OpenSCManager");
- return EXIT_FAILURE;
- }
-
- SC_HANDLE hService = OpenService(hSCM, name.c_str(), SERVICE_ALL_ACCESS);
- if(hService == 0)
- {
- syserror("unable to open service `" + name + "'");
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- SERVICE_STATUS status;
- BOOL b = ControlService(hService, SERVICE_CONTROL_STOP, &status);
-
- if(!b)
- {
- syserror("unable to stop service `" + name + "'");
- CloseServiceHandle(hSCM);
- CloseServiceHandle(hService);
- return EXIT_FAILURE;
- }
-
- trace("Service stop pending.");
-
- //
- // Wait until the service is stopped or an error is detected.
- //
- if(!waitForServiceState(hService, SERVICE_STOP_PENDING, status))
- {
- syserror("unable to query status of service `" + name + "'");
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCM);
- return EXIT_FAILURE;
- }
-
- CloseServiceHandle(hService);
- CloseServiceHandle(hSCM);
-
- if(status.dwCurrentState == SERVICE_STOPPED)
- {
- trace("Service is stopped.");
- }
- else
- {
- showServiceStatus("Service failed to stop.", status);
- return EXIT_FAILURE;
- }
-
- return EXIT_SUCCESS;
-}
-
void
Ice::Service::setModuleHandle(HMODULE module)
{
@@ -1384,10 +965,10 @@ Ice::Service::syserror(const string& msg)
}
else
{
- if(!_name.empty())
- {
- cerr << _name << ": ";
- }
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
if(!msg.empty())
{
cerr << msg << endl;
@@ -1408,11 +989,11 @@ Ice::Service::error(const string& msg)
}
else
{
- if(!_name.empty())
- {
- cerr << _name << ": ";
- }
- cerr << "error: " << msg << endl;
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
+ cerr << "error: " << msg << endl;
}
}
@@ -1425,10 +1006,10 @@ Ice::Service::warning(const string& msg)
}
else
{
- if(!_name.empty())
- {
- cerr << _name << ": ";
- }
+ if(!_name.empty())
+ {
+ cerr << _name << ": ";
+ }
cerr << "warning: " << msg << endl;
}
}
@@ -1501,16 +1082,16 @@ Ice::Service::runService(int argc, char* argv[], const InitializationData& initD
_initData = initData;
- SERVICE_TABLE_ENTRY ste[] =
+ SERVICE_TABLE_ENTRYW ste[] =
{
- { const_cast<char*>(_name.c_str()), Ice_Service_ServiceMain },
+ { const_cast<wchar_t*>(IceUtil::stringToWstring(nativeToUTF8(_initData.stringConverter, _name)).c_str()), Ice_Service_ServiceMain },
{ 0, 0 },
};
//
// Start the service.
//
- if(!StartServiceCtrlDispatcher(ste))
+ if(!StartServiceCtrlDispatcherW(ste))
{
syserror("unable to start service control dispatcher");
return EXIT_FAILURE;
@@ -1658,14 +1239,14 @@ Ice::Service::showServiceStatus(const string& msg, SERVICE_STATUS& status)
}
void
-Ice::Service::serviceMain(int argc, char* argv[])
+Ice::Service::serviceMain(int argc, wchar_t* argv[])
{
_ctrlCHandler = new IceUtil::CtrlCHandler;
//
// Register the control handler function.
//
- _statusHandle = RegisterServiceCtrlHandler(argv[0], Ice_Service_CtrlHandler);
+ _statusHandle = RegisterServiceCtrlHandlerW(argv[0], Ice_Service_CtrlHandler);
if(_statusHandle == (SERVICE_STATUS_HANDLE)0)
{
syserror("unable to register service control handler");
@@ -1685,7 +1266,7 @@ Ice::Service::serviceMain(int argc, char* argv[])
// Merge the executable's arguments with the service's arguments.
//
char** args = new char*[_serviceArgs.size() + argc];
- args[0] = argv[0];
+ args[0] = const_cast<char*>(UTF8ToNative(_initData.stringConverter, IceUtil::wstringToString(argv[0])).c_str());
int i = 1;
for(vector<string>::iterator p = _serviceArgs.begin(); p != _serviceArgs.end(); ++p)
{
@@ -1693,7 +1274,7 @@ Ice::Service::serviceMain(int argc, char* argv[])
}
for(int j = 1; j < argc; ++j)
{
- args[i++] = argv[j];
+ args[i++] = const_cast<char*>(UTF8ToNative(_initData.stringConverter, IceUtil::wstringToString(argv[j])).c_str());
}
argc += static_cast<int>(_serviceArgs.size());
@@ -1923,11 +1504,11 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
pid_t pid = fork();
if(pid < 0)
{
- if(argv[0])
- {
- cerr << argv[0] << ": ";
- }
- cerr << strerror(errno) << endl;
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
+ cerr << strerror(errno) << endl;
return EXIT_FAILURE;
}
@@ -1956,10 +1537,10 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
continue;
}
- if(argv[0])
- {
- cerr << argv[0] << ": ";
- }
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
cerr << strerror(errno) << endl;
_exit(EXIT_FAILURE);
}
@@ -1983,20 +1564,20 @@ Ice::Service::runDaemon(int argc, char* argv[], const InitializationData& initDa
continue;
}
- if(argv[0])
- {
- cerr << ": ";
- }
+ if(argv[0])
+ {
+ cerr << ": ";
+ }
cerr << "I/O error while reading error message from child:\n" << strerror(errno) << endl;
_exit(EXIT_FAILURE);
}
pos += n;
break;
}
- if(argv[0])
- {
- cerr << argv[0] << ": ";
- }
+ if(argv[0])
+ {
+ cerr << argv[0] << ": ";
+ }
cerr << "failure occurred in daemon";
if(strlen(msg) > 0)
{
diff --git a/cpp/src/Ice/TcpEndpointI.cpp b/cpp/src/Ice/TcpEndpointI.cpp
index 7eeac08f05b..7b47da856cd 100644
--- a/cpp/src/Ice/TcpEndpointI.cpp
+++ b/cpp/src/Ice/TcpEndpointI.cpp
@@ -546,10 +546,15 @@ IceInternal::TcpEndpointI::operator<(const LocalObject& r) const
Ice::Int
IceInternal::TcpEndpointI::hashInit() const
{
- Ice::Int h = 0;
+ Ice::Int h = 5381;
+ hashAdd(h, TCPEndpointType);
hashAdd(h, _host);
hashAdd(h, _port);
hashAdd(h, _timeout);
+ hashAdd(h, _protocol.major);
+ hashAdd(h, _protocol.minor);
+ hashAdd(h, _encoding.major);
+ hashAdd(h, _encoding.minor);
hashAdd(h, _connectionId);
hashAdd(h, _compress);
return h;
diff --git a/cpp/src/Ice/ThreadPool.cpp b/cpp/src/Ice/ThreadPool.cpp
index 2faf56e1538..d6114a45071 100644
--- a/cpp/src/Ice/ThreadPool.cpp
+++ b/cpp/src/Ice/ThreadPool.cpp
@@ -7,6 +7,14 @@
//
// **********************************************************************
+//
+// The following is required for MinGW to bring in
+// some definitions.
+//
+#if defined(__MINGW32__)
+# define _WIN32_WINNT 0x0501
+#endif
+
#include <Ice/ThreadPool.h>
#include <IceUtil/DisableWarnings.h>
#include <Ice/EventHandler.h>
diff --git a/cpp/src/Ice/UdpEndpointI.cpp b/cpp/src/Ice/UdpEndpointI.cpp
index 9b4c05bdf9d..c20a430bbe6 100644
--- a/cpp/src/Ice/UdpEndpointI.cpp
+++ b/cpp/src/Ice/UdpEndpointI.cpp
@@ -631,12 +631,17 @@ IceInternal::UdpEndpointI::operator<(const LocalObject& r) const
Ice::Int
IceInternal::UdpEndpointI::hashInit() const
{
- Ice::Int h = 0;
+ Ice::Int h = 5381;
+ hashAdd(h, UDPEndpointType);
hashAdd(h, _host);
hashAdd(h, _port);
hashAdd(h, _mcastInterface);
hashAdd(h, _mcastTtl);
hashAdd(h, _connect);
+ hashAdd(h, _protocol.major);
+ hashAdd(h, _protocol.minor);
+ hashAdd(h, _encoding.major);
+ hashAdd(h, _encoding.minor);
hashAdd(h, _connectionId);
hashAdd(h, _compress);
return h;
diff --git a/cpp/src/Ice/winrt/StreamEndpointI.cpp b/cpp/src/Ice/winrt/StreamEndpointI.cpp
index 1f1c030f84e..d048945f0a0 100644
--- a/cpp/src/Ice/winrt/StreamEndpointI.cpp
+++ b/cpp/src/Ice/winrt/StreamEndpointI.cpp
@@ -587,10 +587,15 @@ IceInternal::StreamEndpointI::operator<(const LocalObject& r) const
Ice::Int
IceInternal::StreamEndpointI::hashInit() const
{
- Ice::Int h = 0;
+ Ice::Int h = 5381;
+ hashAdd(h, _type);
hashAdd(h, _host);
hashAdd(h, _port);
hashAdd(h, _timeout);
+ hashAdd(h, _protocol.major);
+ hashAdd(h, _protocol.minor);
+ hashAdd(h, _encoding.major);
+ hashAdd(h, _encoding.minor);
hashAdd(h, _connectionId);
hashAdd(h, _compress);
return h;
diff --git a/cpp/src/IceBox/ServiceManagerI.cpp b/cpp/src/IceBox/ServiceManagerI.cpp
index 0a2a5908543..f91e9cd8da2 100644
--- a/cpp/src/IceBox/ServiceManagerI.cpp
+++ b/cpp/src/IceBox/ServiceManagerI.cpp
@@ -22,47 +22,18 @@ using namespace std;
typedef IceBox::Service* (*SERVICE_FACTORY)(CommunicatorPtr);
-namespace
+namespace
{
-template<class T>
-class AMICallbackT : public T
-{
-public:
-
- AMICallbackT(const ServiceManagerIPtr& serviceManager, const ServiceObserverPrx& observer) :
- _serviceManager(serviceManager),
- _observer(observer)
- {
- }
-
- virtual void ice_response()
- {
- // ok, success
- }
-
- virtual void ice_exception(const Ice::Exception& ex)
- {
- //
- // Drop this observer
- //
- _serviceManager->removeObserver(_observer, ex);
- }
-
-private:
- ServiceManagerIPtr _serviceManager;
- ServiceObserverPrx _observer;
-};
-
class PropertiesAdminI : public PropertiesAdmin
{
public:
-
+
PropertiesAdminI(const PropertiesPtr& properties) :
_properties(properties)
{
}
-
+
virtual string getProperty(const string& name, const Current&)
{
return _properties->getProperty(name);
@@ -72,10 +43,10 @@ public:
{
return _properties->getPropertiesForPrefix(prefix);
}
-
+
private:
- const PropertiesPtr _properties;
+ const PropertiesPtr _properties;
};
struct StartServiceInfo
@@ -85,28 +56,28 @@ struct StartServiceInfo
name = service;
//
- // Separate the entry point from the arguments.
+ // Split the entire property value into arguments. An entry point containing spaces
+ // must be enclosed in quotes.
//
- string::size_type pos = value.find_first_of(" \t\n");
- if(pos == string::npos)
+ try
{
- entryPoint = value;
+ args = IceUtilInternal::Options::split(value);
}
- else
+ catch(const IceUtilInternal::BadOptException& ex)
{
- entryPoint = value.substr(0, pos);
- try
- {
- args = IceUtilInternal::Options::split(value.substr(pos + 1));
- }
- catch(const IceUtilInternal::BadOptException& ex)
- {
- FailureException e(__FILE__, __LINE__);
- e.reason = "ServiceManager: invalid arguments for service `" + name + "':\n" + ex.reason;
- throw e;
- }
+ PluginInitializationException e(__FILE__, __LINE__);
+ e.reason = "invalid arguments for service `" + name + "':\n" + ex.reason;
+ throw e;
}
+ assert(!args.empty());
+
+ //
+ // Shift the arguments.
+ //
+ entryPoint = args[0];
+ args.erase(args.begin());
+
for(Ice::StringSeq::const_iterator p = serverArgs.begin(); p != serverArgs.end(); ++p)
{
if(p->find("--" + name + ".") == 0)
@@ -121,13 +92,13 @@ struct StartServiceInfo
Ice::StringSeq args;
};
-
}
-IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
+IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
_communicator(communicator),
_pendingStatusChanges(false),
- _traceServiceObserver(0)
+ _traceServiceObserver(0),
+ _observerCompletedCB(newCallback(this, &ServiceManagerI::observerCompleted))
{
_logger = _communicator->getLogger();
_traceServiceObserver = _communicator->getProperties()->getPropertyAsInt("IceBox.Trace.ServiceObserver");
@@ -197,7 +168,7 @@ IceBox::ServiceManagerI::startService(const string& name, const Current&)
Warning out(_logger);
out << "ServiceManager: unknown exception in start for service " << info.name;
}
-
+
{
IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
@@ -318,7 +289,7 @@ IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const I
{
Trace out(_logger, "IceBox.ServiceObserver");
out << "Added service observer " << _communicator->proxyToString(observer);
- }
+ }
vector<string> activeServices;
for(vector<ServiceInfo>::iterator p = _services.begin(); p != _services.end(); ++p)
@@ -329,35 +300,15 @@ IceBox::ServiceManagerI::addObserver(const ServiceObserverPrx& observer, const I
activeServices.push_back(info.name);
}
}
-
+
if(activeServices.size() > 0)
{
- observer->servicesStarted_async(new AMICallbackT<AMI_ServiceObserver_servicesStarted>(this, observer),
- activeServices);
+ observer->begin_servicesStarted(activeServices, _observerCompletedCB);
}
}
}
void
-IceBox::ServiceManagerI::removeObserver(const ServiceObserverPrx& observer, const Ice::Exception& ex)
-{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
-
- //
- // It's possible to remove several times the same observer, e.g. multiple concurrent
- // requests that fail
- //
-
- set<ServiceObserverPrx>::iterator p = _observers.find(observer);
- if(p != _observers.end())
- {
- ServiceObserverPrx observer = *p;
- _observers.erase(p);
- observerRemoved(observer, ex);
- }
-}
-
-void
IceBox::ServiceManagerI::shutdown(const Current&)
{
_communicator->shutdown();
@@ -393,7 +344,7 @@ IceBox::ServiceManagerI::start()
//
// IceBox.Service.Foo=entry_point [args]
//
- // We parse the service properties specified in IceBox.LoadOrder
+ // We parse the service properties specified in IceBox.LoadOrder
// first, then the ones from remaining services.
//
const string prefix = "IceBox.Service.";
@@ -417,7 +368,7 @@ IceBox::ServiceManagerI::start()
{
servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv));
}
-
+
//
// Check if some services are using the shared communicator in which
// case we create the shared communicator now with a property set which
@@ -464,12 +415,12 @@ IceBox::ServiceManagerI::start()
{
initData.properties->setProperty(r->first, r->second);
}
-
+
//
- // Parse <service>.* command line options (the Ice command line options
+ // Parse <service>.* command line options (the Ice command line options
// were parsed by the createProperties above)
//
- q->args = initData.properties->parseCommandLineOptions(q->name, q->args);
+ q->args = initData.properties->parseCommandLineOptions(q->name, q->args);
}
_sharedCommunicator = initialize(initData);
}
@@ -510,7 +461,7 @@ IceBox::ServiceManagerI::start()
//
// Add a Properties facet for each service
- //
+ //
for(vector<ServiceInfo>::iterator r = _services.begin(); r != _services.end(); ++r)
{
const ServiceInfo& info = *r;
@@ -518,7 +469,7 @@ IceBox::ServiceManagerI::start()
_communicator->addAdminFacet(new PropertiesAdminI(communicator->getProperties()),
"IceBox.Service." + info.name + ".Properties");
}
-
+
_communicator->getAdmin();
}
catch(const ObjectAdapterDeactivatedException&)
@@ -659,7 +610,7 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
communicator = _sharedCommunicator;
}
else
- {
+ {
//
// Create the service properties. We use the communicator properties as the default
// properties if IceBox.InheritProperties is set.
@@ -675,25 +626,25 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
initData.properties = createProperties(info.args, initData.properties);
//
- // Next, parse the service "<service>.*" command line options (the Ice command
+ // Next, parse the service "<service>.*" command line options (the Ice command
// line options were parsed by the createProperties above)
//
info.args = initData.properties->parseCommandLineOptions(service, info.args);
}
-
+
//
// Clone the logger to assign a new prefix.
//
initData.logger = _logger->cloneWithPrefix(initData.properties->getProperty("Ice.ProgramName"));
-
+
//
- // Remaining command line options are passed to the communicator. This is
+ // Remaining command line options are passed to the communicator. This is
// necessary for Ice plug-in properties (e.g.: IceSSL).
//
info.communicator = initialize(info.args, initData);
communicator = info.communicator;
}
-
+
//
// Start the service.
//
@@ -704,8 +655,8 @@ IceBox::ServiceManagerI::start(const string& service, const string& entryPoint,
//
// There is no need to notify the observers since the 'start all'
- // (that indirectly calls this function) occurs before the creation of
- // the Server Admin object, and before the activation of the main
+ // (that indirectly calls this function) occurs before the creation of
+ // the Server Admin object, and before the activation of the main
// object adapter (so before any observer can be registered)
//
}
@@ -798,7 +749,7 @@ IceBox::ServiceManagerI::stopAll()
vector<string> stoppedServices;
//
- // First, for each service, we call stop on the service and flush its database environment to
+ // First, for each service, we call stop on the service and flush its database environment to
// the disk.
//
for(p = _services.rbegin(); p != _services.rend(); ++p)
@@ -830,7 +781,7 @@ IceBox::ServiceManagerI::stopAll()
for(p = _services.rbegin(); p != _services.rend(); ++p)
{
ServiceInfo& info = *p;
-
+
try
{
_communicator->removeAdminFacet("IceBox.Service." + info.name + ".Properties");
@@ -863,9 +814,9 @@ IceBox::ServiceManagerI::stopAll()
}
//
- // Release the service, the service communicator and then the library. The order is important,
+ // Release the service, the service communicator and then the library. The order is important,
// the service must be released before destroying the communicator so that the communicator
- // leak detector doesn't report potential leaks, and the communicator must be destroyed before
+ // leak detector doesn't report potential leaks, and the communicator must be destroyed before
// the library is released since the library will destroy its global state.
//
try
@@ -898,7 +849,7 @@ IceBox::ServiceManagerI::stopAll()
out << ex;
}
}
-
+
try
{
info.library = 0;
@@ -933,6 +884,8 @@ IceBox::ServiceManagerI::stopAll()
_services.clear();
servicesStopped(stoppedServices, _observers);
+
+ _observerCompletedCB = 0; // Break cyclic reference count.
}
void
@@ -942,9 +895,7 @@ IceBox::ServiceManagerI::servicesStarted(const vector<string>& services, const s
{
for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p)
{
- ServiceObserverPrx observer = *p;
- observer->servicesStarted_async(new AMICallbackT<AMI_ServiceObserver_servicesStarted>(this, observer),
- services);
+ (*p)->begin_servicesStarted(services, _observerCompletedCB);
}
}
}
@@ -956,16 +907,14 @@ IceBox::ServiceManagerI::servicesStopped(const vector<string>& services, const s
{
for(set<ServiceObserverPrx>::const_iterator p = observers.begin(); p != observers.end(); ++p)
{
- ServiceObserverPrx observer = *p;
- observer->servicesStopped_async(new AMICallbackT<AMI_ServiceObserver_servicesStopped>(this, observer),
- services);
+ (*p)->begin_servicesStopped(services, _observerCompletedCB);
}
}
}
void
IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, const std::exception& ex)
-{
+{
if(_traceServiceObserver >= 1)
{
//
@@ -979,8 +928,8 @@ IceBox::ServiceManagerI::observerRemoved(const ServiceObserverPrx& observer, con
out << "Removed service observer " << _communicator->proxyToString(observer)
<< "\nafter catching " << ex.what();
}
- }
-}
+ }
+}
Ice::PropertiesPtr
IceBox::ServiceManagerI::createServiceProperties(const string& service)
@@ -996,7 +945,7 @@ IceBox::ServiceManagerI::createServiceProperties(const string& service)
{
properties = createProperties();
}
-
+
string programName = communicatorProperties->getProperty("Ice.ProgramName");
if(programName.empty())
{
@@ -1008,3 +957,29 @@ IceBox::ServiceManagerI::createServiceProperties(const string& service)
}
return properties;
}
+
+void
+ServiceManagerI::observerCompleted(const Ice::AsyncResultPtr& result)
+{
+ try
+ {
+ result->throwLocalException();
+ }
+ catch(const Ice::LocalException& ex)
+ {
+ ServiceObserverPrx observer = ServiceObserverPrx::uncheckedCast(result->getProxy());
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(*this);
+
+ //
+ // It's possible to remove several times the same observer, e.g. multiple concurrent
+ // requests that fail
+ //
+ set<ServiceObserverPrx>::iterator p = _observers.find(observer);
+ if(p != _observers.end())
+ {
+ ServiceObserverPrx observer = *p;
+ _observers.erase(p);
+ observerRemoved(observer, ex);
+ }
+ }
+}
diff --git a/cpp/src/IceBox/ServiceManagerI.h b/cpp/src/IceBox/ServiceManagerI.h
index a613ae1b3f8..9c381941b49 100644
--- a/cpp/src/IceBox/ServiceManagerI.h
+++ b/cpp/src/IceBox/ServiceManagerI.h
@@ -39,7 +39,7 @@ public:
bool start();
void stop();
- void removeObserver(const ServiceObserverPrx&, const Ice::Exception&);
+ void observerCompleted(const Ice::AsyncResultPtr&);
private:
@@ -80,6 +80,7 @@ private:
std::set<ServiceObserverPrx> _observers;
int _traceServiceObserver;
+ ::Ice::CallbackPtr _observerCompletedCB;
};
typedef IceUtil::Handle<ServiceManagerI> ServiceManagerIPtr;
diff --git a/cpp/src/IceGrid/Activator.cpp b/cpp/src/IceGrid/Activator.cpp
index 628978b6488..10d0f20d66b 100644
--- a/cpp/src/IceGrid/Activator.cpp
+++ b/cpp/src/IceGrid/Activator.cpp
@@ -786,6 +786,40 @@ Activator::activate(const string& name,
#endif
}
+namespace
+{
+
+class ShutdownCallback : public IceUtil::Shared
+{
+public:
+
+ ShutdownCallback(const ActivatorPtr& activator, const string& name, const TraceLevelsPtr& traceLevels) :
+ _activator(activator), _name(name), _traceLevels(traceLevels)
+ {
+
+ }
+
+ virtual void
+ exception(const Ice::Exception& ex)
+ {
+ Ice::Warning out(_traceLevels->logger);
+ out << "exception occurred while deactivating `" << _name << "' using process proxy:\n" << ex;
+
+ //
+ // Send a SIGTERM to the process.
+ //
+ _activator->sendSignal(_name, SIGTERM);
+ }
+
+private:
+
+ const ActivatorPtr _activator;
+ const string _name;
+ const TraceLevelsPtr _traceLevels;
+};
+
+}
+
void
Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
{
@@ -800,44 +834,6 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
}
#endif
- class ShutdownCallback : public Ice::AMI_Process_shutdown
- {
- public:
-
- ShutdownCallback(const ActivatorPtr& activator, const string& name, const TraceLevelsPtr& traceLevels) :
- _activator(activator), _name(name), _traceLevels(traceLevels)
- {
-
- }
-
- virtual void
- ice_response()
- {
- //
- // Nothing to do, server successfully shutdown, the activator will detect it
- // once the pipe is closed.
- //
- }
-
- virtual void
- ice_exception(const Ice::Exception& ex)
- {
- Ice::Warning out(_traceLevels->logger);
- out << "exception occurred while deactivating `" << _name << "' using process proxy:\n" << ex;
-
- //
- // Send a SIGTERM to the process.
- //
- _activator->sendSignal(_name, SIGTERM);
- }
-
- private:
-
- const ActivatorPtr _activator;
- const string _name;
- const TraceLevelsPtr _traceLevels;
- };
-
//
// Try to shut down the server gracefully using the process proxy.
//
@@ -848,8 +844,8 @@ Activator::deactivate(const string& name, const Ice::ProcessPrx& process)
Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "deactivating `" << name << "' using process proxy";
}
-
- process->shutdown_async(new ShutdownCallback(this, name, _traceLevels));
+ process->begin_shutdown(Ice::newCallback_Process_shutdown(new ShutdownCallback(this, name, _traceLevels),
+ &ShutdownCallback::exception));
return;
}
diff --git a/cpp/src/IceGrid/AdminCallbackRouter.cpp b/cpp/src/IceGrid/AdminCallbackRouter.cpp
index 2fc00ab89c9..bb68190a233 100644
--- a/cpp/src/IceGrid/AdminCallbackRouter.cpp
+++ b/cpp/src/IceGrid/AdminCallbackRouter.cpp
@@ -12,35 +12,20 @@
using namespace Ice;
using namespace std;
-namespace
+void
+IceGrid::AdminCallbackRouter::invokeResponse(bool ok, const std::pair<const Byte*, const Byte*>& outParams,
+ const InvokeCookiePtr& cookie)
{
+ cookie->cb()->ice_response(ok, outParams);
+}
-class InvokeAMICallback : public AMI_Array_Object_ice_invoke
+void
+IceGrid::AdminCallbackRouter::invokeException(const Ice::Exception&, const InvokeCookiePtr& cookie)
{
-public:
-
- InvokeAMICallback(const AMD_Object_ice_invokePtr& cb) :
- _cb(cb)
- {
- }
-
- virtual void ice_response(bool ok, const std::pair<const Byte*, const Byte*>& outParams)
- {
- _cb->ice_response(ok, outParams);
- }
-
- virtual void ice_exception(const Ice::Exception&)
- {
- _cb->ice_exception(ObjectNotExistException(__FILE__, __LINE__)); // Callback object is unreachable.
- }
-
-private:
- AMD_Object_ice_invokePtr _cb;
-};
-
+ // Callback object is unreachable.
+ cookie->cb()->ice_exception(ObjectNotExistException(__FILE__, __LINE__));
}
-
void
IceGrid::AdminCallbackRouter::addMapping(const string& category, const ConnectionPtr& con)
{
@@ -92,6 +77,11 @@ IceGrid::AdminCallbackRouter::ice_invoke_async(const AMD_Object_ice_invokePtr& c
//
// Call with AMI
//
- target->ice_invoke_async(new InvokeAMICallback(cb), current.operation, current.mode, inParams, current.ctx);
+ target->begin_ice_invoke(current.operation, current.mode, inParams, current.ctx,
+ newCallback_Object_ice_invoke(
+ this,
+ &AdminCallbackRouter::invokeResponse,
+ &AdminCallbackRouter::invokeException),
+ new InvokeCookie(cb));
}
diff --git a/cpp/src/IceGrid/AdminCallbackRouter.h b/cpp/src/IceGrid/AdminCallbackRouter.h
index 0affceba9ef..8ae022f5759 100644
--- a/cpp/src/IceGrid/AdminCallbackRouter.h
+++ b/cpp/src/IceGrid/AdminCallbackRouter.h
@@ -28,6 +28,30 @@ public:
void addMapping(const std::string&, const Ice::ConnectionPtr&);
void removeMapping(const std::string&);
+ class InvokeCookie : public Ice::LocalObject
+ {
+ public:
+
+ InvokeCookie(const Ice::AMD_Object_ice_invokePtr& cb) :
+ _cb(cb)
+ {
+ }
+
+ Ice::AMD_Object_ice_invokePtr cb()
+ {
+ return _cb;
+ }
+
+ private:
+
+ Ice::AMD_Object_ice_invokePtr _cb;
+ };
+ typedef IceUtil::Handle<InvokeCookie> InvokeCookiePtr;
+
+ virtual void invokeResponse(bool, const std::pair<const ::Ice::Byte*, const ::Ice::Byte*>&,
+ const InvokeCookiePtr&);
+
+ virtual void invokeException(const Ice::Exception&, const InvokeCookiePtr&);
virtual void ice_invoke_async(const Ice::AMD_Object_ice_invokePtr&,
const std::pair<const Ice::Byte*, const Ice::Byte*>&,
diff --git a/cpp/src/IceGrid/AdminI.cpp b/cpp/src/IceGrid/AdminI.cpp
index 5c832e4f4a5..7453a93902b 100644
--- a/cpp/src/IceGrid/AdminI.cpp
+++ b/cpp/src/IceGrid/AdminI.cpp
@@ -394,100 +394,115 @@ AdminI::getServerAdmin(const string& id, const Current& current) const
return current.adapter->createProxy(adminId);
}
-void
-AdminI::startServer_async(const AMD_Admin_startServerPtr& amdCB, const string& id, const Current&)
+namespace
{
- ServerProxyWrapper proxy(_database, id);
- proxy.useActivationTimeout();
- class StartCB : public AMI_Server_start
+class StartCB : virtual public IceUtil::Shared
+{
+public:
+
+ StartCB(const ServerProxyWrapper& proxy, const AMD_Admin_startServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB)
{
- public:
+ }
- StartCB(const ServerProxyWrapper& proxy, const AMD_Admin_startServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB)
- {
- }
+ virtual void
+ response()
+ {
+ _amdCB->ice_response();
+ }
- virtual void
- ice_response()
+ virtual void
+ exception(const Ice::Exception& ex)
+ {
+ try
{
- _amdCB->ice_response();
+ _proxy.handleException(ex);
+ assert(false);
}
-
- virtual void
- ice_exception(const Ice::Exception& ex)
+ catch(const Ice::Exception& ex)
{
- try
- {
- _proxy.handleException(ex);
- assert(false);
- }
- catch(const Ice::Exception& ex)
- {
- _amdCB->ice_exception(ex);
- }
+ _amdCB->ice_exception(ex);
}
+ }
- private:
+private:
+
+ const ServerProxyWrapper _proxy;
+ const AMD_Admin_startServerPtr _amdCB;
+};
+
+}
+
+
+void
+AdminI::startServer_async(const AMD_Admin_startServerPtr& amdCB, const string& id, const Current&)
+{
+ ServerProxyWrapper proxy(_database, id);
+ proxy.useActivationTimeout();
- const ServerProxyWrapper _proxy;
- const AMD_Admin_startServerPtr _amdCB;
- };
-
//
// Since the server might take a while to be activated, we use AMI.
//
- proxy->start_async(new StartCB(proxy, amdCB));
+ proxy->begin_start(newCallback_Server_start(new StartCB(proxy, amdCB),
+ &StartCB::response,
+ &StartCB::exception));
}
-void
-AdminI::stopServer_async(const AMD_Admin_stopServerPtr& amdCB, const string& id, const Current&)
+namespace
{
- ServerProxyWrapper proxy(_database, id);
- proxy.useDeactivationTimeout();
- class StopCB : public AMI_Server_stop
+class StopCB : virtual public IceUtil::Shared
+{
+public:
+
+ StopCB(const ServerProxyWrapper& proxy, const AMD_Admin_stopServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB)
+ {
+ }
+
+ virtual void
+ response()
{
- public:
+ _amdCB->ice_response();
+ }
- StopCB(const ServerProxyWrapper& proxy, const AMD_Admin_stopServerPtr& amdCB) : _proxy(proxy), _amdCB(amdCB)
+ virtual void
+ exception(const Ice::Exception& ex)
+ {
+ try
{
+ _proxy.handleException(ex);
+ assert(false);
}
-
- virtual void
- ice_response()
+ catch(const Ice::TimeoutException&)
{
_amdCB->ice_response();
}
-
- virtual void
- ice_exception(const Ice::Exception& ex)
+ catch(const Ice::Exception& ex)
{
- try
- {
- _proxy.handleException(ex);
- assert(false);
- }
- catch(const Ice::TimeoutException&)
- {
- _amdCB->ice_response();
- }
- catch(const Ice::Exception& ex)
- {
- _amdCB->ice_exception(ex);
- }
+ _amdCB->ice_exception(ex);
}
+ }
- private:
+private:
- const ServerProxyWrapper _proxy;
- const AMD_Admin_stopServerPtr _amdCB;
- };
+ const ServerProxyWrapper _proxy;
+ const AMD_Admin_stopServerPtr _amdCB;
+};
+
+}
+
+void
+AdminI::stopServer_async(const AMD_Admin_stopServerPtr& amdCB, const string& id, const Current&)
+{
+ ServerProxyWrapper proxy(_database, id);
+ proxy.useDeactivationTimeout();
//
// Since the server might take a while to be deactivated, we use AMI.
//
- proxy->stop_async(new StopCB(proxy, amdCB));
+ proxy->begin_stop(newCallback_Server_stop(new StopCB(proxy, amdCB),
+ &StopCB::response,
+ &StopCB::exception));
}
void
diff --git a/cpp/src/IceGrid/Internal.ice b/cpp/src/IceGrid/Internal.ice
index ed90c4c757b..1362ff7bbe7 100644
--- a/cpp/src/IceGrid/Internal.ice
+++ b/cpp/src/IceGrid/Internal.ice
@@ -149,7 +149,7 @@ interface Adapter
* adapter direct proxy it's active.
*
**/
- ["ami", "amd"] Object* activate();
+ ["amd"] Object* activate();
/**
*
@@ -161,7 +161,7 @@ interface Adapter
* endpoints if the adapter is already active.
*
**/
- ["ami", "nonmutating", "cpp:const"] idempotent Object* getDirectProxy()
+ ["nonmutating", "cpp:const"] idempotent Object* getDirectProxy()
throws AdapterNotActiveException;
/**
@@ -177,7 +177,7 @@ interface Adapter
* active adapter.
*
**/
- ["ami"] void setDirectProxy(Object* proxy)
+ void setDirectProxy(Object* proxy)
throws AdapterActiveException;
};
@@ -224,7 +224,7 @@ interface Server extends FileReader
* otherwise.
*
**/
- ["amd", "ami"] void start()
+ ["amd"] void start()
throws ServerStartException;
/**
@@ -234,7 +234,7 @@ interface Server extends FileReader
* amount of time, it will be killed.
*
**/
- ["amd", "ami"] void stop()
+ ["amd"] void stop()
throws ServerStopException;
/**
@@ -292,7 +292,7 @@ interface Server extends FileReader
* Set the process proxy.
*
**/
- ["ami", "amd"] void setProcess(Ice::Process* proc);
+ ["amd"] void setProcess(Ice::Process* proc);
};
interface InternalRegistry;
@@ -350,7 +350,7 @@ interface Node extends FileReader, ReplicaObserver
* they will be created.
*
**/
- ["amd", "ami"] idempotent Server* loadServer(InternalServerDescriptor svr,
+ ["amd"] idempotent Server* loadServer(InternalServerDescriptor svr,
string replicaName,
out AdapterPrxDict adapters,
out int actTimeout,
@@ -362,7 +362,7 @@ interface Node extends FileReader, ReplicaObserver
* Destroy the given server.
*
**/
- ["amd", "ami"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName)
+ ["amd"] idempotent void destroyServer(string name, string uuid, int revision, string replicaName)
throws DeploymentException;
/**
@@ -386,7 +386,7 @@ interface Node extends FileReader, ReplicaObserver
* replicaAdded below).
*
**/
- ["ami"] void registerWithReplica(InternalRegistry* replica);
+ void registerWithReplica(InternalRegistry* replica);
/**
*
@@ -492,7 +492,7 @@ interface NodeSession
* of the server.
*
**/
- ["amd", "ami", "cpp:const"] void waitForApplicationUpdate(string application, int revision);
+ ["amd", "cpp:const"] void waitForApplicationUpdate(string application, int revision);
/**
*
@@ -572,7 +572,7 @@ interface ReplicaSession
* the locator registry interface.
*
**/
- ["ami"] idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy)
+ idempotent void setAdapterDirectProxy(string adapterId, string replicaGroupId, Object* proxy)
throws AdapterNotExistException, AdapterExistsException;
/**
diff --git a/cpp/src/IceGrid/LocatorI.cpp b/cpp/src/IceGrid/LocatorI.cpp
index 6583980e948..ddcc8601758 100644
--- a/cpp/src/IceGrid/LocatorI.cpp
+++ b/cpp/src/IceGrid/LocatorI.cpp
@@ -22,22 +22,22 @@ namespace IceGrid
//
// Callback from asynchronous call to adapter->getDirectProxy() invoked in LocatorI::findAdapterById_async().
//
-class AMI_Adapter_getDirectProxyI : public AMI_Adapter_getDirectProxy
+class AdapterGetDirectProxyCallback : virtual public IceUtil::Shared
{
public:
- AMI_Adapter_getDirectProxyI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
+ AdapterGetDirectProxyCallback(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
_locator(locator), _adapter(adapter)
{
}
- virtual void ice_response(const ::Ice::ObjectPrx& obj)
+ virtual void response(const ::Ice::ObjectPrx& obj)
{
assert(obj);
_locator->getDirectProxyResponse(_adapter, obj);
}
- virtual void ice_exception(const ::Ice::Exception& e)
+ virtual void exception(const ::Ice::Exception& e)
{
_locator->getDirectProxyException(_adapter, e);
}
@@ -48,21 +48,21 @@ private:
const LocatorAdapterInfo _adapter;
};
-class AMI_Adapter_activateI : public AMI_Adapter_activate
+class AdapterActivateCallback : virtual public IceUtil::Shared
{
public:
- AMI_Adapter_activateI(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
+ AdapterActivateCallback(const LocatorIPtr& locator, const LocatorAdapterInfo& adapter) :
_locator(locator), _adapter(adapter)
{
}
- virtual void ice_response(const ::Ice::ObjectPrx& obj)
+ virtual void response(const ::Ice::ObjectPrx& obj)
{
_locator->getDirectProxyResponse(_adapter, obj);
}
- virtual void ice_exception(const ::Ice::Exception& ex)
+ virtual void exception(const ::Ice::Exception& ex)
{
_locator->getDirectProxyException(_adapter, ex);
}
@@ -936,8 +936,10 @@ LocatorI::getDirectProxy(const LocatorAdapterInfo& adapter, const RequestPtr& re
requests.push_back(request);
_pendingRequests.insert(make_pair(adapter.id, requests));
}
-
- adapter.proxy->getDirectProxy_async(new AMI_Adapter_getDirectProxyI(this, adapter));
+ adapter.proxy->begin_getDirectProxy(newCallback_Adapter_getDirectProxy(
+ new AdapterGetDirectProxyCallback(this, adapter),
+ &AdapterGetDirectProxyCallback::response,
+ &AdapterGetDirectProxyCallback::exception));
return false;
}
@@ -1011,9 +1013,11 @@ LocatorI::getDirectProxyException(const LocatorAdapterInfo& adapter, const Ice::
(*q)->activating(adapter.id);
}
- 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);
+ AdapterPrx::uncheckedCast(adapter.proxy->ice_timeout(timeout * 1000))->begin_activate(
+ newCallback_Adapter_activate(new AdapterActivateCallback(this, adapter),
+ &AdapterActivateCallback::response,
+ &AdapterActivateCallback::exception));
}
else
{
diff --git a/cpp/src/IceGrid/LocatorRegistryI.cpp b/cpp/src/IceGrid/LocatorRegistryI.cpp
index 994d84d0141..6620222da4a 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.cpp
+++ b/cpp/src/IceGrid/LocatorRegistryI.cpp
@@ -20,7 +20,7 @@ namespace IceGrid
{
template<class AmdCB>
-class SetDirectProxyCB : public AMI_Adapter_setDirectProxy
+class SetDirectProxyCB : public LocatorRegistryI::AdapterSetDirectProxyCB
{
public:
@@ -32,7 +32,7 @@ public:
{
}
- virtual void ice_response()
+ virtual void response()
{
if(_traceLevels->locator > 1)
{
@@ -43,7 +43,7 @@ public:
_cb->ice_response();
}
- virtual void ice_exception(const ::Ice::Exception& ex)
+ virtual void exception(const ::Ice::Exception& ex)
{
if(_traceLevels->locator > 1)
{
@@ -88,14 +88,14 @@ newSetDirectProxyCB(const AmdCB& cb, const TraceLevelsPtr& traceLevels, const st
return new SetDirectProxyCB<AmdCB>(cb, traceLevels, id, p);
}
-class AMI_Server_setProcessI : public AMI_Server_setProcess
+class ServerSetProcessCB : virtual public IceUtil::Shared
{
public:
- AMI_Server_setProcessI(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
- const TraceLevelsPtr& traceLevels,
- const string& id,
- const Ice::ObjectPrx& proxy) :
+ ServerSetProcessCB(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr& cb,
+ const TraceLevelsPtr& traceLevels,
+ const string& id,
+ const Ice::ObjectPrx& proxy) :
_cb(cb), _traceLevels(traceLevels), _id(id), _proxy(proxy)
{
}
@@ -145,13 +145,14 @@ private:
const string _id;
const Ice::ObjectPrx _proxy;
};
+typedef IceUtil::Handle<ServerSetProcessCB> ServerSetProcessCBPtr;
class SetAdapterDirectProxyCallback : public SynchronizationCallback
{
public:
SetAdapterDirectProxyCallback(const LocatorRegistryIPtr& registry,
- const AMI_Adapter_setDirectProxyPtr& amiCB,
+ const LocatorRegistryI::AdapterSetDirectProxyCBPtr& amiCB,
const string& adapterId,
const string& replicaGroupId,
const Ice::ObjectPrx& proxy) :
@@ -168,7 +169,7 @@ public:
}
catch(const Ice::Exception& ex)
{
- _amiCB->ice_exception(ex);
+ _amiCB->exception(ex);
}
}
@@ -181,14 +182,14 @@ public:
}
catch(const Ice::Exception& ex)
{
- _amiCB->ice_exception(ex);
+ _amiCB->exception(ex);
}
}
private:
const LocatorRegistryIPtr _registry;
- const AMI_Adapter_setDirectProxyPtr _amiCB;
+ const LocatorRegistryI::AdapterSetDirectProxyCBPtr _amiCB;
const string _adapterId;
const string _replicaGroupId;
const Ice::ObjectPrx _proxy;
@@ -322,8 +323,10 @@ LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_set
}
}
- AMI_Server_setProcessPtr amiCB = new AMI_Server_setProcessI(cb, _database->getTraceLevels(), id, proxy);
- server->setProcess_async(amiCB, proxy);
+ server->begin_setProcess(proxy, IceGrid::newCallback_Server_setProcess(
+ new ServerSetProcessCB(cb, _database->getTraceLevels(), id, proxy),
+ &ServerSetProcessCB::ice_response,
+ &ServerSetProcessCB::ice_exception));
}
catch(const ServerNotExistException&)
{
@@ -342,7 +345,7 @@ LocatorRegistryI::setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_set
}
void
-LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& amiCB,
+LocatorRegistryI::setAdapterDirectProxy(const LocatorRegistryI::AdapterSetDirectProxyCBPtr& amiCB,
const string& adapterId,
const string& replicaGroupId,
const Ice::ObjectPrx& proxy)
@@ -352,7 +355,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami
//
if(adapterId.empty())
{
- amiCB->ice_response();
+ amiCB->response();
return;
}
@@ -386,7 +389,9 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami
}
}
- adapter->setDirectProxy_async(amiCB, proxy);
+ adapter->begin_setDirectProxy(proxy, IceGrid::newCallback_Adapter_setDirectProxy(amiCB,
+ &LocatorRegistryI::AdapterSetDirectProxyCB::response,
+ &LocatorRegistryI::AdapterSetDirectProxyCB::exception));
return;
}
catch(const AdapterNotExistException&)
@@ -413,7 +418,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami
try
{
_database->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
+ amiCB->response();
return;
}
catch(const AdapterExistsException&)
@@ -439,7 +444,7 @@ LocatorRegistryI::setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr& ami
try
{
session->setAdapterDirectProxy(adapterId, replicaGroupId, proxy);
- amiCB->ice_response();
+ amiCB->response();
return;
}
catch(const AdapterExistsException&)
diff --git a/cpp/src/IceGrid/LocatorRegistryI.h b/cpp/src/IceGrid/LocatorRegistryI.h
index 44bc8e7007d..b20ad40ccbc 100644
--- a/cpp/src/IceGrid/LocatorRegistryI.h
+++ b/cpp/src/IceGrid/LocatorRegistryI.h
@@ -11,6 +11,7 @@
#include <IceGrid/Internal.h>
#include <Ice/Locator.h>
+#include <IceUtil/Shared.h>
namespace IceGrid
{
@@ -26,6 +27,15 @@ class ReplicaSessionManager;
class LocatorRegistryI : public Ice::LocatorRegistry
{
public:
+
+ class AdapterSetDirectProxyCB : virtual public IceUtil::Shared
+ {
+ public:
+
+ virtual void response() = 0;
+ virtual void exception(const ::Ice::Exception&) = 0;
+ };
+ typedef IceUtil::Handle<AdapterSetDirectProxyCB> AdapterSetDirectProxyCBPtr;
LocatorRegistryI(const DatabasePtr&, bool, bool, ReplicaSessionManager&);
@@ -39,7 +49,7 @@ public:
virtual void setServerProcessProxy_async(const Ice::AMD_LocatorRegistry_setServerProcessProxyPtr&,
const ::std::string&, const ::Ice::ProcessPrx&, const ::Ice::Current&);
- void setAdapterDirectProxy(const AMI_Adapter_setDirectProxyPtr&, const std::string&, const std::string&,
+ void setAdapterDirectProxy(const AdapterSetDirectProxyCBPtr&, const std::string&, const std::string&,
const Ice::ObjectPrx&);
const TraceLevelsPtr& getTraceLevels() const;
diff --git a/cpp/src/IceGrid/NodeCache.cpp b/cpp/src/IceGrid/NodeCache.cpp
index c3c14d92789..e03a74e51d9 100644
--- a/cpp/src/IceGrid/NodeCache.cpp
+++ b/cpp/src/IceGrid/NodeCache.cpp
@@ -178,7 +178,7 @@ struct ToInternalServerDescriptor : std::unary_function<CommunicatorDescriptorPt
int _iceVersion;
};
-class LoadCB : public AMI_Node_loadServer
+class LoadCB : virtual public IceUtil::Shared
{
public:
@@ -191,7 +191,7 @@ public:
}
void
- ice_response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt)
+ response(const ServerPrx& server, const AdapterPrxDict& adapters, int at, int dt)
{
if(_traceLevels && _traceLevels->server > 1)
{
@@ -207,7 +207,7 @@ public:
}
void
- ice_exception(const Ice::Exception& ex)
+ exception(const Ice::Exception& ex)
{
try
{
@@ -248,7 +248,7 @@ private:
const int _timeout;
};
-class DestroyCB : public AMI_Node_destroyServer
+class DestroyCB : virtual public IceUtil::Shared
{
public:
@@ -258,7 +258,7 @@ public:
}
void
- ice_response()
+ response()
{
if(_traceLevels && _traceLevels->server > 1)
{
@@ -269,7 +269,7 @@ public:
}
void
- ice_exception(const Ice::Exception& ex)
+ exception(const Ice::Exception& ex)
{
try
{
@@ -308,31 +308,7 @@ private:
const string _node;
};
-class RegisterCB : public AMI_Node_registerWithReplica
-{
-public:
-
- RegisterCB(const NodeEntryPtr& node) : _node(node)
- {
- }
-
- void
- ice_response()
- {
- _node->finishedRegistration();
- }
-
- void
- ice_exception(const Ice::Exception& ex)
- {
- _node->finishedRegistration(ex);
- }
-
-private:
- const NodeEntryPtr _node;
-};
-
-};
+}
NodeCache::NodeCache(const Ice::CommunicatorPtr& communicator, ReplicaCache& replicaCache, const string& replicaName) :
_communicator(communicator),
@@ -625,8 +601,11 @@ NodeEntry::loadServer(const ServerEntryPtr& entry, const ServerInfo& server, con
}
}
- AMI_Node_loadServerPtr amiCB = new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout);
- node->loadServer_async(amiCB, desc, _cache.getReplicaName());
+ node->begin_loadServer(desc, _cache.getReplicaName(),
+ newCallback_Node_loadServer(
+ new LoadCB(_cache.getTraceLevels(), entry, _name, sessionTimeout),
+ &LoadCB::response,
+ &LoadCB::exception));
}
catch(const NodeUnreachableException& ex)
{
@@ -663,8 +642,10 @@ NodeEntry::destroyServer(const ServerEntryPtr& entry, const ServerInfo& info, in
out << "unloading `" << info.descriptor->id << "' on node `" << _name << "'";
}
- AMI_Node_destroyServerPtr amiCB = new DestroyCB(_cache.getTraceLevels(), entry, _name);
- node->destroyServer_async(amiCB, info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName());
+ node->begin_destroyServer(info.descriptor->id, info.uuid, info.revision, _cache.getReplicaName(),
+ newCallback_Node_destroyServer(new DestroyCB(_cache.getTraceLevels(), entry, _name),
+ &DestroyCB::response,
+ &DestroyCB::exception));
}
catch(const NodeUnreachableException& ex)
{
@@ -794,7 +775,10 @@ NodeEntry::checkSession() const
//
_registering = true;
NodeEntry* self = const_cast<NodeEntry*>(this);
- _proxy->registerWithReplica_async(new RegisterCB(self), _cache.getReplicaCache().getInternalRegistry());
+ _proxy->begin_registerWithReplica(_cache.getReplicaCache().getInternalRegistry(),
+ newCallback_Node_registerWithReplica(self,
+ &NodeEntry::finishedRegistration,
+ &NodeEntry::finishedRegistration));
_proxy = 0; // Registration with the proxy is only attempted once.
}
diff --git a/cpp/src/IceGrid/NodeI.cpp b/cpp/src/IceGrid/NodeI.cpp
index 2a44b98dbdb..1c03de9c4fa 100644
--- a/cpp/src/IceGrid/NodeI.cpp
+++ b/cpp/src/IceGrid/NodeI.cpp
@@ -188,7 +188,7 @@ private:
string _dest;
};
-class NodeUp : public NodeI::Update, public AMI_NodeObserver_nodeUp
+class NodeUp : public NodeI::Update
{
public:
@@ -202,7 +202,7 @@ public:
{
try
{
- _observer->nodeUp_async(this, _info);
+ _observer->begin_nodeUp(_info, newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed));
}
catch(const Ice::LocalException&)
{
@@ -210,25 +210,13 @@ public:
}
return true;
}
-
- virtual void
- ice_response()
- {
- finished(true);
- }
-
- virtual void
- ice_exception(const Ice::Exception&)
- {
- finished(false);
- }
private:
NodeDynamicInfo _info;
};
-class UpdateServer : public NodeI::Update, public AMI_NodeObserver_updateServer
+class UpdateServer : public NodeI::Update
{
public:
@@ -242,7 +230,9 @@ public:
{
try
{
- _observer->updateServer_async(this, _node->getName(), _info);
+ _observer->begin_updateServer(_node->getName(),
+ _info,
+ newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed));
}
catch(const Ice::LocalException&)
{
@@ -250,25 +240,13 @@ public:
}
return true;
}
-
- virtual void
- ice_response()
- {
- finished(true);
- }
-
- virtual void
- ice_exception(const Ice::Exception&)
- {
- finished(false);
- }
private:
ServerDynamicInfo _info;
};
-class UpdateAdapter : public NodeI::Update, public AMI_NodeObserver_updateAdapter
+class UpdateAdapter : public NodeI::Update
{
public:
@@ -282,7 +260,9 @@ public:
{
try
{
- _observer->updateAdapter_async(this, _node->getName(), _info);
+ _observer->begin_updateAdapter(_node->getName(),
+ _info,
+ newCallback(static_cast<NodeI::Update*>(this), &NodeI::Update::completed));
}
catch(const Ice::LocalException&)
{
@@ -290,18 +270,6 @@ public:
}
return true;
}
-
- virtual void
- ice_response()
- {
- finished(true);
- }
-
- virtual void
- ice_exception(const Ice::Exception&)
- {
- finished(false);
- }
private:
@@ -384,6 +352,20 @@ NodeI::NodeI(const Ice::ObjectAdapterPtr& adapter,
}
}
+void
+NodeI::Update::completed(const Ice::AsyncResultPtr& result)
+{
+ try
+ {
+ result->throwLocalException();
+ finished(true);
+ }
+ catch(const Ice::LocalException&)
+ {
+ finished(false);
+ }
+}
+
NodeI::~NodeI()
{
}
diff --git a/cpp/src/IceGrid/NodeI.h b/cpp/src/IceGrid/NodeI.h
index 4d29d853147..508de0f2a48 100644
--- a/cpp/src/IceGrid/NodeI.h
+++ b/cpp/src/IceGrid/NodeI.h
@@ -40,6 +40,7 @@ typedef IceUtil::Handle<NodeI> NodeIPtr;
class NodeI : public Node, public IceUtil::Monitor<IceUtil::Mutex>
{
public:
+
class Update : virtual public IceUtil::Shared
{
public:
@@ -50,6 +51,8 @@ public:
virtual bool send() = 0;
void finished(bool);
+
+ void completed(const Ice::AsyncResultPtr&);
protected:
diff --git a/cpp/src/IceGrid/ServerI.cpp b/cpp/src/IceGrid/ServerI.cpp
index 1eb80d965f3..4db7ef92f78 100755
--- a/cpp/src/IceGrid/ServerI.cpp
+++ b/cpp/src/IceGrid/ServerI.cpp
@@ -248,31 +248,6 @@ private:
const TraceLevelsPtr _traceLevels;
};
-class WaitForApplicationUpdateCB : public AMI_NodeSession_waitForApplicationUpdate
-{
-public:
-
- WaitForApplicationUpdateCB(const ServerIPtr& server) : _server(server)
- {
- }
-
- virtual void
- ice_response()
- {
- _server->activate();
- }
-
- virtual void
- ice_exception(const Ice::Exception&)
- {
- _server->activate();
- }
-
-private:
-
- const ServerIPtr _server;
-};
-
struct EnvironmentEval : std::unary_function<string, string>
{
@@ -697,6 +672,12 @@ ServerI::~ServerI()
}
void
+ServerI::waitForApplicationUpdateCompleted(const Ice::AsyncResultPtr&)
+{
+ activate();
+}
+
+void
ServerI::start_async(const AMD_Server_startPtr& amdCB, const Ice::Current&)
{
start(Manual, amdCB);
@@ -1406,8 +1387,8 @@ ServerI::activate()
NodeSessionPrx session = _node->getMasterNodeSession();
if(session)
{
- AMI_NodeSession_waitForApplicationUpdatePtr cb = new WaitForApplicationUpdateCB(this);
- _node->getMasterNodeSession()->waitForApplicationUpdate_async(cb, desc->uuid, desc->revision);
+ _node->getMasterNodeSession()->begin_waitForApplicationUpdate(
+ desc->uuid, desc->revision, ::Ice::newCallback(this, &ServerI::waitForApplicationUpdateCompleted));
return;
}
}
diff --git a/cpp/src/IceGrid/ServerI.h b/cpp/src/IceGrid/ServerI.h
index f033a4d8bec..e40cd51c877 100644
--- a/cpp/src/IceGrid/ServerI.h
+++ b/cpp/src/IceGrid/ServerI.h
@@ -71,6 +71,8 @@ public:
ServerI(const NodeIPtr&, const ServerPrx&, const std::string&, const std::string&, int);
virtual ~ServerI();
+ void waitForApplicationUpdateCompleted(const Ice::AsyncResultPtr&);
+
virtual void start_async(const AMD_Server_startPtr&, const ::Ice::Current& = Ice::Current());
virtual void stop_async(const AMD_Server_stopPtr&, const ::Ice::Current& = Ice::Current());
virtual void sendSignal(const std::string&, const ::Ice::Current&);
diff --git a/cpp/src/IcePatch2Lib/ClientUtil.cpp b/cpp/src/IcePatch2Lib/ClientUtil.cpp
index 4196200775b..78aa0776d3e 100755
--- a/cpp/src/IcePatch2Lib/ClientUtil.cpp
+++ b/cpp/src/IcePatch2Lib/ClientUtil.cpp
@@ -241,66 +241,6 @@ private:
const PatcherFeedbackPtr _feedback;
};
-class AMIGetFileInfoSeq : public AMI_FileServer_getFileInfoSeq, public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- AMIGetFileInfoSeq() :
- _done(false)
- {
- }
-
- FileInfoSeq
- getFileInfoSeq()
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(!_done)
- {
- wait();
- }
-
- _done = false;
-
- if(_exception.get())
- {
- auto_ptr<Exception> ex = _exception;
- _fileInfoSeq.clear();
- ex->ice_throw();
- }
-
- FileInfoSeq fileInfoSeq;
- fileInfoSeq.swap(_fileInfoSeq);
- return fileInfoSeq;
- }
-
- virtual void
- ice_response(const FileInfoSeq& fileInfoSeq)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- _fileInfoSeq = fileInfoSeq;
- _done = true;
- notify();
- }
-
- virtual void
- ice_exception(const Exception& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- _exception.reset(ex.ice_clone());
- _done = true;
- notify();
- }
-
-private:
-
- bool _done;
- FileInfoSeq _fileInfoSeq;
- auto_ptr<Exception> _exception;
-};
-
-typedef IceUtil::Handle<AMIGetFileInfoSeq> AMIGetFileInfoSeqPtr;
-
}
bool
@@ -363,8 +303,8 @@ IcePatch2::Patcher::prepare()
throw string("server returned illegal value");
}
- AMIGetFileInfoSeqPtr curCB;
- AMIGetFileInfoSeqPtr nxtCB;
+ AsyncResultPtr curCB;
+ AsyncResultPtr nxtCB;
for(int node0 = 0; node0 < 256; ++node0)
{
@@ -373,9 +313,7 @@ IcePatch2::Patcher::prepare()
if(!curCB)
{
assert(!nxtCB);
- curCB = new AMIGetFileInfoSeq;
- nxtCB = new AMIGetFileInfoSeq;
- _serverCompress->getFileInfoSeq_async(curCB, node0);
+ curCB = _serverCompress->begin_getFileInfoSeq(node0);
}
else
{
@@ -393,10 +331,10 @@ IcePatch2::Patcher::prepare()
if(node0Nxt < 256)
{
- _serverCompress->getFileInfoSeq_async(nxtCB, node0Nxt);
+ nxtCB = _serverCompress->begin_getFileInfoSeq(node0Nxt);
}
- FileInfoSeq files = curCB->getFileInfoSeq();
+ FileInfoSeq files = _serverCompress->end_getFileInfoSeq(curCB);
sort(files.begin(), files.end(), FileInfoLess());
files.erase(unique(files.begin(), files.end(), FileInfoEqual()), files.end());
@@ -733,71 +671,6 @@ IcePatch2::Patcher::updateFiles(const FileInfoSeq& files)
return result;
}
-namespace
-{
-
-class AMIGetFileCompressed : public AMI_FileServer_getFileCompressed, public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- AMIGetFileCompressed() :
- _done(false)
- {
- }
-
- ByteSeq
- getFileCompressed()
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(!_done)
- {
- wait();
- }
-
- _done = false;
-
- if(_exception.get())
- {
- auto_ptr<Exception> ex = _exception;
- _bytes.clear();
- ex->ice_throw();
- }
-
- ByteSeq bytes;
- bytes.swap(_bytes);
- return bytes;
- }
-
- virtual void
- ice_response(const pair<const Ice::Byte*, const Ice::Byte*>& bytes)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- ByteSeq(bytes.first, bytes.second).swap(_bytes);
- _done = true;
- notify();
- }
-
- virtual void
- ice_exception(const Exception& ex)
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- _exception.reset(ex.ice_clone());
- _done = true;
- notify();
- }
-
-private:
-
- bool _done;
- ByteSeq _bytes;
- auto_ptr<Exception> _exception;
-};
-
-typedef IceUtil::Handle<AMIGetFileCompressed> AMIGetFileCompressedPtr;
-
-}
-
bool
IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const DecompressorPtr& decompressor)
{
@@ -814,8 +687,8 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
}
}
- AMIGetFileCompressedPtr curCB;
- AMIGetFileCompressedPtr nxtCB;
+ AsyncResultPtr curCB;
+ AsyncResultPtr nxtCB;
for(p = files.begin(); p != files.end(); ++p)
{
@@ -877,9 +750,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
if(!curCB)
{
assert(!nxtCB);
- curCB = new AMIGetFileCompressed;
- nxtCB = new AMIGetFileCompressed;
- _serverNoCompress->getFileCompressed_async(curCB, p->path, pos, _chunkSize);
+ curCB = _serverNoCompress->begin_getFileCompressed(p->path, pos, _chunkSize);
}
else
{
@@ -889,7 +760,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
if(pos + _chunkSize < p->size)
{
- _serverNoCompress->getFileCompressed_async(nxtCB, p->path, pos + _chunkSize, _chunkSize);
+ nxtCB = _serverNoCompress->begin_getFileCompressed(p->path, pos + _chunkSize, _chunkSize);
}
else
{
@@ -902,7 +773,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
if(q != files.end())
{
- _serverNoCompress->getFileCompressed_async(nxtCB, q->path, 0, _chunkSize);
+ nxtCB = _serverNoCompress->begin_getFileCompressed(q->path, 0, _chunkSize);
}
}
@@ -910,7 +781,7 @@ IcePatch2::Patcher::updateFilesInternal(const FileInfoSeq& files, const Decompre
try
{
- bytes = curCB->getFileCompressed();
+ bytes = _serverNoCompress->end_getFileCompressed(curCB);
}
catch(const FileAccessException& ex)
{
diff --git a/cpp/src/IceSSL/Certificate.cpp b/cpp/src/IceSSL/Certificate.cpp
index 5a33fdda464..da9e7e2c4b9 100644
--- a/cpp/src/IceSSL/Certificate.cpp
+++ b/cpp/src/IceSSL/Certificate.cpp
@@ -40,7 +40,7 @@ CertificateReadException::ice_name() const
return _name;
}
-Exception*
+CertificateReadException*
CertificateReadException::ice_clone() const
{
return new CertificateReadException(*this);
@@ -70,7 +70,7 @@ CertificateEncodingException::ice_name() const
return _name;
}
-Exception*
+CertificateEncodingException*
CertificateEncodingException::ice_clone() const
{
return new CertificateEncodingException(*this);
@@ -269,7 +269,7 @@ ParseException::ice_name() const
return _name;
}
-IceUtil::Exception*
+ParseException*
ParseException::ice_clone() const
{
return new ParseException(*this);
diff --git a/cpp/src/IceSSL/EndpointI.cpp b/cpp/src/IceSSL/EndpointI.cpp
index d7a63a226ee..6e5a8bb7463 100644
--- a/cpp/src/IceSSL/EndpointI.cpp
+++ b/cpp/src/IceSSL/EndpointI.cpp
@@ -543,10 +543,15 @@ IceSSL::EndpointI::operator<(const Ice::LocalObject& r) const
Ice::Int
IceSSL::EndpointI::hashInit() const
{
- Int h = 0;
+ Int h = 5381;
+ IceInternal::hashAdd(h, EndpointType);
IceInternal::hashAdd(h, _host);
IceInternal::hashAdd(h, _port);
IceInternal::hashAdd(h, _timeout);
+ IceInternal::hashAdd(h, _protocol.major);
+ IceInternal::hashAdd(h, _protocol.minor);
+ IceInternal::hashAdd(h, _encoding.major);
+ IceInternal::hashAdd(h, _encoding.minor);
IceInternal::hashAdd(h, _connectionId);
IceInternal::hashAdd(h, _compress);
return h;
diff --git a/cpp/src/IceStorm/Election.ice b/cpp/src/IceStorm/Election.ice
index fc8a8025484..3e9c95f6321 100644
--- a/cpp/src/IceStorm/Election.ice
+++ b/cpp/src/IceStorm/Election.ice
@@ -68,7 +68,7 @@ interface ReplicaObserver
* inconsisency was detected.
*
**/
- ["ami"] void createTopic(LogUpdate llu, string name)
+ void createTopic(LogUpdate llu, string name)
throws ObserverInconsistencyException;
/**
@@ -83,7 +83,7 @@ interface ReplicaObserver
* inconsisency was detected.
*
**/
- ["ami"] void destroyTopic(LogUpdate llu, string name)
+ void destroyTopic(LogUpdate llu, string name)
throws ObserverInconsistencyException;
/**
@@ -100,7 +100,7 @@ interface ReplicaObserver
* inconsisency was detected.
*
**/
- ["ami"] void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
+ void addSubscriber(LogUpdate llu, string topic, IceStorm::SubscriberRecord record)
throws ObserverInconsistencyException;
/**
@@ -117,7 +117,7 @@ interface ReplicaObserver
* inconsisency was detected.
*
**/
- ["ami"] void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
+ void removeSubscriber(LogUpdate llu, string topic, Ice::IdentitySeq subscribers)
throws ObserverInconsistencyException;
};
diff --git a/cpp/src/IceStorm/IceStormInternal.ice b/cpp/src/IceStorm/IceStormInternal.ice
index e664f76abfb..3f89f9d3a03 100644
--- a/cpp/src/IceStorm/IceStormInternal.ice
+++ b/cpp/src/IceStorm/IceStormInternal.ice
@@ -59,7 +59,7 @@ interface TopicLink
* @param events The events to forward.
*
**/
- ["ami"] void forward(EventDataSeq events);
+ void forward(EventDataSeq events);
};
/** Thrown if the reap call would block. */
@@ -94,7 +94,7 @@ interface TopicInternal extends Topic
* @throws ReapWouldBlock Raised if the reap call would block.
*
**/
- ["ami"] void reap(Ice::IdentitySeq id) throws ReapWouldBlock;
+ void reap(Ice::IdentitySeq id) throws ReapWouldBlock;
};
/**
diff --git a/cpp/src/IceStorm/NodeI.cpp b/cpp/src/IceStorm/NodeI.cpp
index 9933b18357a..f586edcaa86 100644
--- a/cpp/src/IceStorm/NodeI.cpp
+++ b/cpp/src/IceStorm/NodeI.cpp
@@ -107,6 +107,21 @@ GroupNodeInfo::operator==(const GroupNodeInfo& rhs) const
return id == rhs.id;
}
+//
+// COMPILER FIX: Clang using libc++ requires to define operator=
+//
+#if defined(__clang__) && defined(_LIBCPP_VERSION)
+GroupNodeInfo&
+GroupNodeInfo::operator=(const GroupNodeInfo& other)
+
+{
+ const_cast<int&>(this->id) = other.id;
+ const_cast<LogUpdate&>(this->llu) = other.llu;
+ const_cast<Ice::ObjectPrx&>(this->observer) = other.observer;
+ return *this;
+}
+#endif
+
Replica::~Replica()
{
//cout << "~Replica" << endl;
diff --git a/cpp/src/IceStorm/Observers.cpp b/cpp/src/IceStorm/Observers.cpp
index a937adf874c..92f74469421 100644
--- a/cpp/src/IceStorm/Observers.cpp
+++ b/cpp/src/IceStorm/Observers.cpp
@@ -15,82 +15,6 @@ using namespace std;
using namespace IceStorm;
using namespace IceStormElection;
-namespace
-{
-
-class AMI_ReplicaObserver_createTopicI : public AMI_ReplicaObserver_createTopic, public AMICall
-{
-public:
-
- virtual void ice_response() { response(); }
- virtual void ice_exception(const Ice::Exception& e) { exception(e); }
-};
-typedef IceUtil::Handle<AMI_ReplicaObserver_createTopicI> AMI_ReplicaObserver_createTopicIPtr;
-
-class AMI_ReplicaObserver_addSubscriberI : public AMI_ReplicaObserver_addSubscriber, public AMICall
-{
-public:
-
- virtual void ice_response() { response(); }
- virtual void ice_exception(const Ice::Exception& e) { exception(e); }
-};
-typedef IceUtil::Handle<AMI_ReplicaObserver_addSubscriberI> AMI_ReplicaObserver_addSubscriberIPtr;
-
-class AMI_ReplicaObserver_removeSubscriberI : public AMI_ReplicaObserver_removeSubscriber, public AMICall
-{
-public:
-
- virtual void ice_response() { response(); }
- virtual void ice_exception(const Ice::Exception& e) { exception(e); }
-};
-typedef IceUtil::Handle<AMI_ReplicaObserver_removeSubscriberI> AMI_ReplicaObserver_removeSubscriberIPtr;
-
-class AMI_ReplicaObserver_destroyTopicI : public AMI_ReplicaObserver_destroyTopic, public AMICall
-{
-public:
-
- virtual void ice_response() { response(); }
- virtual void ice_exception(const Ice::Exception& e) { exception(e); }
-};
-typedef IceUtil::Handle<AMI_ReplicaObserver_destroyTopicI> AMI_ReplicaObserver_destroyTopicIPtr;
-
-}
-
-AMICall::AMICall() :
- _response(false)
-{
-}
-
-void
-AMICall::response()
-{
- Lock sync(*this);
- _response = true;
- notify();
-}
-void
-AMICall::exception(const IceUtil::Exception& e)
-{
- Lock sync(*this);
- _response = true;
- _ex.reset(e.ice_clone());
- notify();
-}
-
-void
-AMICall::waitResponse()
-{
- Lock sync(*this);
- while(!_response)
- {
- wait();
- }
- if(_ex.get())
- {
- _ex->ice_throw();
- }
-}
-
Observers::Observers(const InstancePtr& instance) :
_traceLevels(instance->traceLevels()),
_majority(0)
@@ -194,9 +118,7 @@ Observers::createTopic(const LogUpdate& llu, const string& name)
Lock sync(*this);
for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- AMI_ReplicaObserver_createTopicIPtr cb = new AMI_ReplicaObserver_createTopicI;
- p->call = cb;
- p->observer->createTopic_async(cb, llu, name);
+ p->result = p->observer->begin_createTopic(llu, name);
}
wait("createTopic");
}
@@ -207,9 +129,7 @@ Observers::destroyTopic(const LogUpdate& llu, const string& id)
Lock sync(*this);
for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- AMI_ReplicaObserver_destroyTopicIPtr cb = new AMI_ReplicaObserver_destroyTopicI;
- p->call = cb;
- p->observer->destroyTopic_async(cb, llu, id);
+ p->result = p->observer->begin_destroyTopic(llu, id);
}
wait("destroyTopic");
}
@@ -221,9 +141,7 @@ Observers::addSubscriber(const LogUpdate& llu, const string& name, const Subscri
Lock sync(*this);
for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- AMI_ReplicaObserver_addSubscriberIPtr cb = new AMI_ReplicaObserver_addSubscriberI;
- p->call = cb;
- p->observer->addSubscriber_async(cb, llu, name, rec);
+ p->result = p->observer->begin_addSubscriber(llu, name, rec);
}
wait("addSubscriber");
}
@@ -234,9 +152,7 @@ Observers::removeSubscriber(const LogUpdate& llu, const string& name, const Ice:
Lock sync(*this);
for(vector<ObserverInfo>::iterator p = _observers.begin(); p != _observers.end(); ++p)
{
- AMI_ReplicaObserver_removeSubscriberIPtr cb = new AMI_ReplicaObserver_removeSubscriberI;
- p->call = cb;
- p->observer->removeSubscriber_async(cb, llu, name, id);
+ p->result = p->observer->begin_removeSubscriber(llu, name, id);
}
wait("removeSubscriber");
}
@@ -249,7 +165,8 @@ Observers::wait(const string& op)
{
try
{
- p->call->waitResponse();
+ p->result->waitForCompleted();
+ p->result->throwLocalException();
}
catch(const Ice::Exception& ex)
{
@@ -261,11 +178,8 @@ Observers::wait(const string& op)
int id = p->id;
p = _observers.erase(p);
- // COMPILERFIX: Just using following causes double unlock with C++Builder 2007
- //IceUtil::Mutex::Lock sync(_reapedMutex);
- _reapedMutex.lock();
+ IceUtil::Mutex::Lock sync(_reapedMutex);
_reaped.push_back(id);
- _reapedMutex.unlock();
continue;
}
++p;
diff --git a/cpp/src/IceStorm/Observers.h b/cpp/src/IceStorm/Observers.h
index d7c51f9020f..1cac54a8b8e 100644
--- a/cpp/src/IceStorm/Observers.h
+++ b/cpp/src/IceStorm/Observers.h
@@ -25,23 +25,6 @@ typedef IceUtil::Handle<TraceLevels> TraceLevelsPtr;
namespace IceStormElection
{
-class AMICall : virtual public IceUtil::Shared,
- virtual public IceUtil::Monitor<IceUtil::Mutex>
-{
-public:
-
- AMICall();
-
- void response();
- void exception(const IceUtil::Exception& e);
- void waitResponse();
-
-private:
- bool _response;
- std::auto_ptr<IceUtil::Exception> _ex;
-};
-typedef IceUtil::Handle<AMICall> AMICallPtr;
-
class Observers : public IceUtil::Shared, public IceUtil::Mutex
{
public:
@@ -72,7 +55,7 @@ private:
id(i), observer(o) {}
int id;
ReplicaObserverPrx observer;
- AMICallPtr call;
+ ::Ice::AsyncResultPtr result;
};
std::vector<ObserverInfo> _observers;
IceUtil::Mutex _reapedMutex;
diff --git a/cpp/src/IceStorm/Replica.h b/cpp/src/IceStorm/Replica.h
index 60600c778d8..7e131904bf1 100644
--- a/cpp/src/IceStorm/Replica.h
+++ b/cpp/src/IceStorm/Replica.h
@@ -22,6 +22,12 @@ struct GroupNodeInfo
GroupNodeInfo(int i, LogUpdate l, const Ice::ObjectPrx& o = Ice::ObjectPrx());
bool operator<(const GroupNodeInfo& rhs) const;
bool operator==(const GroupNodeInfo& rhs) const;
+ //
+ // COMPILER FIX: Clang using libc++ requires to define operator=
+ //
+#if defined(__clang__) && defined(_LIBCPP_VERSION)
+ GroupNodeInfo& operator=(const GroupNodeInfo&);
+#endif
const int id;
const LogUpdate llu;
const Ice::ObjectPrx observer;
diff --git a/cpp/src/IceStorm/Service.cpp b/cpp/src/IceStorm/Service.cpp
index 2844453c5a7..9bb02dc0b83 100644
--- a/cpp/src/IceStorm/Service.cpp
+++ b/cpp/src/IceStorm/Service.cpp
@@ -85,7 +85,7 @@ createIceStorm(CommunicatorPtr communicator)
}
ServicePtr
-Service::create(const CommunicatorPtr& communicator,
+IceStormInternal::Service::create(const CommunicatorPtr& communicator,
const ObjectAdapterPtr& topicAdapter,
const ObjectAdapterPtr& publishAdapter,
const string& name,
diff --git a/cpp/src/IceStorm/Subscriber.cpp b/cpp/src/IceStorm/Subscriber.cpp
index b854ff2a835..74b15583cc1 100755
--- a/cpp/src/IceStorm/Subscriber.cpp
+++ b/cpp/src/IceStorm/Subscriber.cpp
@@ -93,6 +93,11 @@ public:
virtual void flush();
+ void exception(const Ice::Exception& ex)
+ {
+ error(false, ex);
+ }
+
void doFlush();
private:
@@ -111,7 +116,11 @@ public:
virtual void flush();
- void sent();
+ void exception(const Ice::Exception& ex)
+ {
+ error(true, ex);
+ }
+ void sent(bool);
private:
@@ -146,84 +155,6 @@ private:
const TopicLinkPrx _obj;
};
-class OnewayIceInvokeI : public Ice::AMI_Object_ice_invoke, public Ice::AMISentCallback
-{
-public:
-
- OnewayIceInvokeI(const SubscriberOnewayPtr& subscriber) :
- _subscriber(subscriber)
- {
- }
-
- virtual void
- ice_response(bool, const std::vector<Ice::Byte>&)
- {
- assert(false);
- }
-
- virtual void
- ice_sent()
- {
- _subscriber->sent();
- }
-
- virtual void
- ice_exception(const Ice::Exception& e)
- {
- _subscriber->error(true, e);
- }
-
-private:
-
- const SubscriberOnewayPtr _subscriber;
-};
-
-class IceInvokeI : public Ice::AMI_Object_ice_invoke
-{
-public:
-
- IceInvokeI(const SubscriberPtr& subscriber) :
- _subscriber(subscriber)
- {
- }
-
- virtual void
- ice_response(bool, const std::vector<Ice::Byte>&)
- {
- _subscriber->response();
- }
-
- virtual void
- ice_exception(const Ice::Exception& e)
- {
- _subscriber->error(true, e);
- }
-
-private:
-
- const SubscriberPtr _subscriber;
-};
-
-class FlushBatchI : public Ice::AMI_Object_ice_flushBatchRequests
-{
-public:
-
- FlushBatchI(const SubscriberPtr& subscriber) :
- _subscriber(subscriber)
- {
- }
-
- virtual void
- ice_exception(const Ice::Exception& e)
- {
- _subscriber->error(false, e);
- }
-
-private:
-
- const SubscriberPtr _subscriber;
-};
-
class FlushTimerTask : public IceUtil::TimerTask
{
public:
@@ -313,7 +244,8 @@ SubscriberBatch::doFlush()
return;
}
- _obj->ice_flushBatchRequests_async(new FlushBatchI(this));
+ _obj->begin_ice_flushBatchRequests(Ice::newCallback_Object_ice_flushBatchRequests(this,
+ &SubscriberBatch::exception));
// This is significantly faster than the async version, but it can
// block the calling thread. Bad news!
@@ -361,7 +293,11 @@ SubscriberOneway::flush()
_events.erase(_events.begin());
try
{
- if(!_obj->ice_invoke_async(new OnewayIceInvokeI(this), e->op, e->mode, e->data, e->context))
+ Ice::AsyncResultPtr result = _obj->begin_ice_invoke(
+ e->op, e->mode, e->data, e->context, Ice::newCallback_Object_ice_invoke(this,
+ &SubscriberOneway::exception,
+ &SubscriberOneway::sent));
+ if(!result->sentSynchronously())
{
++_outstanding;
}
@@ -380,8 +316,13 @@ SubscriberOneway::flush()
}
void
-SubscriberOneway::sent()
+SubscriberOneway::sent(bool sentSynchronously)
{
+ if(sentSynchronously)
+ {
+ return;
+ }
+
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock);
// Decrement the _outstanding count.
@@ -436,7 +377,8 @@ SubscriberTwoway::flush()
try
{
- _obj->ice_invoke_async(new IceInvokeI(this), e->op, e->mode, e->data, e->context);
+ _obj->begin_ice_invoke(e->op, e->mode, e->data, e->context,
+ Ice::newCallback(static_cast<Subscriber*>(this), &Subscriber::completed));
}
catch(const Ice::Exception& ex)
{
@@ -449,34 +391,6 @@ SubscriberTwoway::flush()
namespace
{
-class Topiclink_forwardI : public IceStorm::AMI_TopicLink_forward
-{
-public:
-
- Topiclink_forwardI(const SubscriberPtr& subscriber) :
- _subscriber(subscriber)
- {
- }
-
- virtual void
- ice_response()
- {
- _subscriber->response();
- }
-
- virtual void
- ice_exception(const Ice::Exception& e)
- {
- _subscriber->error(true, e);
- }
-
-private:
-
- const SubscriberPtr _subscriber;
-};
-
-}
-
SubscriberLink::SubscriberLink(
const InstancePtr& instance,
const SubscriberRecord& rec) :
@@ -523,7 +437,7 @@ SubscriberLink::flush()
try
{
++_outstanding;
- _obj->forward_async(new Topiclink_forwardI(this), v);
+ _obj->begin_forward(v, Ice::newCallback(static_cast<Subscriber*>(this), &Subscriber::completed));
}
catch(const Ice::Exception& ex)
{
@@ -532,6 +446,8 @@ SubscriberLink::flush()
}
}
+}
+
SubscriberPtr
Subscriber::create(
const InstancePtr& instance,
@@ -850,30 +766,40 @@ Subscriber::error(bool dec, const Ice::Exception& e)
}
void
-Subscriber::response()
+Subscriber::completed(const Ice::AsyncResultPtr& result)
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock);
-
- // Decrement the _outstanding count.
- --_outstanding;
- assert(_outstanding >= 0 && _outstanding < _maxOutstanding);
-
- //
- // A successful response means we're no longer retrying, we're
- // back active.
- //
- _currentRetry = 0;
-
- if(_events.empty() && _outstanding == 0 && _shutdown)
+ try
{
- _lock.notify();
+ result->throwLocalException();
+
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(_lock);
+
+ // Decrement the _outstanding count.
+ --_outstanding;
+ assert(_outstanding >= 0 && _outstanding < _maxOutstanding);
+
+ //
+ // A successful response means we're no longer retrying, we're
+ // back active.
+ //
+ _currentRetry = 0;
+
+ if(_events.empty() && _outstanding == 0 && _shutdown)
+ {
+ _lock.notify();
+ }
+ else
+ {
+ flush();
+ }
}
- else
+ catch(const Ice::LocalException& ex)
{
- flush();
+ error(true, ex);
}
}
+
void
Subscriber::shutdown()
{
diff --git a/cpp/src/IceStorm/Subscriber.h b/cpp/src/IceStorm/Subscriber.h
index 75b7e0ea056..52e07c2b137 100644
--- a/cpp/src/IceStorm/Subscriber.h
+++ b/cpp/src/IceStorm/Subscriber.h
@@ -43,8 +43,8 @@ public:
void destroy();
// To be called by the AMI callbacks only.
+ void completed(const Ice::AsyncResultPtr&);
void error(bool, const Ice::Exception&);
- void response();
void shutdown();
diff --git a/cpp/src/IceStorm/TopicI.cpp b/cpp/src/IceStorm/TopicI.cpp
index 35e0fe455dc..a19ac8b7289 100644
--- a/cpp/src/IceStorm/TopicI.cpp
+++ b/cpp/src/IceStorm/TopicI.cpp
@@ -1147,20 +1147,16 @@ TopicImpl::proxy() const
namespace
{
-class TopicInternal_reapI : public AMI_TopicInternal_reap
+class TopicInternalReapCB : public IceUtil::Shared
{
public:
- TopicInternal_reapI(const InstancePtr& instance, Ice::Long generation) :
+ TopicInternalReapCB(const InstancePtr& instance, Ice::Long generation) :
_instance(instance), _generation(generation)
{
}
- virtual void ice_response()
- {
- }
-
- virtual void ice_exception(const Ice::Exception& ex)
+ virtual void exception(const Ice::Exception& ex)
{
TraceLevelsPtr traceLevels = _instance->traceLevels();
if(traceLevels->topic > 0)
@@ -1236,7 +1232,8 @@ TopicImpl::publish(bool forwarded, const EventDataSeq& events)
// call may raise an exception in the caller (that is directly
// call ice_exception) which calls recover() on the node which
// would result in a deadlock since the node is locked.
- masterInternal->reap_async(new TopicInternal_reapI(_instance, generation), reap);
+ masterInternal->begin_reap(reap, newCallback_TopicInternal_reap(new TopicInternalReapCB(_instance, generation),
+ &TopicInternalReapCB::exception));
}
void
diff --git a/cpp/src/IceUtil/CtrlCHandler.cpp b/cpp/src/IceUtil/CtrlCHandler.cpp
index 26b9fcf711a..bb6bbb9f2a3 100644
--- a/cpp/src/IceUtil/CtrlCHandler.cpp
+++ b/cpp/src/IceUtil/CtrlCHandler.cpp
@@ -68,7 +68,7 @@ CtrlCHandlerException::ice_name() const
return ctrlCHandlerName;
}
-Exception*
+CtrlCHandlerException*
CtrlCHandlerException::ice_clone() const
{
return new CtrlCHandlerException(*this);
diff --git a/cpp/src/IceUtil/Exception.cpp b/cpp/src/IceUtil/Exception.cpp
index b6c75231f5a..3d4a40a91fc 100644
--- a/cpp/src/IceUtil/Exception.cpp
+++ b/cpp/src/IceUtil/Exception.cpp
@@ -17,8 +17,20 @@
#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__)
# include <execinfo.h>
# include <cxxabi.h>
+# define ICE_STACK_TRACES
+# define ICE_GCC_STACK_TRACES
#endif
+#if defined(_WIN32) && !defined(__MINGW32__) && !defined(ICE_OS_WINRT)
+# include <IceUtil/Unicode.h>
+# define DBGHELP_TRANSLATE_TCHAR
+# include <DbgHelp.h>
+# include <iomanip>
+# define ICE_STACK_TRACES
+# define ICE_WIN32_STACK_TRACES
+#endif
+
+
using namespace std;
namespace IceUtilInternal
@@ -34,6 +46,10 @@ namespace
IceUtil::Mutex* globalMutex = 0;
+#ifdef ICE_WIN32_STACK_TRACES
+HANDLE process = 0;
+#endif
+
class Init
{
public:
@@ -47,22 +63,102 @@ public:
{
delete globalMutex;
globalMutex = 0;
+#ifdef ICE_WIN32_STACK_TRACES
+ if(process != 0)
+ {
+ SymCleanup(process);
+ process = 0;
+ }
+#endif
}
};
Init init;
-#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__)
+#ifdef ICE_STACK_TRACES
string
getStackTrace()
{
+ if(!IceUtilInternal::printStackTraces)
+ {
+ return "";
+ }
+
string stackTrace;
- if(!IceUtilInternal::printStackTraces)
+# ifdef ICE_WIN32_STACK_TRACES
+ //
+ // Note: the Sym functions are not thread-safe
+ //
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex);
+ if(process == 0)
+ {
+ process = GetCurrentProcess();
+ SymSetOptions(SYMOPT_LOAD_LINES | SYMOPT_UNDNAME);
+ BOOL ok = SymInitialize(process, 0, TRUE);
+ if(!ok)
+ {
+ process = 0;
+ return "No stack trace: SymInitialize failed with " + IceUtilInternal::errorToString(GetLastError());
+ }
+ }
+ lock.release();
+
+ const int stackSize = 61;
+ void* stack[stackSize];
+
+ //
+ // 1: skip the first frame (the call to getStackTrace)
+ // 1 + stackSize < 63 on XP according to the documentation for CaptureStackBackTrace
+ //
+ USHORT frames = CaptureStackBackTrace(1, stackSize, stack, 0);
+
+ if(frames > 0)
{
- return stackTrace;
+ char buffer[sizeof(SYMBOL_INFO) + MAX_SYM_NAME * sizeof(TCHAR)];
+ SYMBOL_INFO* symbol = reinterpret_cast<SYMBOL_INFO*>(buffer);
+ symbol->SizeOfStruct = sizeof(SYMBOL_INFO);
+ symbol->MaxNameLen = MAX_SYM_NAME;
+
+ IMAGEHLP_LINE64 line = {};
+ line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
+ DWORD displacement = 0;
+
+ lock.acquire();
+ for(int i = 0; i < frames; i++)
+ {
+ if(!stackTrace.empty())
+ {
+ stackTrace += "\n";
+ }
+
+ stringstream s;
+ s << setw(3) << i << " ";
+
+ DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
+
+ BOOL ok = SymFromAddr(process, address, 0, symbol);
+ if(ok)
+ {
+ s << IceUtil::wstringToString(symbol->Name);
+
+ ok = SymGetLineFromAddr64(process, address, &displacement, &line);
+ if(ok)
+ {
+ s << " at line " << line.LineNumber << " in " << IceUtil::wstringToString(line.FileName);
+ }
+ }
+ else
+ {
+ s << hex << "0x" << address;
+ }
+ stackTrace += s.str();
+ }
+ lock.release();
}
+# elif defined(ICE_GCC_STACK_TRACES)
+
const size_t maxDepth = 100;
void *stackAddrs[maxDepth];
@@ -174,6 +270,7 @@ getStackTrace()
}
free(stackStrings);
+# endif
return stackTrace;
}
#endif
@@ -183,7 +280,7 @@ getStackTrace()
IceUtil::Exception::Exception() :
_file(0),
_line(0)
-#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__)
+#ifdef ICE_STACK_TRACES
, _stackTrace(getStackTrace())
#endif
{
@@ -192,7 +289,7 @@ IceUtil::Exception::Exception() :
IceUtil::Exception::Exception(const char* file, int line) :
_file(file),
_line(line)
-#if defined(__GNUC__) && !defined(__sun) && !defined(__FreeBSD__) && !defined(__MINGW32__)
+#ifdef ICE_STACK_TRACES
, _stackTrace(getStackTrace())
#endif
{
@@ -300,7 +397,7 @@ IceUtil::NullHandleException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::NullHandleException*
IceUtil::NullHandleException::ice_clone() const
{
return new NullHandleException(*this);
@@ -342,7 +439,7 @@ IceUtil::IllegalArgumentException::ice_print(ostream& out) const
out << ": " << _reason;
}
-IceUtil::Exception*
+IceUtil::IllegalArgumentException*
IceUtil::IllegalArgumentException::ice_clone() const
{
return new IllegalArgumentException(*this);
@@ -384,7 +481,7 @@ IceUtil::SyscallException::ice_print(ostream& os) const
}
}
-IceUtil::Exception*
+IceUtil::SyscallException*
IceUtil::SyscallException::ice_clone() const
{
return new SyscallException(*this);
@@ -433,7 +530,7 @@ IceUtil::FileLockException::ice_print(ostream& os) const
}
}
-IceUtil::Exception*
+IceUtil::FileLockException*
IceUtil::FileLockException::ice_clone() const
{
return new FileLockException(*this);
@@ -472,7 +569,7 @@ IceUtil::OptionalNotSetException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::OptionalNotSetException*
IceUtil::OptionalNotSetException::ice_clone() const
{
return new OptionalNotSetException(*this);
diff --git a/cpp/src/IceUtil/FileUtil.cpp b/cpp/src/IceUtil/FileUtil.cpp
index 9fe0a5f85d3..b09159619bf 100644
--- a/cpp/src/IceUtil/FileUtil.cpp
+++ b/cpp/src/IceUtil/FileUtil.cpp
@@ -16,10 +16,9 @@
#ifdef _WIN32
# include <process.h>
-#endif
-
-#ifdef _WIN32
# include <io.h>
+#else
+# include <unistd.h>
#endif
using namespace std;
diff --git a/cpp/src/IceUtil/Makefile.mak b/cpp/src/IceUtil/Makefile.mak
index a4ec13cc6e3..1867424f63c 100644
--- a/cpp/src/IceUtil/Makefile.mak
+++ b/cpp/src/IceUtil/Makefile.mak
@@ -60,7 +60,7 @@ $(LIBNAME): $(OBJS)
$(LIBNAME): $(DLLNAME)
$(DLLNAME): $(OBJS) IceUtil.res
- $(LINK) $(BASE):0x20000000 $(LD_DLLFLAGS) $(PDBFLAGS) $(OBJS) $(PREOUT)$@ $(PRELIBS)$(ICE_OS_LIBS) \
+ $(LINK) $(BASE):0x20000000 $(LD_DLLFLAGS) $(PDBFLAGS) $(OBJS) $(PREOUT)$@ $(PRELIBS) $(ICEUTIL_OS_LIBS) \
$(RES_FILE)
move $(DLLNAME:.dll=.lib) $(LIBNAME)
@if exist $@.manifest echo ^ ^ ^ Embedding manifest using $(MT) && \
diff --git a/cpp/src/IceUtil/Options.cpp b/cpp/src/IceUtil/Options.cpp
index b632d0e90fa..32840de107c 100644
--- a/cpp/src/IceUtil/Options.cpp
+++ b/cpp/src/IceUtil/Options.cpp
@@ -42,7 +42,7 @@ IceUtilInternal::APIException::ice_print(ostream& out) const
}
}
-IceUtil::Exception*
+IceUtilInternal::APIException*
IceUtilInternal::APIException::ice_clone() const
{
return new APIException(*this);
@@ -88,7 +88,7 @@ IceUtilInternal::BadOptException::ice_print(ostream& out) const
}
}
-IceUtil::Exception*
+IceUtilInternal::BadOptException*
IceUtilInternal::BadOptException::ice_clone() const
{
return new BadOptException(*this);
diff --git a/cpp/src/IceUtil/OutputUtil.cpp b/cpp/src/IceUtil/OutputUtil.cpp
index 00464533d98..7ab7ca159f0 100644
--- a/cpp/src/IceUtil/OutputUtil.cpp
+++ b/cpp/src/IceUtil/OutputUtil.cpp
@@ -35,7 +35,11 @@ IceUtilInternal::int64ToString(Int64 val)
{
char buf[64];
#ifdef _WIN32
+# if defined(_MSC_VER)
sprintf_s(buf, sizeof(buf), "%I64d", val);
+# else
+ sprintf(buf, "%I64d", val);
+# endif
#elif defined(ICE_64)
sprintf(buf, "%ld", val); // Avoids a format warning from GCC.
#else
diff --git a/cpp/src/IceUtil/ThreadException.cpp b/cpp/src/IceUtil/ThreadException.cpp
index dcfcfad386e..f034da27408 100644
--- a/cpp/src/IceUtil/ThreadException.cpp
+++ b/cpp/src/IceUtil/ThreadException.cpp
@@ -24,7 +24,7 @@ IceUtil::ThreadSyscallException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::ThreadSyscallException*
IceUtil::ThreadSyscallException::ice_clone() const
{
return new ThreadSyscallException(*this);
@@ -49,7 +49,7 @@ IceUtil::ThreadLockedException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::ThreadLockedException*
IceUtil::ThreadLockedException::ice_clone() const
{
return new ThreadLockedException(*this);
@@ -74,7 +74,7 @@ IceUtil::ThreadStartedException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::ThreadStartedException*
IceUtil::ThreadStartedException::ice_clone() const
{
return new ThreadStartedException(*this);
@@ -99,7 +99,7 @@ IceUtil::ThreadNotStartedException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::ThreadNotStartedException*
IceUtil::ThreadNotStartedException::ice_clone() const
{
return new ThreadNotStartedException(*this);
@@ -125,7 +125,7 @@ IceUtil::BadThreadControlException::ice_name() const
return _name;
}
-IceUtil::Exception*
+IceUtil::BadThreadControlException*
IceUtil::BadThreadControlException::ice_clone() const
{
return new BadThreadControlException(*this);
@@ -159,7 +159,7 @@ IceUtil::InvalidTimeoutException::ice_print(ostream& os) const
os << ":\ninvalid timeout: " << _timeout << " seconds";
}
-IceUtil::Exception*
+IceUtil::InvalidTimeoutException*
IceUtil::InvalidTimeoutException::ice_clone() const
{
return new InvalidTimeoutException(*this);
diff --git a/cpp/src/IceUtil/Unicode.cpp b/cpp/src/IceUtil/Unicode.cpp
index f7a8bd5192a..238ae2042ff 100644
--- a/cpp/src/IceUtil/Unicode.cpp
+++ b/cpp/src/IceUtil/Unicode.cpp
@@ -165,7 +165,7 @@ IceUtil::UTFConversionException::ice_print(ostream& os) const
};
}
-IceUtil::Exception*
+IceUtil::UTFConversionException*
IceUtil::UTFConversionException::ice_clone() const
{
return new UTFConversionException(*this);
diff --git a/cpp/src/IceXML/Parser.cpp b/cpp/src/IceXML/Parser.cpp
index d72164c5c5c..d561cf70459 100644
--- a/cpp/src/IceXML/Parser.cpp
+++ b/cpp/src/IceXML/Parser.cpp
@@ -55,7 +55,7 @@ IceXML::ParserException::ice_print(std::ostream& out) const
}
}
-IceUtil::Exception*
+IceXML::ParserException*
IceXML::ParserException::ice_clone() const
{
return new ParserException(*this);
diff --git a/cpp/src/Slice/CsUtil.cpp b/cpp/src/Slice/CsUtil.cpp
index 1cd5e3dcec3..482ee8a11b1 100644
--- a/cpp/src/Slice/CsUtil.cpp
+++ b/cpp/src/Slice/CsUtil.cpp
@@ -582,24 +582,7 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
EnumPtr en = EnumPtr::dynamicCast(type);
if(en)
{
- string func;
- string cast;
size_t sz = en->getEnumerators().size();
- if(sz <= 0x7f)
- {
- func = marshal ? "writeByte" : "readByte";
- cast = marshal ? string("(byte)") : "(" + fixId(en->scoped()) + ")";
- }
- else if(sz <= 0x7fff)
- {
- func = marshal ? "writeShort" : "readShort";
- cast = marshal ? string("(short)") : "(" + fixId(en->scoped()) + ")";
- }
- else
- {
- func = marshal ? "writeInt" : "readInt";
- cast = marshal ? string("(int)") : "(" + fixId(en->scoped()) + ")";
- }
if(marshal)
{
if(streamingAPI)
@@ -609,21 +592,11 @@ Slice::CsGenerator::writeMarshalUnmarshalCode(Output &out,
out << nl << "throw new Ice.MarshalException(\"enumerator out of range\");";
out << eb;
}
- out << nl << stream << '.' << func << '(' << cast << param;
- if(!streamingAPI)
- {
- out << ", " << sz;
- }
- out << ");";
+ out << nl << stream << ".writeEnum((int)" << param << ", " << sz << ");";
}
else
{
- out << nl << param << " = " << cast << stream << '.' << func << "(";
- if(!streamingAPI)
- {
- out << sz;
- }
- out << ")" << ';';
+ out << nl << param << " = (" << fixId(en->scoped()) << ')' << stream << ".readEnum(" << sz << ");";
if(streamingAPI)
{
out << nl << "if((int)" << param << " < 0 || (int)" << param << " >= " << sz << ")";
@@ -1246,23 +1219,6 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
if(en)
{
size_t sz = en->getEnumerators().size();
- string dataType;
- string func = marshal ? "write" : "read";
- if(sz <= 0x7f)
- {
- func += "Byte";
- dataType = "byte";
- }
- else if(sz <= 0x7fff)
- {
- func += "Short";
- dataType = "short";
- }
- else
- {
- func += "Int";
- dataType = "int";
- }
if(marshal)
{
out << nl << "if(" << param << " == null)";
@@ -1282,12 +1238,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << nl << typeS << "[] " << param << "_tmp = " << param << ".ToArray();";
out << nl << "for(int ix__ = " << param << "_tmp.Length - 1; ix__ >= 0; --ix__)";
out << sb;
- out << nl << stream << '.' << func << "((" << dataType << ")" << param << "_tmp[ix__]";
- if(!streamingAPI)
- {
- out << ", " << sz;
- }
- out << ");";
+ out << nl << stream << ".writeEnum((int)" << param << "_tmp[ix__], " << sz << ");";
out << eb;
}
else
@@ -1296,12 +1247,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
<< "> e__ = " << param << ".GetEnumerator();";
out << nl << "while(e__.MoveNext())";
out << sb;
- out << nl << stream << '.' << func << "((" << dataType << ")e__.Current";
- if(!streamingAPI)
- {
- out << ", " << sz;
- }
- out << ");";
+ out << nl << stream << ".writeEnum((int)e__.Current, " << sz << ");";
out << eb;
}
}
@@ -1309,12 +1255,7 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
{
out << nl << "for(int ix__ = 0; ix__ < " << param << '.' << limitID << "; ++ix__)";
out << sb;
- out << nl << stream << '.' << func << "((" << dataType << ")" << param << "[ix__]";
- if(!streamingAPI)
- {
- out << ", " << sz;
- }
- out << ");";
+ out << nl << stream << ".writeEnum((int)" << param << "[ix__], " << sz << ");";
out << eb;
}
out << eb;
@@ -1350,21 +1291,11 @@ Slice::CsGenerator::writeSequenceMarshalUnmarshalCode(Output& out,
out << sb;
if(isArray)
{
- out << nl << param << "[ix__] = (" << typeS << ')' << stream << "." << func << "(";
- if(!streamingAPI)
- {
- out << sz;
- }
- out << ");";
+ out << nl << param << "[ix__] = (" << typeS << ')' << stream << ".readEnum(" << sz << ");";
}
else
{
- out << nl << param << "." << addMethod << "((" << typeS << ')' << stream << "." << func << "(";
- if(!streamingAPI)
- {
- out << sz;
- }
- out << "));";
+ out << nl << param << "." << addMethod << "((" << typeS << ')' << stream << ".readEnum(" << sz << "));";
}
out << eb;
out << eb;
diff --git a/cpp/src/Slice/FileTracker.cpp b/cpp/src/Slice/FileTracker.cpp
index a14638757a2..9000efb43a0 100644
--- a/cpp/src/Slice/FileTracker.cpp
+++ b/cpp/src/Slice/FileTracker.cpp
@@ -9,12 +9,10 @@
#include <Slice/FileTracker.h>
-#ifdef __sun
-# include <unistd.h>
-#endif
-
#ifdef _WIN32
# include <direct.h>
+#else
+# include <unistd.h>
#endif
using namespace std;
@@ -44,7 +42,7 @@ Slice::FileException::ice_print(ostream& out) const
out << ": " << _reason;
}
-IceUtil::Exception*
+Slice::FileException*
Slice::FileException::ice_clone() const
{
return new FileException(*this);
diff --git a/cpp/src/slice2cpp/Gen.cpp b/cpp/src/slice2cpp/Gen.cpp
index 70adaf19199..f6cb56d797b 100644
--- a/cpp/src/slice2cpp/Gen.cpp
+++ b/cpp/src/slice2cpp/Gen.cpp
@@ -814,8 +814,8 @@ Slice::Gen::TypesVisitor::visitExceptionStart(const ExceptionPtr& p)
H << nl << "virtual void ice_print(::std::ostream&) const;";
}
- H << nl << "virtual ::Ice::Exception* ice_clone() const;";
- C << sp << nl << "::Ice::Exception*" << nl << scoped.substr(2) << "::ice_clone() const";
+ H << nl << "virtual " << name << "* ice_clone() const;";
+ C << sp << nl << scoped.substr(2) << "*" << nl << scoped.substr(2) << "::ice_clone() const";
C << sb;
C << nl << "return new " << name << "(*this);";
C << eb;
@@ -1763,6 +1763,38 @@ Slice::Gen::ProxyVisitor::visitClassDefEnd(const ClassDefPtr& p)
_useWstring = resetUseWstring(_useWstringHist);
}
+namespace
+{
+
+bool
+usePrivateEnd(const OperationPtr& p)
+{
+ TypePtr ret = p->returnType();
+ bool retIsOpt = p->returnIsOptional();
+ string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd);
+ string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd);
+
+ ParamDeclList outParams;
+ vector<string> outDeclsEnd;
+ vector<string> outDeclsPrivateEnd;
+
+ ParamDeclList paramList = p->parameters();
+ for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
+ {
+ if((*q)->isOutParam())
+ {
+ outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ TypeContextAMIEnd));
+ outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
+ TypeContextAMIPrivateEnd));
+ }
+ }
+
+ return retSEnd != retSPrivateEnd || outDeclsEnd != outDeclsPrivateEnd;
+}
+
+}
+
void
Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
{
@@ -1771,14 +1803,17 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
string scope = fixKwd(p->scope());
TypePtr ret = p->returnType();
+
bool retIsOpt = p->returnIsOptional();
string retS = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIEnd);
string retSEndAMI = returnTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring | TypeContextAMIPrivateEnd);
+ string retInS = retS != "void" ? inputTypeToString(ret, retIsOpt, p->getMetaData(), _useWstring) : "";
ContainerPtr container = p->container();
ClassDefPtr cl = ClassDefPtr::dynamicCast(container);
+ string clName = cl->name();
string clScope = fixKwd(cl->scope());
- string delName = "Callback_" + cl->name() + "_" + name;
+ string delName = "Callback_" + clName + "_" + name;
string delNameScoped = clScope + delName;
vector<string> params;
@@ -1789,12 +1824,18 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
vector<string> paramsDeclAMI;
vector<string> argsAMI;
vector<string> outParamsAMI;
+ vector<string> outParamNamesAMI;
vector<string> outParamsDeclAMI;
vector<string> outParamsDeclEndAMI;
-
+ vector<string> outDecls;
+
ParamDeclList paramList = p->parameters();
ParamDeclList inParams;
ParamDeclList outParams;
+
+
+ vector<string> outEndArgs;
+
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
string paramName = fixKwd((*q)->name());
@@ -1827,9 +1868,12 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
else
{
outParamsAMI.push_back(typeString);
+ outParamNamesAMI.push_back(paramName);
outParamsDeclAMI.push_back(typeString + ' ' + paramName);
outParamsDeclEndAMI.push_back(typeStringEndAMI + ' ' + paramName);
outParams.push_back(*q);
+ outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring));
+ outEndArgs.push_back(getEndArg((*q)->type(), (*q)->getMetaData(), outParamNamesAMI.back()));
}
}
@@ -1873,6 +1917,201 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
}
H << fixKwd(name) << spar << args << "&__ctx" << epar << ';';
H << eb;
+
+ H.zeroIndent();
+ H << nl << "#ifdef ICE_CPP11";
+ H.restoreIndent();
+
+ string retEndArg = getEndArg(ret, p->getMetaData(), "__ret");
+
+ H << nl << "::Ice::AsyncResultPtr";
+ H << nl << "begin_" << name << spar << paramsDeclAMI
+ << "const ::IceInternal::Function<void " << spar;
+ if(!retInS.empty())
+ {
+ H << retInS;
+ }
+ H << outDecls << epar << ">& response, "
+ << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = "
+ "::IceInternal::Function<void (const ::Ice::Exception&)>(), "
+ << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar;
+
+ H << sb;
+ if(p->returnsData())
+ {
+ H << nl << "return __begin_" << name << spar << argsAMI << "0, response, exception, sent" << epar << ";";
+ }
+ else
+ {
+ H << nl << "return begin_" << name << spar << argsAMI
+ << "0, new ::IceInternal::Cpp11FnOnewayCallbackNC(response, exception, sent)" << epar << ";";
+
+ }
+ H << eb;
+
+ H << nl << "::Ice::AsyncResultPtr";
+ H << nl << "begin_" << name << spar << paramsDeclAMI
+ << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed"
+ << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = "
+ "::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()" << epar;
+ H << sb;
+ H << nl << "return begin_" << name << spar << argsAMI << "0, ::Ice::newCallback(completed, sent), 0" << epar << ";";
+ H << eb;
+
+
+ H << nl << "::Ice::AsyncResultPtr";
+ H << nl << "begin_" << name << spar << paramsDeclAMI << "const ::Ice::Context& ctx"
+ << "const ::IceInternal::Function<void " << spar;
+ if(!retInS.empty())
+ {
+ H << retInS;
+ }
+ H << outDecls << epar << ">& response, "
+ << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception = "
+ "::IceInternal::Function<void (const ::Ice::Exception&)>(), "
+ << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar;
+
+ H << sb;
+ if(p->returnsData())
+ {
+ H << nl << "return __begin_" << name << spar << argsAMI << "&ctx, response, exception, sent" << epar << ";";
+ }
+ else
+ {
+ H << nl << "return begin_" << name << spar << argsAMI
+ << "&ctx, new ::IceInternal::Cpp11FnOnewayCallbackNC(response, exception, sent), 0" << epar << ";";
+ }
+ H << eb;
+
+ H << nl << "::Ice::AsyncResultPtr";
+ H << nl << "begin_" << name << spar << paramsDeclAMI
+ << "const ::Ice::Context& ctx"
+ << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& completed"
+ << "const ::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>& sent = "
+ "::IceInternal::Function<void (const ::Ice::AsyncResultPtr&)>()" << epar;
+ H << sb;
+ H << nl << "return begin_" << name << spar << argsAMI << "&ctx, ::Ice::newCallback(completed, sent)" << epar << ";";
+ H << eb;
+
+ if(p->returnsData())
+ {
+ H << nl;
+ H.dec();
+ H << nl << "private:";
+ H.inc();
+
+
+ H << sp << nl << "::Ice::AsyncResultPtr __begin_" << name << spar << paramsDeclAMI
+ << "const ::Ice::Context* ctx" << "const ::IceInternal::Function<void " << spar;
+
+
+ if(!retInS.empty())
+ {
+ H << retInS;
+ }
+ H << outDecls;
+
+ H << epar << ">& response, "
+ << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception, "
+ << "const ::IceInternal::Function<void (bool)>& sent" << epar;
+ H << sb;
+ H << nl << "class Cpp11CB : public ::IceInternal::Cpp11FnCallbackNC";
+ H << sb;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ H << sp << nl << "Cpp11CB" << spar << "const ::std::function<void " << spar;
+ if(!retInS.empty())
+ {
+ H << retInS;
+ }
+ H << outDecls;
+ H << epar << ">& responseFunc, "
+ << "const ::std::function<void (const ::Ice::Exception&)>& exceptionFunc, "
+ << "const ::std::function<void (bool)>& sentFunc" << epar << " :";
+ H.inc();
+ H << nl << "::IceInternal::Cpp11FnCallbackNC(exceptionFunc, sentFunc),";
+ H << nl << "_response(responseFunc)";
+ H.dec();
+ H << sb;
+ H << nl << "CallbackBase::checkCallback(true, responseFunc || exceptionFunc != nullptr);";
+ H << eb;
+
+ //
+ // completed.
+ //
+ H << sp << nl << "virtual void __completed(const ::Ice::AsyncResultPtr& __result) const";
+ H << sb;
+ H << nl << clScope << clName << "Prx __proxy = " << clScope << clName
+ << "Prx::uncheckedCast(__result->getProxy());";
+ writeAllocateCode(H, outParams, p, _useWstring | TypeContextInParam | TypeContextAMICallPrivateEnd);
+ H << nl << "try";
+ H << sb;
+ H << nl;
+ if(!usePrivateEnd(p))
+ {
+ if(ret)
+ {
+ H << retEndArg << " = ";
+ }
+ H << "__proxy->end_" << p->name() << spar << outEndArgs << "__result" << epar << ';';
+ }
+ else
+ {
+ H << "__proxy->___end_" << p->name() << spar << outEndArgs;
+ if(ret)
+ {
+ H << retEndArg;
+ }
+ H << "__result" << epar << ';';
+ }
+ writeEndCode(H, outParams, p);
+ H << eb;
+ H << nl << "catch(::Ice::Exception& ex)";
+ H << sb;
+ H << nl << "Cpp11FnCallbackNC::__exception(__result, ex);";
+ H << nl << "return;";
+ H << eb;
+ H << nl << "if(_response != nullptr)";
+ H << sb;
+ H << nl << "_response" << spar;
+ if(ret)
+ {
+ H << "__ret";
+ }
+ H << outParamNamesAMI;
+ H << epar << ';';
+ H << eb;
+ H << eb;
+
+ H.dec();
+ H << nl << nl << "private:";
+ H.inc();
+ H << nl;
+ H << nl << "::std::function<void " << spar;
+
+ if(!retInS.empty())
+ {
+ H << retInS;
+ }
+ H << outDecls;
+
+ H << epar << "> _response;";
+
+ H << eb << ';';
+
+ H << nl << "return begin_" << name << spar << argsAMI << "ctx" << "new Cpp11CB(response, exception, sent)"
+ << epar << ';';
+ H << eb;
+ H << nl;
+ H.dec();
+ H << nl << "public:";
+ H.inc();
+ }
+
+ H.zeroIndent();
+ H << nl << "#endif";
+ H.restoreIndent();
H << sp << nl << "::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI << epar;
H << sb;
@@ -1921,7 +2160,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
<< "const ::Ice::AsyncResultPtr&" << epar << ';';
if(generatePrivateEnd)
{
- H << sp << nl << "void ___end_" << name << spar << outParamsDeclEndAMI;
+ H << sp << nl << _dllExport << " void ___end_" << name << spar << outParamsDeclEndAMI;
H << "const ::Ice::AsyncResultPtr&" << epar << ';';
}
@@ -1938,7 +2177,7 @@ Slice::Gen::ProxyVisitor::visitOperation(const OperationPtr& p)
H.dec();
H << nl << "public:";
H.inc();
-
+
C << sp << nl << retS << nl << "IceProxy" << scoped << spar << paramsDecl << "const ::Ice::Context* __ctx" << epar;
C << sb;
C << nl << "::IceInternal::InvocationObserver __observer(this, " << p->flattenedScope() << p->name()
@@ -3316,27 +3555,37 @@ Slice::Gen::ObjectVisitor::visitClassDefStart(const ClassDefPtr& p)
if(!p->isLocal())
{
- H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;";
-
C << sp << nl
<< (_dllExport.empty() ? "" : "ICE_DECLSPEC_EXPORT ")
<< "::Ice::Object* " << scope.substr(2) << "upCast(" << scoped << "* p) { return p; }";
- C << sp;
- C << nl << "::Ice::ObjectPtr";
- C << nl << scoped.substr(2) << "::ice_clone() const";
- C << sb;
- if(!p->isAbstract())
- {
- C << nl << fixKwd(p->scope()) << p->name() << "Ptr __p = new " << scoped << "(*this);";
- C << nl << "return __p;";
- }
- else
- {
- C << nl << "throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__);";
- C << nl << "return 0; // to avoid a warning with some compilers";
- }
- C << eb;
+ //
+ // It would make sense to provide a covariant ice_clone(); unfortunately many compilers
+ // (including VS2010) generate bad code for covariant types that use virtual inheritance
+ //
+
+ if(!p->isInterface())
+ {
+ H << nl << "virtual ::Ice::ObjectPtr ice_clone() const;";
+
+ C << nl << "::Ice::ObjectPtr";
+ C << nl << scoped.substr(2) << "::ice_clone() const";
+ C << sb;
+ if(!p->isAbstract())
+ {
+ C << nl << "::Ice::Object* __p = new " << name << "(*this);";
+ C << nl << "return __p;";
+ }
+ else
+ {
+ //
+ // We need this ice_clone for abstract classes derived from concrete classes
+ //
+ C << nl << "throw ::Ice::CloneNotImplementedException(__FILE__, __LINE__);";
+ C << nl << "return 0; // to avoid a warning with some compilers";
+ }
+ C << eb;
+ }
ClassList allBases = p->allBases();
StringList ids;
@@ -3967,6 +4216,7 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
ParamDeclList inParams;
ParamDeclList outParams;
ParamDeclList paramList = p->parameters();
+ vector< string> outDecls;
for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
{
string paramName = fixKwd((*q)->name());
@@ -4008,6 +4258,10 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
argsAMD += paramName;
argsAMD += ", ";
}
+ else
+ {
+ outDecls.push_back(inputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(), _useWstring));
+ }
}
if(!cl->isLocal())
@@ -4198,6 +4452,18 @@ Slice::Gen::ObjectVisitor::visitOperation(const OperationPtr& p)
outParamsDeclAMI.push_back(typeString + ' ' + paramName);
}
}
+
+ H.zeroIndent();
+ H << nl << "#ifdef ICE_CPP11";
+ H.restoreIndent();
+
+ H << nl << "virtual ::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI
+ << "const ::IceInternal::Function<void (const ::Ice::Exception&)>& exception"
+ << "const ::IceInternal::Function<void (bool)>& sent = ::IceInternal::Function<void (bool)>()" << epar << " = 0;";
+
+ H.zeroIndent();
+ H << nl << "#endif";
+ H.restoreIndent();
H << sp << nl << "virtual ::Ice::AsyncResultPtr begin_" << name << spar << paramsDeclAMI << epar << " = 0;";
@@ -4726,38 +4992,6 @@ Slice::Gen::AsyncCallbackTemplateVisitor::visitClassDefEnd(const ClassDefPtr& p)
_useWstring = resetUseWstring(_useWstringHist);
}
-namespace
-{
-
-bool
-usePrivateEnd(const OperationPtr& p)
-{
- TypePtr ret = p->returnType();
- bool retIsOpt = p->returnIsOptional();
- string retSEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIEnd);
- string retSPrivateEnd = returnTypeToString(ret, retIsOpt, p->getMetaData(), TypeContextAMIPrivateEnd);
-
- ParamDeclList outParams;
- vector<string> outDeclsEnd;
- vector<string> outDeclsPrivateEnd;
-
- ParamDeclList paramList = p->parameters();
- for(ParamDeclList::const_iterator q = paramList.begin(); q != paramList.end(); ++q)
- {
- if((*q)->isOutParam())
- {
- outDeclsEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
- TypeContextAMIEnd));
- outDeclsPrivateEnd.push_back(outputTypeToString((*q)->type(), (*q)->optional(), (*q)->getMetaData(),
- TypeContextAMIPrivateEnd));
- }
- }
-
- return retSEnd != retSPrivateEnd || outDeclsEnd != outDeclsPrivateEnd;
-}
-
-}
-
void
Slice::Gen::AsyncCallbackTemplateVisitor::visitOperation(const OperationPtr& p)
{
diff --git a/cpp/src/slice2cpp/Main.cpp b/cpp/src/slice2cpp/Main.cpp
index a8b82aaa52d..e9d8a211d2d 100644
--- a/cpp/src/slice2cpp/Main.cpp
+++ b/cpp/src/slice2cpp/Main.cpp
@@ -22,7 +22,7 @@ using namespace Slice;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -31,13 +31,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -48,7 +48,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -295,7 +295,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2cs/Gen.cpp b/cpp/src/slice2cs/Gen.cpp
index f636b758a77..a79ea86851e 100644
--- a/cpp/src/slice2cs/Gen.cpp
+++ b/cpp/src/slice2cs/Gen.cpp
@@ -62,6 +62,24 @@ sliceModeToIceMode(Operation::Mode opMode)
}
static string
+opFormatTypeToString(const OperationPtr& op)
+{
+ switch(op->format())
+ {
+ case DefaultFormat:
+ return "Ice.FormatType.DefaultFormat";
+ case CompactFormat:
+ return "Ice.FormatType.CompactFormat";
+ case SlicedFormat:
+ return "Ice.FormatType.SlicedFormat";
+ default:
+ assert(false);
+ }
+
+ return "???";
+}
+
+static string
getDeprecateReason(const ContainedPtr& p1, const ContainedPtr& p2, const string& type)
{
string deprecateMetadata, deprecateReason;
@@ -97,6 +115,133 @@ Slice::CsVisitor::~CsVisitor()
}
void
+Slice::CsVisitor::writeMarshalDataMember(const DataMemberPtr& member, const string& name)
+{
+ writeMarshalUnmarshalCode(_out, member->type(), name, true, false, false);
+
+#if 0
+ if(!member->optional())
+ {
+ writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()),
+ true, iter, false, member->getMetaData());
+ }
+ else
+ {
+ out << nl << "if(__has_" << member->name() << " && __os.writeOpt(" << member->tag() << ", "
+ << getOptionalType(member->type()) << "))";
+ out << sb;
+ writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), true,
+ iter, false, member->getMetaData());
+ out << eb;
+ }
+#endif
+}
+
+void
+Slice::CsVisitor::writeUnmarshalDataMember(const DataMemberPtr& member, const string& name, bool needPatcher,
+ int& patchIter)
+{
+ string patchParams = "this";
+ if(needPatcher)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type()))
+ {
+ ostringstream ostr;
+ ostr << ", " << patchIter++;
+ patchParams += ostr.str();
+ }
+ }
+
+ writeMarshalUnmarshalCode(_out, member->type(), name, false, false, false, patchParams);
+#if 0
+ if(!member->optional())
+ {
+ writeMarshalUnmarshalCode(out, package, member->type(), OptionalNone, false, 0, fixKwd(member->name()), false,
+ iter, false, member->getMetaData(), patchParams);
+ }
+ else
+ {
+ out << nl << "if(__has_" << member->name() << " = __is.readOpt(" << member->tag() << ", "
+ << getOptionalType(member->type()) << "))";
+ out << sb;
+ writeMarshalUnmarshalCode(out, package, member->type(), OptionalMember, false, 0, fixKwd(member->name()), false,
+ iter, false, member->getMetaData(), patchParams);
+ out << eb;
+ }
+#endif
+}
+
+void
+Slice::CsVisitor::writeStreamMarshalDataMember(const DataMemberPtr& member, const string& name)
+{
+ writeMarshalUnmarshalCode(_out, member->type(), name, true, true, false);
+#if 0
+ if(!member->optional())
+ {
+ writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), true,
+ iter, false, member->getMetaData());
+ }
+ else
+ {
+ out << nl << "if(__has_" << member->name() << " && __outS.writeOptional(" << member->tag() << ", "
+ << getOptionalType(member->type()) << "))";
+ out << sb;
+ writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()),
+ true, iter, false, member->getMetaData());
+ out << eb;
+ }
+#endif
+}
+
+void
+Slice::CsVisitor::writeStreamUnmarshalDataMember(const DataMemberPtr& member, const string& name, bool needPatcher,
+ int& patchIter)
+{
+ string patchParams = "this";
+ if(needPatcher)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type()))
+ {
+ ostringstream ostr;
+ ostr << ", " << patchIter++;
+ patchParams += ostr.str();
+ }
+ }
+
+ writeMarshalUnmarshalCode(_out, member->type(), name, false, true, false, patchParams);
+#if 0
+ string patchParams;
+ if(needPatcher)
+ {
+ BuiltinPtr builtin = BuiltinPtr::dynamicCast(member->type());
+ if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast(member->type()))
+ {
+ ostringstream ostr;
+ ostr << "new Patcher(" << patchIter++ << ')';
+ patchParams = ostr.str();
+ }
+ }
+
+ if(!member->optional())
+ {
+ writeStreamMarshalUnmarshalCode(out, package, member->type(), false, 0, fixKwd(member->name()), false,
+ iter, false, member->getMetaData(), patchParams);
+ }
+ else
+ {
+ out << nl << "if(__has_" << member->name() << " = __inS.readOptional(" << member->tag() << ", "
+ << getOptionalType(member->type()) << "))";
+ out << sb;
+ writeStreamMarshalUnmarshalCode(out, package, member->type(), true, member->tag(), fixKwd(member->name()),
+ false, iter, false, member->getMetaData(), patchParams);
+ out << eb;
+ }
+#endif
+}
+
+void
Slice::CsVisitor::writeInheritedOperations(const ClassDefPtr& p)
{
ClassList bases = p->bases();
@@ -445,7 +590,8 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
//
if(!outParams.empty() || ret)
{
- _out << nl << "IceInternal.BasicStream os__ = inS__.startWriteParams__();";
+ _out << nl << "IceInternal.BasicStream os__ = inS__.startWriteParams__("
+ << opFormatTypeToString(op) << ");";
for(q = outParams.begin(); q != outParams.end(); ++q)
{
writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, true, "");
@@ -478,8 +624,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
string exS = fixId((*t)->scoped());
_out << nl << "catch(" << exS << " ex__)";
_out << sb;
- _out << nl << "inS__.startWriteParams__().writeUserException(ex__);";
- _out << nl << "inS__.endWriteParams__(false);";
+ _out << nl << "inS__.writeUserException__(ex__, " << opFormatTypeToString(op) << ");";
_out << nl << "return Ice.DispatchStatus.DispatchUserException;";
_out << eb;
}
@@ -716,6 +861,9 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
DataMemberList::const_iterator d;
DataMemberList members = p->dataMembers();
DataMemberList classMembers = p->classDataMembers();
+ const bool basePreserved = p->inheritsMetaData("preserve-slice");
+ const bool preserved = basePreserved || p->hasMetaData("preserve-slice");
+
ClassList bases = p->bases();
ClassDefPtr base;
if(!bases.empty() && !bases.front()->isInterface())
@@ -732,15 +880,35 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
}
_out << nl << "public override void write__(IceInternal.BasicStream os__)";
_out << sb;
- _out << nl << "os__.writeTypeId(ice_staticId());";
- _out << nl << "os__.startWriteSlice();";
+ if(preserved)
+ {
+ _out << nl << "os__.startWriteObject(slicedData__);";
+ }
+ else
+ {
+ _out << nl << "os__.startWriteObject(null);";
+ }
+ _out << nl << "writeImpl__(os__);";
+ _out << nl << "os__.endWriteObject();";
+ _out << eb;
+
+ _out << sp;
+ if(!p->isInterface())
+ {
+ emitGeneratedCodeAttribute();
+ }
+ _out << nl << "public override void writeImpl__(IceInternal.BasicStream os__)";
+ _out << sb;
+ _out << nl << "os__.startWriteSlice(ice_staticId(), " << (!base ? "true" : "false") << ");";
for(d = members.begin(); d != members.end(); ++d)
{
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true),
- true, false, false);
+ writeMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true));
}
_out << nl << "os__.endWriteSlice();";
- _out << nl << "base.write__(os__);";
+ if(base)
+ {
+ _out << nl << "base.writeImpl__(os__);";
+ }
_out << eb;
if(allClassMembers.size() != 0)
@@ -826,31 +994,39 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
+ _out << nl << "public override void read__(IceInternal.BasicStream is__)";
_out << sb;
- _out << nl << "/* string myId = */ is__.readTypeId();";
+ _out << nl << "is__.startReadObject();";
+ _out << nl << "readImpl__(is__);";
+ if(preserved)
+ {
+ _out << nl << "slicedData__ = is__.endReadObject(true);";
+ }
+ else
+ {
+ _out << nl << "is__.endReadObject(false);";
+ }
_out << eb;
+
+ _out << sp;
+ if(!p->isInterface())
+ {
+ emitGeneratedCodeAttribute();
+ }
+ _out << nl << "public override void readImpl__(IceInternal.BasicStream is__)";
+ _out << sb;
_out << nl << "is__.startReadSlice();";
int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ const bool needCustomPatcher = classMembers.size() > 1 || allClassMembers.size() > 1;
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
- patchParams << "this";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true),
- false, false, false, patchParams.str());
+ writeUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), needCustomPatcher, classMemberCount);
}
_out << nl << "is__.endReadSlice();";
- _out << nl << "base.read__(is__, true);";
+ if(base)
+ {
+ _out << nl << "base.readImpl__(is__);";
+ }
_out << eb;
//
@@ -865,15 +1041,35 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
}
_out << nl << "public override void write__(Ice.OutputStream outS__)";
_out << sb;
- _out << nl << "outS__.writeTypeId(ice_staticId());";
- _out << nl << "outS__.startSlice();";
+ if(preserved)
+ {
+ _out << nl << "outS__.startObject(slicedData__);";
+ }
+ else
+ {
+ _out << nl << "outS__.startObject(null);";
+ }
+ _out << nl << "writeImpl__(outS__);";
+ _out << nl << "outS__.endObject();";
+ _out << eb;
+
+ _out << sp;
+ if(!p->isInterface())
+ {
+ emitGeneratedCodeAttribute();
+ }
+ _out << nl << "public " << (base ? "override" : "virtual") << " void writeImpl__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "outS__.startSlice(ice_staticId(), " << (!base ? "true" : "false") << ");";
for(d = members.begin(); d != members.end(); ++d)
{
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true),
- true, true, false);
+ writeStreamMarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true));
}
_out << nl << "outS__.endSlice();";
- _out << nl << "base.write__(outS__);";
+ if(base)
+ {
+ _out << nl << "base.writeImpl__(outS__);";
+ }
_out << eb;
_out << sp;
@@ -881,30 +1077,39 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << nl << "public override void read__(Ice.InputStream inS__)";
_out << sb;
- _out << nl << "if(rid__)";
- _out << sb;
- _out << nl << "/* string myId = */ inS__.readTypeId();";
+ _out << nl << "inS__.startObject();";
+ _out << nl << "readImpl__(inS__);";
+ if(preserved)
+ {
+ _out << nl << "slicedData__ = inS__.endObject(true);";
+ }
+ else
+ {
+ _out << nl << "inS__.endObject(false);";
+ }
_out << eb;
+
+ _out << sp;
+ if(!p->isInterface())
+ {
+ emitGeneratedCodeAttribute();
+ }
+ _out << nl << "public " << (base ? "override" : "virtual") << " void readImpl__(Ice.InputStream inS__)";
+ _out << sb;
_out << nl << "inS__.startSlice();";
+ classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
for(d = members.begin(); d != members.end(); ++d)
{
- ostringstream patchParams;
- patchParams << "this";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*d)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*d)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*d)->type(), fixId(*d, DotNet::ICloneable, true),
- false, true, false, patchParams.str());
+ writeStreamUnmarshalDataMember(*d, fixId(*d, DotNet::ICloneable, true), needCustomPatcher,
+ classMemberCount);
}
_out << nl << "inS__.endSlice();";
- _out << nl << "base.read__(inS__, true);";
+ if(base)
+ {
+ _out << nl << "base.readImpl__(inS__);";
+ }
_out << eb;
}
else
@@ -930,7 +1135,7 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
{
emitGeneratedCodeAttribute();
}
- _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << nl << "public override void read__(Ice.InputStream inS__)";
_out << sb;
_out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
_out << nl << "ex.reason = \"type " << scoped.substr(2) << " was not generated with stream support\";";
@@ -938,6 +1143,11 @@ Slice::CsVisitor::writeDispatchAndMarshalling(const ClassDefPtr& p, bool stream)
_out << eb;
}
+ if(preserved && !basePreserved)
+ {
+ _out << sp << nl << "protected Ice.SlicedData slicedData__;";
+ }
+
_out << sp << nl << "#endregion"; // Marshalling support
}
@@ -2844,8 +3054,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
}
else
{
- _out << nl << "int h__ = 0;";
+ _out << nl << "int h__ = 5381;";
}
+ _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, \"" << p->scoped() << "\");";
writeMemberHashCode(dataMembers, DotNet::Exception);
_out << nl << "return h__;";
_out << eb;
@@ -2905,21 +3116,38 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
string scoped = p->scoped();
ExceptionPtr base = p->base();
+ const bool basePreserved = p->inheritsMetaData("preserve-slice");
+ const bool preserved = basePreserved || p->hasMetaData("preserve-slice");
+
_out << sp;
emitGeneratedCodeAttribute();
_out << nl << "public override void write__(IceInternal.BasicStream os__)";
_out << sb;
- _out << nl << "os__.writeString(\"" << scoped << "\");";
- _out << nl << "os__.startWriteSlice();";
+ if(preserved)
+ {
+ _out << nl << "os__.startWriteException(slicedData__);";
+ }
+ else
+ {
+ _out << nl << "os__.startWriteException(null);";
+ }
+ _out << nl << "writeImpl__(os__);";
+ _out << nl << "os__.endWriteException();";
+ _out << eb;
+
+ _out << sp;
+ emitGeneratedCodeAttribute();
+ _out << nl << "public override void writeImpl__(IceInternal.BasicStream os__)";
+ _out << sb;
+ _out << nl << "os__.startWriteSlice(\"" << scoped << "\", " << (!base ? "true" : "false") << ");";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception),
- true, false, false);
+ writeMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception));
}
_out << nl << "os__.endWriteSlice();";
if(base)
{
- _out << nl << "base.write__(os__);";
+ _out << nl << "base.writeImpl__(os__);";
}
_out << eb;
@@ -3001,34 +3229,36 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << sp;
emitGeneratedCodeAttribute();
- _out << nl << "public override void read__(IceInternal.BasicStream is__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
+ _out << nl << "public override void read__(IceInternal.BasicStream is__)";
_out << sb;
- _out << nl << "/* string myId = */ is__.readString();";
+ _out << nl << "is__.startReadException();";
+ _out << nl << "readImpl__(is__);";
+ if(preserved)
+ {
+ _out << nl << "slicedData__ = is__.endReadException(true);";
+ }
+ else
+ {
+ _out << nl << "is__.endReadException(false);";
+ }
_out << eb;
+
+ _out << sp;
+ emitGeneratedCodeAttribute();
+ _out << nl << "public override void readImpl__(IceInternal.BasicStream is__)";
+ _out << sb;
_out << nl << "is__.startReadSlice();";
DataMemberList classMembers = p->classDataMembers();
int classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
+ const bool needCustomPatcher = classMembers.size() > 1 || allClassMembers.size() > 1;
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- ostringstream patchParams;
- patchParams << "this";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception),
- false, false, false, patchParams.str());
+ writeUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), needCustomPatcher, classMemberCount);
}
_out << nl << "is__.endReadSlice();";
if(base)
{
- _out << nl << "base.read__(is__, true);";
+ _out << nl << "base.readImpl__(is__);";
}
_out << eb;
@@ -3038,49 +3268,65 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
emitGeneratedCodeAttribute();
_out << nl << "public override void write__(Ice.OutputStream outS__)";
_out << sb;
- _out << nl << "outS__.writeString(\"" << scoped << "\");";
- _out << nl << "outS__.startSlice();";
+ if(preserved)
+ {
+ _out << nl << "outS__.startException(slicedData__);";
+ }
+ else
+ {
+ _out << nl << "outS__.startException(null);";
+ }
+ _out << nl << "writeImpl__(outS__);";
+ _out << nl << "outS__.endException();";
+ _out << eb;
+
+ _out << sp;
+ emitGeneratedCodeAttribute();
+ _out << nl << "public " << (base ? "override" : "virtual") << " void writeImpl__(Ice.OutputStream outS__)";
+ _out << sb;
+ _out << nl << "outS__.startSlice(\"" << scoped << "\", " << (!base ? "true" : "false") << ");";
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception),
- true, true, false);
+ writeStreamMarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception));
}
_out << nl << "outS__.endSlice();";
if(base)
{
- _out << nl << "base.write__(outS__);";
+ _out << nl << "base.writeImpl__(outS__);";
}
_out << eb;
_out << sp;
emitGeneratedCodeAttribute();
- _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
- _out << sb;
- _out << nl << "if(rid__)";
+ _out << nl << "public override void read__(Ice.InputStream inS__)";
_out << sb;
- _out << nl << "/* string myId = */ inS__.readString();";
+ _out << nl << "inS__.startException();";
+ _out << nl << "readImpl__(inS__);";
+ if(preserved)
+ {
+ _out << nl << "slicedData__ = inS__.endException(true);";
+ }
+ else
+ {
+ _out << nl << "inS__.endException(false);";
+ }
_out << eb;
+
+ _out << sp;
+ emitGeneratedCodeAttribute();
+ _out << nl << "public " << (base ? "override" : "virtual") << " void readImpl__(Ice.InputStream inS__)";
+ _out << sb;
_out << nl << "inS__.startSlice();";
classMemberCount = static_cast<int>(allClassMembers.size() - classMembers.size());
for(q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- ostringstream patchParams;
- patchParams << "this";
- BuiltinPtr builtin = BuiltinPtr::dynamicCast((*q)->type());
- if((builtin && builtin->kind() == Builtin::KindObject) || ClassDeclPtr::dynamicCast((*q)->type()))
- {
- if(classMembers.size() > 1 || allClassMembers.size() > 1)
- {
- patchParams << ", " << classMemberCount++;
- }
- }
- writeMarshalUnmarshalCode(_out, (*q)->type(), fixId((*q)->name(), DotNet::Exception),
- false, true, false, patchParams.str());
+ writeStreamUnmarshalDataMember(*q, fixId((*q)->name(), DotNet::Exception), needCustomPatcher,
+ classMemberCount);
}
_out << nl << "inS__.endSlice();";
if(base)
{
- _out << nl << "base.read__(inS__, true);";
+ _out << nl << "base.readImpl__(inS__);";
}
_out << eb;
}
@@ -3100,7 +3346,7 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << sp;
emitGeneratedCodeAttribute();
- _out << nl << "public override void read__(Ice.InputStream inS__, bool rid__)";
+ _out << nl << "public override void read__(Ice.InputStream inS__)";
_out << sb;
_out << nl << "Ice.MarshalException ex = new Ice.MarshalException();";
_out << nl << "ex.reason = \"exception " << scoped.substr(2) << " was not generated with stream support\";";
@@ -3108,14 +3354,9 @@ Slice::Gen::TypesVisitor::visitExceptionEnd(const ExceptionPtr& p)
_out << eb;
}
- if((!base || (base && !base->usesClasses())) && p->usesClasses())
+ if(preserved && !basePreserved)
{
- _out << sp;
- emitGeneratedCodeAttribute();
- _out << nl << "public override bool usesClasses__()";
- _out << sb;
- _out << nl << "return true;";
- _out << eb;
+ _out << sp << nl << "protected Ice.SlicedData slicedData__;";
}
_out << sp << nl << "#endregion"; // Marshalling support
@@ -3252,7 +3493,8 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
emitGeneratedCodeAttribute();
_out << nl << "public override int GetHashCode()";
_out << sb;
- _out << nl << "int h__ = 0;";
+ _out << nl << "int h__ = 5381;";
+ _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, \"" << p->scoped() << "\");";
writeMemberHashCode(dataMembers, isClass ? DotNet::ICloneable : 0);
_out << nl << "return h__;";
_out << eb;
@@ -3678,73 +3920,7 @@ Slice::Gen::TypesVisitor::writeMemberHashCode(const DataMemberList& dataMembers,
{
for(DataMemberList::const_iterator q = dataMembers.begin(); q != dataMembers.end(); ++q)
{
- string memberName = fixId((*q)->name(), baseTypes);
- TypePtr memberType = (*q)->type();
- bool isValue = isValueType(memberType);
- if(!isValue)
- {
- _out << nl << "if(" << memberName << " != null)";
- _out << sb;
- }
- SequencePtr seq = SequencePtr::dynamicCast(memberType);
- if(seq)
- {
- string meta;
- bool isSerializable = seq->findMetaData("clr:serializable", meta);
- bool isGeneric = seq->findMetaData("clr:generic:", meta);
- bool isArray = !isSerializable && !isGeneric && !seq->hasMetaData("clr:collection");
- if(isArray)
- {
- //
- // GetHashCode() for native arrays does not have value semantics.
- //
- _out << nl << "h__ = 5 * h__ + IceUtilInternal.Arrays.GetHashCode(" << memberName << ");";
- }
- else if(isGeneric)
- {
- //
- // GetHashCode() for generic types does not have value semantics.
- //
- _out << nl << "h__ = 5 * h__ + IceUtilInternal.Collections.SequenceGetHashCode(" << memberName << ");";
- }
- else
- {
- //
- // GetHashCode() for CollectionBase has value semantics.
- //
- _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
- }
- }
- else
- {
- DictionaryPtr dict = DictionaryPtr::dynamicCast(memberType);
- if(dict)
- {
- if(dict->hasMetaData("clr:collection"))
- {
- //
- // GetHashCode() for DictionaryBase has value semantics.
- //
- _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
- }
- else
- {
- //
- // GetHashCode() for generic types does not have value semantics.
- //
- _out << nl << "h__ = 5 * h__ + IceUtilInternal.Collections.DictionaryGetHashCode(" << memberName
- << ");";
- }
- }
- else
- {
- _out << nl << "h__ = 5 * h__ + " << memberName << ".GetHashCode();";
- }
- }
- if(!isValue)
- {
- _out << eb;
- }
+ _out << nl << "IceInternal.HashUtil.hashAdd(ref h__, " << fixId((*q)->name(), baseTypes) << ");";
}
}
@@ -4598,7 +4774,8 @@ Slice::Gen::HelperVisitor::visitClassDefStart(const ClassDefPtr& p)
<< sliceModeToIceMode(op->sendMode()) << ", ctx__, explicitContext__);";
if(!inParams.empty())
{
- _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams__();";
+ _out << nl << "IceInternal.BasicStream os__ = result__.startWriteParams__("
+ << opFormatTypeToString(op) << ");";
for(q = inParams.begin(); q != inParams.end(); ++q)
{
string typeS = typeToString(q->first);
@@ -5478,7 +5655,7 @@ Slice::Gen::DelegateMVisitor::visitClassDefStart(const ClassDefPtr& p)
{
_out << nl << "try";
_out << sb;
- _out << nl << "IceInternal.BasicStream os__ = og__.startWriteParams();";
+ _out << nl << "IceInternal.BasicStream os__ = og__.startWriteParams(" << opFormatTypeToString(op) << ");";
for(q = inParams.begin(); q != inParams.end(); ++q)
{
writeMarshalUnmarshalCode(_out, q->first, fixId(q->second), true, false, false);
@@ -6110,7 +6287,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
{
_out << nl << "try";
_out << sb;
- _out << nl << "IceInternal.BasicStream os__ = startWriteParams__();";
+ _out << nl << "IceInternal.BasicStream os__ = startWriteParams__(" << opFormatTypeToString(p) << ");";
for(q = outParams.begin(); q != outParams.end(); ++q)
{
string typeS = typeToString(q->first);
@@ -6156,8 +6333,7 @@ Slice::Gen::AsyncVisitor::visitOperation(const OperationPtr& p)
_out << sb;
_out << nl << "if(validateResponse__(false))";
_out << sb;
- _out << nl << "startWriteParams__().writeUserException(ex__);";
- _out << nl << "endWriteParams__(false);";
+ _out << nl << "writeUserException__(ex__, " << opFormatTypeToString(p) << ");";
_out << nl << "response__();";
_out << eb;
_out << eb;
diff --git a/cpp/src/slice2cs/Gen.h b/cpp/src/slice2cs/Gen.h
index bec13760eaf..2c171a71e25 100644
--- a/cpp/src/slice2cs/Gen.h
+++ b/cpp/src/slice2cs/Gen.h
@@ -24,6 +24,11 @@ public:
protected:
+ void writeMarshalDataMember(const DataMemberPtr&, const std::string&);
+ void writeUnmarshalDataMember(const DataMemberPtr&, const std::string&, bool, int&);
+ void writeStreamMarshalDataMember(const DataMemberPtr&, const std::string&);
+ void writeStreamUnmarshalDataMember(const DataMemberPtr&, const std::string&, bool, int&);
+
virtual void writeInheritedOperations(const ClassDefPtr&);
virtual void writeDispatchAndMarshalling(const ClassDefPtr&, bool);
virtual std::vector<std::string> getParams(const OperationPtr&);
diff --git a/cpp/src/slice2cs/Main.cpp b/cpp/src/slice2cs/Main.cpp
index 4ebc975b0f8..8539e303244 100644
--- a/cpp/src/slice2cs/Main.cpp
+++ b/cpp/src/slice2cs/Main.cpp
@@ -22,7 +22,7 @@ using namespace Slice;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -31,13 +31,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -48,7 +48,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -303,7 +303,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2freeze/Main.cpp b/cpp/src/slice2freeze/Main.cpp
index 9cf0e4477e3..2d2020f10a2 100644
--- a/cpp/src/slice2freeze/Main.cpp
+++ b/cpp/src/slice2freeze/Main.cpp
@@ -28,7 +28,7 @@ using namespace Slice;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -37,13 +37,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -56,7 +56,7 @@ string ICE_ENCODING_COMPARE = "Freeze::IceEncodingCompare";
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -1999,7 +1999,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
@@ -2046,7 +2046,7 @@ compile(int argc, char* argv[])
u->destroy();
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2freezej/Main.cpp b/cpp/src/slice2freezej/Main.cpp
index 9f85a9f5536..a08642d2650 100755
--- a/cpp/src/slice2freezej/Main.cpp
+++ b/cpp/src/slice2freezej/Main.cpp
@@ -26,7 +26,7 @@ using namespace IceUtilInternal;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -35,13 +35,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -52,7 +52,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> lock(globalMutex);
interrupted = true;
}
@@ -1841,7 +1841,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
@@ -1941,7 +1941,7 @@ compile(int argc, char* argv[])
u->destroy();
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2html/Main.cpp b/cpp/src/slice2html/Main.cpp
index 26caf348009..861cbafb0bb 100755
--- a/cpp/src/slice2html/Main.cpp
+++ b/cpp/src/slice2html/Main.cpp
@@ -24,7 +24,7 @@ using namespace IceUtil;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -33,13 +33,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -50,7 +50,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -254,7 +254,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
@@ -296,7 +296,7 @@ compile(int argc, char* argv[])
p->destroy();
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2java/Gen.cpp b/cpp/src/slice2java/Gen.cpp
index 3f0c23c2aca..1a9b678b6aa 100644
--- a/cpp/src/slice2java/Gen.cpp
+++ b/cpp/src/slice2java/Gen.cpp
@@ -465,110 +465,6 @@ Slice::JavaVisitor::writeDelegateThrowsClause(const string& package, const Excep
}
void
-Slice::JavaVisitor::writeHashCode(Output& out, const TypePtr& type, const string& name, int& iter,
- const StringList& metaData)
-{
- BuiltinPtr builtin = BuiltinPtr::dynamicCast(type);
- if(builtin)
- {
- switch(builtin->kind())
- {
- case Builtin::KindByte:
- case Builtin::KindShort:
- case Builtin::KindLong:
- {
- out << nl << "__h = 5 * __h + (int)" << name << ';';
- break;
- }
- case Builtin::KindBool:
- {
- out << nl << "__h = 5 * __h + (" << name << " ? 1 : 0);";
- break;
- }
- case Builtin::KindInt:
- {
- out << nl << "__h = 5 * __h + " << name << ';';
- break;
- }
- case Builtin::KindFloat:
- {
- out << nl << "__h = 5 * __h + java.lang.Float.floatToIntBits(" << name << ");";
- break;
- }
- case Builtin::KindDouble:
- {
- out << nl << "__h = 5 * __h + (int)java.lang.Double.doubleToLongBits(" << name << ");";
- break;
- }
- case Builtin::KindString:
- {
- out << nl << "if(" << name << " != null)";
- out << sb;
- out << nl << "__h = 5 * __h + " << name << ".hashCode();";
- out << eb;
- break;
- }
- case Builtin::KindObject:
- case Builtin::KindObjectProxy:
- case Builtin::KindLocalObject:
- {
- out << nl << "if(" << name << " != null)";
- out << sb;
- out << nl << "__h = 5 * __h + " << name << ".hashCode();";
- out << eb;
- break;
- }
- }
- return;
- }
-
- ProxyPtr prx = ProxyPtr::dynamicCast(type);
- ClassDeclPtr cl = ClassDeclPtr::dynamicCast(type);
- DictionaryPtr dict = DictionaryPtr::dynamicCast(type);
- if(prx || cl || dict)
- {
- out << nl << "if(" << name << " != null)";
- out << sb;
- out << nl << "__h = 5 * __h + " << name << ".hashCode();";
- out << eb;
- return;
- }
-
- SequencePtr seq = SequencePtr::dynamicCast(type);
- if(seq)
- {
- bool customType = hasTypeMetaData(seq, metaData);
-
- out << nl << "if(" << name << " != null)";
- out << sb;
- if(customType)
- {
- out << nl << "__h = 5 * __h + " << name << ".hashCode();";
- }
- else
- {
- out << nl << "for(int __i" << iter << " = 0; __i" << iter << " < " << name << ".length; __i" << iter
- << "++)";
- out << sb;
- ostringstream elem;
- elem << name << "[__i" << iter << ']';
- iter++;
- writeHashCode(out, seq->type(), elem.str(), iter);
- out << eb;
- }
- out << eb;
- return;
- }
-
- ConstructedPtr constructed = ConstructedPtr::dynamicCast(type);
- assert(constructed);
- out << nl << "if(" << name << " != null)";
- out << sb;
- out << nl << "__h = 5 * __h + " << name << ".hashCode();";
- out << eb;
-}
-
-void
Slice::JavaVisitor::writeMarshalDataMember(Output& out, const string& package, const DataMemberPtr& member, int& iter)
{
if(!member->optional())
@@ -2528,14 +2424,6 @@ Slice::Gen::TieVisitor::visitClassDefStart(const ClassDefPtr& p)
if(p->isLocal())
{
- out << sp << nl << "/**";
- out << nl << " * @deprecated This method is deprecated, use hashCode instead.";
- out << nl << " **/";
- out << nl << "public int" << nl << "ice_hash()";
- out << sb;
- out << nl << "return hashCode();";
- out << eb;
-
out << sp << nl << "public java.lang.Object" << nl << "clone()";
out.inc();
out << nl << "throws java.lang.CloneNotSupportedException";
@@ -3772,13 +3660,13 @@ Slice::Gen::TypesVisitor::visitStructEnd(const StructPtr& p)
out << sp << nl << "public int" << nl << "hashCode()";
out << sb;
- out << nl << "int __h = 0;";
+ out << nl << "int __h = 5381;";
+ out << nl << "__h = IceInternal.HashUtil.hashAdd(__h, \"" << p->scoped() << "\");";
iter = 0;
for(d = members.begin(); d != members.end(); ++d)
{
string memberName = fixKwd((*d)->name());
- StringList metaData = (*d)->getMetaData();
- writeHashCode(out, (*d)->type(), memberName, iter, metaData);
+ out << nl << "__h = IceInternal.HashUtil.hashAdd(__h, " << memberName << ");";
}
out << nl << "return __h;";
out << eb;
diff --git a/cpp/src/slice2java/Main.cpp b/cpp/src/slice2java/Main.cpp
index 6ced6400644..02e92a9bd6b 100644
--- a/cpp/src/slice2java/Main.cpp
+++ b/cpp/src/slice2java/Main.cpp
@@ -23,7 +23,7 @@ using namespace Slice;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -32,13 +32,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -49,7 +49,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -356,7 +356,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2php/Main.cpp b/cpp/src/slice2php/Main.cpp
index a30a16eca2d..4a566ffb7c0 100644
--- a/cpp/src/slice2php/Main.cpp
+++ b/cpp/src/slice2php/Main.cpp
@@ -1491,7 +1491,7 @@ printHeader(IceUtilInternal::Output& out)
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -1500,13 +1500,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -1517,7 +1517,7 @@ Init init;
static void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -1780,7 +1780,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2py/Main.cpp b/cpp/src/slice2py/Main.cpp
index 08e947d3ecb..dee21f342b1 100644
--- a/cpp/src/slice2py/Main.cpp
+++ b/cpp/src/slice2py/Main.cpp
@@ -40,7 +40,7 @@ using namespace Slice::Python;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -49,13 +49,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -66,7 +66,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -631,7 +631,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{
diff --git a/cpp/src/slice2rb/Main.cpp b/cpp/src/slice2rb/Main.cpp
index 9afaffeaf73..0f899485d02 100644
--- a/cpp/src/slice2rb/Main.cpp
+++ b/cpp/src/slice2rb/Main.cpp
@@ -23,11 +23,9 @@
#include <sys/stat.h>
#ifdef _WIN32
-#include <direct.h>
-#endif
-
-#ifndef _WIN32
-#include <unistd.h>
+# include <direct.h>
+#else
+# include <unistd.h>
#endif
#include <string.h>
@@ -39,7 +37,7 @@ using namespace Slice::Ruby;
namespace
{
-IceUtil::Mutex* mutex = 0;
+IceUtil::Mutex* globalMutex = 0;
bool interrupted = false;
class Init
@@ -48,13 +46,13 @@ public:
Init()
{
- mutex = new IceUtil::Mutex;
+ globalMutex = new IceUtil::Mutex;
}
~Init()
{
- delete mutex;
- mutex = 0;
+ delete globalMutex;
+ globalMutex = 0;
}
};
@@ -65,7 +63,7 @@ Init init;
void
interruptedCallback(int signal)
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
interrupted = true;
}
@@ -316,7 +314,7 @@ compile(int argc, char* argv[])
}
{
- IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(mutex);
+ IceUtilInternal::MutexPtrLock<IceUtil::Mutex> sync(globalMutex);
if(interrupted)
{