diff options
author | Benoit Foucher <benoit@zeroc.com> | 2018-02-16 12:36:36 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2018-02-16 12:36:36 +0100 |
commit | 1d9509c347547b2d36d6fa3ff667927836d72245 (patch) | |
tree | df6cc4ac9d1e2742ae8d9bf36a4f7927e7f970c1 /csharp/src/Ice/ObjectAdapterFactory.cs | |
parent | Allow to create NuGet packages with single platform/configuration (diff) | |
download | ice-1d9509c347547b2d36d6fa3ff667927836d72245.tar.bz2 ice-1d9509c347547b2d36d6fa3ff667927836d72245.tar.xz ice-1d9509c347547b2d36d6fa3ff667927836d72245.zip |
Improved object adapter getPublishedEndpoints/refreshPublishedEndpoints method
to return the Ice router server endpoints if the adapter is associated with a
router.
setPublishedEndpoints now also raises an invalid argument exception for such
adapters.
Also fixed a rare deadlock that could occur on adapter creating if the router
wasn't accessible.
Fixes ICE-8675 and ICE-8650
Diffstat (limited to 'csharp/src/Ice/ObjectAdapterFactory.cs')
-rw-r--r-- | csharp/src/Ice/ObjectAdapterFactory.cs | 59 |
1 files changed, 49 insertions, 10 deletions
diff --git a/csharp/src/Ice/ObjectAdapterFactory.cs b/csharp/src/Ice/ObjectAdapterFactory.cs index 9992d9da8e2..394ee773f71 100644 --- a/csharp/src/Ice/ObjectAdapterFactory.cs +++ b/csharp/src/Ice/ObjectAdapterFactory.cs @@ -141,13 +141,7 @@ namespace IceInternal throw new Ice.CommunicatorDestroyedException(); } - Ice.ObjectAdapterI adapter = null; - if(name.Length == 0) - { - string uuid = System.Guid.NewGuid().ToString(); - adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, null, true); - } - else + if(name.Length > 0) { if(_adapterNamesInUse.Contains(name)) { @@ -156,12 +150,57 @@ namespace IceInternal ex.id = name; throw ex; } - adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, router, false); _adapterNamesInUse.Add(name); } - _adapters.Add(adapter); - return adapter; } + + // + // Must be called outside the synchronization since initialize can make client invocations + // on the router if it's set. + // + Ice.ObjectAdapterI adapter = null; + try + { + if(name.Length == 0) + { + string uuid = System.Guid.NewGuid().ToString(); + adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, uuid, null, true); + } + else + { + adapter = new Ice.ObjectAdapterI(_instance, _communicator, this, name, router, false); + } + + lock(this) + { + if(_instance == null) + { + throw new Ice.CommunicatorDestroyedException(); + } + _adapters.Add(adapter); + } + } + catch(Ice.CommunicatorDestroyedException ex) + { + if(adapter != null) + { + adapter.destroy(); + } + throw ex; + } + catch(Ice.LocalException ex) + { + if(name.Length > 0) + { + lock(this) + { + _adapterNamesInUse.Remove(name); + } + } + throw ex; + } + + return adapter; } public Ice.ObjectAdapter findObjectAdapter(Ice.ObjectPrx proxy) |