diff options
Diffstat (limited to 'csharp/src')
49 files changed, 505 insertions, 420 deletions
diff --git a/csharp/src/Glacier2/Application.cs b/csharp/src/Glacier2/Application.cs index b241aff9e70..cc1be419d01 100644 --- a/csharp/src/Glacier2/Application.cs +++ b/csharp/src/Glacier2/Application.cs @@ -33,24 +33,23 @@ public abstract class Application : Ice.Application } /// <summary> - /// Initializes an instance that calls Communicator.shutdown if - /// a signal is received. + /// Initializes an instance that handles signals according to the signal policy. + /// If not signal policy is provided the default SinalPolicy.HandleSignals + /// will be used, which calls Communicator.shutdown if a signal is received. /// </summary> - public - Application() + /// <param name="signalPolicy">Determines how to respond to signals.</param> + public Application(Ice.SignalPolicy signalPolicy = Ice.SignalPolicy.HandleSignals) : base(signalPolicy) { } /// <summary> - /// Initializes an instance that handles signals according to the signal - /// policy. + /// Creates a new Glacier2 session. A call to createSession always + /// precedes a call to runWithSession. If Ice.LocalException is thrown + /// from this method, the application is terminated. /// </summary> - /// <param name="signalPolicy">@param signalPolicy Determines how to - /// respond to signals.</param> - public - Application(Ice.SignalPolicy signalPolicy) : base(signalPolicy) - { - } + /// <returns> The Glacier2 session.</returns> + public abstract Glacier2.SessionPrx + createSession(); /// <summary> /// Called once the communicator has been initialized and the Glacier2 session @@ -85,6 +84,18 @@ public abstract class Application : Ice.Application } /// <summary> + /// Called when the session refresh thread detects that the session has been + /// destroyed. A subclass can override this method to take action after the + /// loss of connectivity with the Glacier2 router. This method is called + /// according to the Ice invocation dipsatch rules (in other words, it + /// uses the same rules as an servant upcall or AMI callback). + /// </summary> + public virtual void + sessionDestroyed() + { + } + + /// <summary> /// Called to restart the application's Glacier2 session. This /// method never returns. The exception produce an application restart /// when called from the Application main thread. @@ -92,34 +103,13 @@ public abstract class Application : Ice.Application /// <returns>throws RestartSessionException This exception is /// always thrown.</returns> /// - public void + public static void restart() { throw new RestartSessionException(); } /// <summary> - /// Creates a new Glacier2 session. A call to createSession always - /// precedes a call to runWithSession. If Ice.LocalException is thrown - /// from this method, the application is terminated. - /// </summary> - /// <returns> The Glacier2 session.</returns> - public abstract Glacier2.SessionPrx - createSession(); - - /// <summary> - /// Called when the session refresh thread detects that the session has been - /// destroyed. A subclass can override this method to take action after the - /// loss of connectivity with the Glacier2 router. This method is called - /// according to the Ice invocation dipsatch rules (in other words, it - /// uses the same rules as an servant upcall or AMI callback). - /// </summary> - public virtual void - sessionDestroyed() - { - } - - /// <summary> /// Returns the Glacier2 router proxy. /// </summary> /// <returns>The router proxy.</returns> @@ -146,7 +136,7 @@ public abstract class Application : Ice.Application /// Throws SessionNotExistException if no session exists. /// </summary> /// <returns>The category.</returns> - public string + public static string categoryForClient() { if(_router == null) @@ -161,7 +151,7 @@ public abstract class Application : Ice.Application /// identity name field. /// </summary> /// <returns>The identity.</returns> - public Ice.Identity + public static Ice.Identity createCallbackIdentity(string name) { return new Ice.Identity(name, categoryForClient()); @@ -172,7 +162,7 @@ public abstract class Application : Ice.Application /// </summary> /// <param name="servant">The servant to add.</param> /// <returns>The proxy for the servant.</returns> - public Ice.ObjectPrx + public static Ice.ObjectPrx addWithUUID(Ice.Object servant) { return objectAdapter().add(servant, createCallbackIdentity(Guid.NewGuid().ToString())); @@ -182,7 +172,7 @@ public abstract class Application : Ice.Application /// Returns an object adapter for callback objects, creating it if necessary. /// </summary> /// <returns>The object adapter.</returns> - public Ice.ObjectAdapter + public static Ice.ObjectAdapter objectAdapter() { if(_router == null) @@ -240,6 +230,7 @@ public abstract class Application : Ice.Application iceInterrupted = false; bool restart = false; + bool sessionCreated = false; status = 0; try @@ -268,7 +259,7 @@ public abstract class Application : Ice.Application try { _session = createSession(); - _createdSession = true; + sessionCreated = true; } catch(Ice.LocalException ex) { @@ -276,7 +267,7 @@ public abstract class Application : Ice.Application status = 1; } - if(_createdSession) + if(sessionCreated) { int acmTimeout = 0; try @@ -380,7 +371,7 @@ public abstract class Application : Ice.Application } } - if(_createdSession && _router != null) + if(sessionCreated && _router != null) { try { @@ -436,7 +427,6 @@ public abstract class Application : Ice.Application _adapter = null; _router = null; _session = null; - _createdSession = false; _category = null; return restart; @@ -445,7 +435,6 @@ public abstract class Application : Ice.Application private static Ice.ObjectAdapter _adapter; private static RouterPrx _router; private static SessionPrx _session; - private static bool _createdSession = false; private static string _category; } diff --git a/csharp/src/Glacier2/AssemblyInfo.cs b/csharp/src/Glacier2/AssemblyInfo.cs index 03764fe9cb7..8cf71a52695 100644 --- a/csharp/src/Glacier2/AssemblyInfo.cs +++ b/csharp/src/Glacier2/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/Glacier2/SessionCallback.cs b/csharp/src/Glacier2/SessionCallback.cs index b9dfe5e6d6f..2a720d367dc 100644 --- a/csharp/src/Glacier2/SessionCallback.cs +++ b/csharp/src/Glacier2/SessionCallback.cs @@ -30,7 +30,7 @@ public interface SessionCallback /// </summary> /// <param name="session">The established session.</param> void connected(SessionHelper session); - + /// <summary> /// Notifies the application that the Glacier2 session has been /// disconnected. @@ -40,7 +40,7 @@ public interface SessionCallback /// <summary> /// Notifies the application that the Glacier2 session - /// establishment failed. + /// establishment failed. /// </summary> /// <param name="session">The session reporting the connection /// failure.</param> diff --git a/csharp/src/Glacier2/SessionHelper.cs b/csharp/src/Glacier2/SessionHelper.cs index 547221e8924..73c016377cb 100644 --- a/csharp/src/Glacier2/SessionHelper.cs +++ b/csharp/src/Glacier2/SessionHelper.cs @@ -29,7 +29,7 @@ public class SessionHelper /// the communicator.</param> /// <param name="finderStr">The stringified Ice.RouterFinder proxy.</param> /// <param name="useCallbacks">True if the session should create an object adapter for receiving callbacks.</param> - public SessionHelper(SessionCallback callback, Ice.InitializationData initData, string finderStr, bool useCallbacks) + internal SessionHelper(SessionCallback callback, Ice.InitializationData initData, string finderStr, bool useCallbacks) { _callback = callback; _initData = initData; @@ -201,7 +201,7 @@ public class SessionHelper /// the exception. /// </summary> /// <param name="context">The request context to use when creating the session.</param> - public void + internal void connect(Dictionary<string, string> context) { lock(this) @@ -222,7 +222,7 @@ public class SessionHelper /// <param name="username">The user name.</param> /// <param name="password">The password.</param> /// <param name="context">The request context to use when creating the session.</param> - public void + internal void connect(string username, string password, Dictionary<string, string> context) { lock(this) diff --git a/csharp/src/Ice/ACM.cs b/csharp/src/Ice/ACM.cs index 28a8b0427b7..e0d03af69c0 100644 --- a/csharp/src/Ice/ACM.cs +++ b/csharp/src/Ice/ACM.cs @@ -20,11 +20,11 @@ namespace IceInternal heartbeat = Ice.ACMHeartbeat.HeartbeatOnInvocation; close = server ? Ice.ACMClose.CloseOnInvocation : Ice.ACMClose.CloseOnInvocationAndIdle; } - + public ACMConfig(Ice.Properties p, Ice.Logger l, string prefix, ACMConfig dflt) { Debug.Assert(prefix != null); - + string timeoutProperty; if((prefix.Equals("Ice.ACM.Client") || prefix.Equals("Ice.ACM.Server")) && p.getProperty(prefix + ".Timeout").Length == 0) @@ -35,7 +35,7 @@ namespace IceInternal { timeoutProperty = prefix + ".Timeout"; } - + timeout = p.getPropertyAsIntWithDefault(timeoutProperty, dflt.timeout / 1000) * 1000; int hb = p.getPropertyAsIntWithDefault(prefix + ".Heartbeat", (int)dflt.heartbeat); @@ -45,7 +45,7 @@ namespace IceInternal } else { - l.warning("invalid value for property `" + prefix + ".Heartbeat" + + l.warning("invalid value for property `" + prefix + ".Heartbeat" + "', default value will be used instead"); heartbeat = dflt.heartbeat; } @@ -78,7 +78,7 @@ namespace IceInternal void add(Ice.ConnectionI con); void remove(Ice.ConnectionI con); void reap(Ice.ConnectionI con); - + ACMMonitor acm(Ice.Optional<int> timeout, Ice.Optional<Ice.ACMClose> c, Ice.Optional<Ice.ACMHeartbeat> h); Ice.ACM getACM(); } @@ -144,7 +144,7 @@ namespace IceInternal { return; } - + lock(this) { Debug.Assert(_instance != null); @@ -163,7 +163,7 @@ namespace IceInternal public ACMMonitor acm(Ice.Optional<int> timeout, Ice.Optional<Ice.ACMClose> c, Ice.Optional<Ice.ACMHeartbeat> h) { Debug.Assert(_instance != null); - + ACMConfig config = (ACMConfig)_config.Clone(); if(timeout.HasValue) { @@ -179,7 +179,7 @@ namespace IceInternal } return new ConnectionACMMonitor(this, _instance.timer(), config); } - + public Ice.ACM getACM() { Ice.ACM acm = new Ice.ACM(); @@ -188,7 +188,7 @@ namespace IceInternal acm.heartbeat = _config.heartbeat; return acm; } - + internal List<Ice.ConnectionI> swapReapedConnections() { lock(this) @@ -231,8 +231,8 @@ namespace IceInternal return; } } - - + + // // Monitor connections outside the thread synchronization, so // that connections can be added or removed during monitoring. @@ -241,16 +241,16 @@ namespace IceInternal foreach(Ice.ConnectionI connection in _connections) { try - { + { connection.monitor(now, _config); } catch(System.Exception ex) - { + { handleException(ex); } } } - + internal void handleException(System.Exception ex) { lock(this) @@ -258,7 +258,7 @@ namespace IceInternal if(_instance == null) { return; - } + } _instance.initializationData().logger.error("exception in connection monitor:\n" + ex); } } @@ -305,17 +305,17 @@ namespace IceInternal } } } - + public void reap(Ice.ConnectionI connection) { _parent.reap(connection); } - + public ACMMonitor acm(Ice.Optional<int> timeout, Ice.Optional<Ice.ACMClose> c, Ice.Optional<Ice.ACMHeartbeat> h) { return _parent.acm(timeout, c, h); } - + public Ice.ACM getACM() { Ice.ACM acm = new Ice.ACM(); @@ -324,7 +324,7 @@ namespace IceInternal acm.heartbeat = _config.heartbeat; return acm; } - + public void runTimerTask() { Ice.ConnectionI connection; @@ -336,13 +336,13 @@ namespace IceInternal } connection = _connection; } - + try - { + { connection.monitor(Time.currentMonotonicTimeMillis(), _config); } catch(System.Exception ex) - { + { _parent.handleException(ex); } } diff --git a/csharp/src/Ice/Application.cs b/csharp/src/Ice/Application.cs index b7a15c2184a..396001a1add 100644 --- a/csharp/src/Ice/Application.cs +++ b/csharp/src/Ice/Application.cs @@ -79,11 +79,11 @@ namespace Ice /// <summary> /// Initializes an instance that handles signals according to the signal policy. - /// If not signal policy is provided the default SinalPolicy.NoSignalHandling + /// If not signal policy is provided the default SinalPolicy.HandleSignals /// will be used, which calls Communicator.shutdown if a signal is received. /// </summary> /// <param name="signalPolicy">Determines how to respond to signals.</param> - public Application(SignalPolicy signalPolicy = SignalPolicy.NoSignalHandling) + public Application(SignalPolicy signalPolicy = SignalPolicy.HandleSignals) { } diff --git a/csharp/src/Ice/Arrays.cs b/csharp/src/Ice/Arrays.cs index a18e2550798..d0e6c6fed84 100644 --- a/csharp/src/Ice/Arrays.cs +++ b/csharp/src/Ice/Arrays.cs @@ -46,7 +46,7 @@ namespace IceUtilInternal return true; } - return false; + return false; } public static bool Equals(Array arr1, Array arr2) @@ -84,7 +84,7 @@ namespace IceUtilInternal return true; } - return false; + return false; } public static int GetHashCode(object[] arr) @@ -100,7 +100,7 @@ namespace IceUtilInternal } } - return h; + return h; } public static int GetHashCode(Array arr) @@ -115,7 +115,7 @@ namespace IceUtilInternal } } - return h; + return h; } } } diff --git a/csharp/src/Ice/AssemblyInfo.cs b/csharp/src/Ice/AssemblyInfo.cs index 11542373a2a..adb14233030 100644 --- a/csharp/src/Ice/AssemblyInfo.cs +++ b/csharp/src/Ice/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/Ice/AsyncIOThread.cs b/csharp/src/Ice/AsyncIOThread.cs index c9d714a4074..7e080246bdb 100644 --- a/csharp/src/Ice/AsyncIOThread.cs +++ b/csharp/src/Ice/AsyncIOThread.cs @@ -33,9 +33,9 @@ namespace IceInternal Ice.Instrumentation.CommunicatorObserver obsv = _instance.initializationData().observer; if(obsv != null) { - _observer = obsv.getThreadObserver("Communicator", - _thread.getName(), - Ice.Instrumentation.ThreadState.ThreadStateIdle, + _observer = obsv.getThreadObserver("Communicator", + _thread.getName(), + Ice.Instrumentation.ThreadState.ThreadStateIdle, _observer); if(_observer != null) { @@ -83,7 +83,7 @@ namespace IceInternal { if(_observer != null && inUse) { - _observer.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForIO, + _observer.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateInUseForIO, Ice.Instrumentation.ThreadState.ThreadStateIdle); inUse = false; } @@ -104,7 +104,7 @@ namespace IceInternal if(_observer != null) { - _observer.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle, + _observer.stateChanged(Ice.Instrumentation.ThreadState.ThreadStateIdle, Ice.Instrumentation.ThreadState.ThreadStateInUseForIO); inUse = true; } diff --git a/csharp/src/Ice/Collections.cs b/csharp/src/Ice/Collections.cs index d5f6516123a..1b18fe0a1eb 100644 --- a/csharp/src/Ice/Collections.cs +++ b/csharp/src/Ice/Collections.cs @@ -50,7 +50,7 @@ namespace IceUtilInternal return true; } - return false; + return false; } public static bool SequenceEquals(IEnumerable seq1, IEnumerable seq2) @@ -91,7 +91,7 @@ namespace IceUtilInternal return false; } - return true; + return true; } public static int SequenceGetHashCode(IEnumerable seq) @@ -102,7 +102,7 @@ namespace IceUtilInternal { IceInternal.HashUtil.hashAdd(ref h, e.Current); } - return h; + return h; } public static bool DictionaryEquals(IDictionary d1, IDictionary d2) @@ -144,7 +144,7 @@ namespace IceUtilInternal return true; } - return false; + return false; } public static int DictionaryGetHashCode(IDictionary d) @@ -156,7 +156,7 @@ namespace IceUtilInternal IceInternal.HashUtil.hashAdd(ref h, e.Key); IceInternal.HashUtil.hashAdd(ref h, e.Value); } - return h; + return h; } public static void Shuffle<T>(ref List<T> l) @@ -224,16 +224,16 @@ namespace IceUtilInternal { tmp[k++] = array[i++]; } - while(j < end) + while(j < end) { tmp[k++] = array[j++]; } - for(i = 0; i < (end - begin); ++i) + for(i = 0; i < (end - begin); ++i) { array[begin + i] = tmp[i]; } } - private static System.Random _rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks)); + private static System.Random _rand = new System.Random(unchecked((int)System.DateTime.Now.Ticks)); } } diff --git a/csharp/src/Ice/ConnectionI.cs b/csharp/src/Ice/ConnectionI.cs index 1f02c48b6fb..4f348437e76 100644 --- a/csharp/src/Ice/ConnectionI.cs +++ b/csharp/src/Ice/ConnectionI.cs @@ -1746,6 +1746,11 @@ namespace Ice } } + public IceInternal.ThreadPool getThreadPool() + { + return _threadPool; + } + static ConnectionI() { _compressionSupported = IceInternal.BZip2.supported(); diff --git a/csharp/src/Ice/EndpointFactory.cs b/csharp/src/Ice/EndpointFactory.cs index 3bc4e979ea4..225cf374a15 100644 --- a/csharp/src/Ice/EndpointFactory.cs +++ b/csharp/src/Ice/EndpointFactory.cs @@ -13,13 +13,88 @@ namespace IceInternal public interface EndpointFactory { + void initialize(); short type(); string protocol(); EndpointI create(List<string> args, bool oaEndpoint); EndpointI read(Ice.InputStream s); void destroy(); - EndpointFactory clone(ProtocolInstance instance, EndpointFactory del); + EndpointFactory clone(ProtocolInstance instance); } + abstract public class EndpointFactoryWithUnderlying : EndpointFactory + { + public EndpointFactoryWithUnderlying(ProtocolInstance instance, short type) + { + instance_ = instance; + _type = type; + } + + public void initialize() + { + // + // Get the endpoint factory for the underlying type and clone it with + // our protocol instance. + // + EndpointFactory factory = instance_.getEndpointFactory(_type); + if(factory != null) + { + _underlying = factory.clone(instance_); + _underlying.initialize(); + } + } + + public short type() + { + return instance_.type(); + } + + public string protocol() + { + return instance_.protocol(); + } + + public EndpointI create(List<string> args, bool oaEndpoint) + { + if(_underlying == null) + { + return null; // Can't create an endpoint without underlying factory. + } + return createWithUnderlying(_underlying.create(args, oaEndpoint), args, oaEndpoint); + } + + public EndpointI read(Ice.InputStream s) + { + if(_underlying == null) + { + return null; // Can't create an endpoint without underlying factory. + } + return readWithUnderlying(_underlying.read(s), s); + } + + public void destroy() + { + if(_underlying != null) + { + _underlying.destroy(); + } + instance_ = null; + } + + public EndpointFactory clone(ProtocolInstance instance) + { + return cloneWithUnderlying(instance, _type); + } + + abstract public EndpointFactory cloneWithUnderlying(ProtocolInstance instance, short type); + + abstract protected EndpointI createWithUnderlying(EndpointI underlying, List<string> args, bool oaEndpoint); + abstract protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s); + + protected ProtocolInstance instance_; + + private readonly short _type; + private EndpointFactory _underlying; + } } diff --git a/csharp/src/Ice/EndpointFactoryManager.cs b/csharp/src/Ice/EndpointFactoryManager.cs index 7dc55c990b5..73c31e557aa 100644 --- a/csharp/src/Ice/EndpointFactoryManager.cs +++ b/csharp/src/Ice/EndpointFactoryManager.cs @@ -20,13 +20,20 @@ namespace IceInternal _factories = new List<EndpointFactory>(); } + public void initialize() + { + foreach(EndpointFactory f in _factories) + { + f.initialize(); + } + } + public void add(EndpointFactory factory) { lock(this) { - for(int i = 0; i < _factories.Count; i++) + foreach(EndpointFactory f in _factories) { - EndpointFactory f = _factories[i]; if(f.type() == factory.type()) { Debug.Assert(false); @@ -40,9 +47,8 @@ namespace IceInternal { lock(this) { - for(int i = 0; i < _factories.Count; i++) + foreach(EndpointFactory f in _factories) { - EndpointFactory f = _factories[i]; if(f.type() == type) { return f; @@ -173,7 +179,13 @@ namespace IceInternal { e = factory.read(s); } - else + // + // If the factory failed to read the endpoint, return an opaque endpoint. This can + // occur if for example the factory delegates to another factory and this factory + // isn't available. In this case, the factory needs to make sure the stream position + // is preserved for reading the opaque endpoint. + // + if(e == null) { e = new OpaqueEndpointI(type, s); } @@ -186,9 +198,8 @@ namespace IceInternal internal void destroy() { - for(int i = 0; i < _factories.Count; i++) + foreach(EndpointFactory f in _factories) { - EndpointFactory f = (EndpointFactory)_factories[i]; f.destroy(); } _factories.Clear(); diff --git a/csharp/src/Ice/EventHandler.cs b/csharp/src/Ice/EventHandler.cs index 486c665f27d..3e5ce930b39 100644 --- a/csharp/src/Ice/EventHandler.cs +++ b/csharp/src/Ice/EventHandler.cs @@ -33,7 +33,7 @@ public abstract class EventHandler internal int _pending = 0; internal int _started = 0; internal bool _finish = false; - + internal bool _hasMoreData = false; internal int _registered = 0; } diff --git a/csharp/src/Ice/ImplicitContextI.cs b/csharp/src/Ice/ImplicitContextI.cs index 67262f2b955..ecf19b14d6f 100644 --- a/csharp/src/Ice/ImplicitContextI.cs +++ b/csharp/src/Ice/ImplicitContextI.cs @@ -36,10 +36,10 @@ namespace Ice throw new InitializationException("'" + kind + "' is not a valid value for Ice.ImplicitContext"); } } - + public abstract Dictionary<string, string> getContext(); public abstract void setContext(Dictionary<string, string> newContext); - public abstract bool containsKey(string key); + public abstract bool containsKey(string key); public abstract string get(string key); public abstract string put(string key, string value); public abstract string remove(string key); @@ -47,8 +47,8 @@ namespace Ice abstract public void write(Dictionary<string, string> prxContext, OutputStream os); abstract internal Dictionary<string, string> combine(Dictionary<string, string> prxContext); } - - + + internal class SharedImplicitContext : ImplicitContextI { public override Dictionary<string, string> getContext() @@ -58,7 +58,7 @@ namespace Ice return new Dictionary<string, string>(_context); } } - + public override void setContext(Dictionary<string, string> context) { lock(this) @@ -73,7 +73,7 @@ namespace Ice } } } - + public override bool containsKey(string key) { lock(this) @@ -82,7 +82,7 @@ namespace Ice { key = ""; } - + return _context.ContainsKey(key); } } @@ -95,7 +95,7 @@ namespace Ice { key = ""; } - + string val = _context[key]; if(val == null) { @@ -104,8 +104,8 @@ namespace Ice return val; } } - - + + public override string put(string key, string value) { lock(this) @@ -126,11 +126,11 @@ namespace Ice oldVal = ""; } _context[key] = value; - + return oldVal; } } - + public override string remove(string key) { lock(this) @@ -154,7 +154,7 @@ namespace Ice return val; } } - + public override void write(Dictionary<string, string> prxContext, OutputStream os) { if(prxContext.Count == 0) @@ -164,12 +164,12 @@ namespace Ice ContextHelper.write(os, _context); } } - else + else { Dictionary<string, string> ctx = null; lock(this) { - ctx = _context.Count == 0 ? prxContext : combine(prxContext); + ctx = _context.Count == 0 ? prxContext : combine(prxContext); } ContextHelper.write(os, ctx); } @@ -231,7 +231,7 @@ namespace Ice else { Dictionary<string, string> threadContext = new Dictionary<string, string>(context); - + lock(this) { _map.Add(Thread.CurrentThread, threadContext); @@ -302,7 +302,7 @@ namespace Ice _map.Add(Thread.CurrentThread, threadContext); } } - + string oldVal; if(!threadContext.TryGetValue(key, out oldVal)) { @@ -349,7 +349,7 @@ namespace Ice { _map.TryGetValue(Thread.CurrentThread, out threadContext); } - + if(threadContext == null || threadContext.Count == 0) { ContextHelper.write(os, prxContext); @@ -398,9 +398,9 @@ namespace Ice // // map Thread -> Context // - private Dictionary<Thread, Dictionary<string, string> > _map = + private Dictionary<Thread, Dictionary<string, string> > _map = new Dictionary<Thread, Dictionary<string, string> >(); - } + } } diff --git a/csharp/src/Ice/Instance.cs b/csharp/src/Ice/Instance.cs index 423b24b96d2..63d3b232a70 100644 --- a/csharp/src/Ice/Instance.cs +++ b/csharp/src/Ice/Instance.cs @@ -937,6 +937,13 @@ namespace IceInternal ProtocolInstance udpInstance = new ProtocolInstance(this, Ice.UDPEndpointType.value, "udp", false); _endpointFactoryManager.add(new UdpEndpointFactory(udpInstance)); + + ProtocolInstance wsInstance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false); + _endpointFactoryManager.add(new WSEndpointFactory(wsInstance, Ice.TCPEndpointType.value)); + + ProtocolInstance wssInstance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true); + _endpointFactoryManager.add(new WSEndpointFactory(wssInstance, Ice.SSLEndpointType.value)); + _pluginManager = new Ice.PluginManagerI(communicator); if(_initData.valueFactoryManager == null) @@ -983,20 +990,10 @@ namespace IceInternal pluginManagerImpl.loadPlugins(ref args); // - // Add WS and WSS endpoint factories if TCP/SSL factories are installed. + // Initialize the endpoint factories once all the plugins are loaded. This gives + // the opportunity for the endpoint factories to find underyling factories. // - EndpointFactory tcpFactory = _endpointFactoryManager.get(Ice.TCPEndpointType.value); - if(tcpFactory != null) - { - ProtocolInstance instance = new ProtocolInstance(this, Ice.WSEndpointType.value, "ws", false); - _endpointFactoryManager.add(new WSEndpointFactory(instance, tcpFactory.clone(instance, null))); - } - EndpointFactory sslFactory = _endpointFactoryManager.get(Ice.SSLEndpointType.value); - if(sslFactory != null) - { - ProtocolInstance instance = new ProtocolInstance(this, Ice.WSSEndpointType.value, "wss", true); - _endpointFactoryManager.add(new WSEndpointFactory(instance, sslFactory.clone(instance, null))); - } + _endpointFactoryManager.initialize(); // // Create Admin facets, if enabled. diff --git a/csharp/src/Ice/LoggerAdminI.cs b/csharp/src/Ice/LoggerAdminI.cs index 04163f4fba8..05d3236473b 100644 --- a/csharp/src/Ice/LoggerAdminI.cs +++ b/csharp/src/Ice/LoggerAdminI.cs @@ -16,19 +16,19 @@ namespace IceInternal sealed class LoggerAdminI : Ice.LoggerAdminDisp_ { public override void - attachRemoteLogger(Ice.RemoteLoggerPrx prx, Ice.LogMessageType[] messageTypes, string[] categories, + attachRemoteLogger(Ice.RemoteLoggerPrx prx, Ice.LogMessageType[] messageTypes, string[] categories, int messageMax, Ice.Current current) { if(prx == null) { return; // can't send this null RemoteLogger anything! } - + Ice.RemoteLoggerPrx remoteLogger = Ice.RemoteLoggerPrxHelper.uncheckedCast(prx.ice_twoway()); - + Filters filters = new Filters(messageTypes, categories); LinkedList<Ice.LogMessage> initLogMessages = null; - + lock(this) { if(_sendLogCommunicator == null) @@ -38,12 +38,12 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ throw new Ice.ObjectNotExistException(); } - _sendLogCommunicator = + _sendLogCommunicator = createSendLogCommunicator(current.adapter.getCommunicator(), _logger.getLocalLogger()); } - + Ice.Identity remoteLoggerId = remoteLogger.ice_getIdentity(); - + if(_remoteLoggerMap.ContainsKey(remoteLoggerId)) { if(_traceLevel > 0) @@ -51,13 +51,13 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ _logger.trace(_traceCategory, "rejecting `" + remoteLogger.ToString() + "' with RemoteLoggerAlreadyAttachedException"); } - + throw new Ice.RemoteLoggerAlreadyAttachedException(); } - _remoteLoggerMap.Add(remoteLoggerId, + _remoteLoggerMap.Add(remoteLoggerId, new RemoteLoggerData(changeCommunicator(remoteLogger, _sendLogCommunicator), filters)); - + if(messageMax != 0) { initLogMessages = new LinkedList<Ice.LogMessage>(_queue); // copy @@ -67,7 +67,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ initLogMessages = new LinkedList<Ice.LogMessage>(); } } - + if(_traceLevel > 0) { _logger.trace(_traceCategory, "attached `" + remoteLogger.ToString() + "'"); @@ -77,7 +77,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ { filterLogMessages(initLogMessages, filters.messageTypes, filters.traceCategories, messageMax); } - + try { remoteLogger.initAsync(_logger.getPrefix(), initLogMessages.ToArray()).ContinueWith( @@ -103,9 +103,9 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ { deadRemoteLogger(remoteLogger, _logger, ex, "init"); throw; - } + } } - + public override bool detachRemoteLogger(Ice.RemoteLoggerPrx remoteLogger, Ice.Current current) { @@ -113,7 +113,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ { return false; } - + // // No need to convert the proxy as we only use its identity // @@ -133,9 +133,9 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ return found; } - - public override Ice.LogMessage[] - getLog(Ice.LogMessageType[] messageTypes, string[] categories, int messageMax, out string prefix, + + public override Ice.LogMessage[] + getLog(Ice.LogMessageType[] messageTypes, string[] categories, int messageMax, out string prefix, Ice.Current current) { LinkedList<Ice.LogMessage> logMessages = null; @@ -150,9 +150,9 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ logMessages = new LinkedList<Ice.LogMessage>(); } } - + prefix = _logger.getPrefix(); - + if(logMessages.Count > 0) { Filters filters = new Filters(messageTypes, categories); @@ -169,7 +169,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ _traceLevel = props.getPropertyAsInt("Ice.Trace.Admin.Logger"); _logger = logger; } - + internal void destroy() { Ice.Communicator sendLogCommunicator = null; @@ -183,9 +183,9 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ _sendLogCommunicator = null; } } - - // - // Destroy outside lock to avoid deadlock when there are outstanding two-way log calls sent to + + // + // Destroy outside lock to avoid deadlock when there are outstanding two-way log calls sent to // remote logggers // if(sendLogCommunicator != null) @@ -203,11 +203,11 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ // // Put message in _queue // - if((logMessage.type != Ice.LogMessageType.TraceMessage && _maxLogCount > 0) || + if((logMessage.type != Ice.LogMessageType.TraceMessage && _maxLogCount > 0) || (logMessage.type == Ice.LogMessageType.TraceMessage && _maxTraceCount > 0)) { _queue.AddLast(logMessage); - + if(logMessage.type != Ice.LogMessageType.TraceMessage) { Debug.Assert(_maxLogCount > 0); @@ -220,7 +220,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ var next = _oldestLog.Next; _queue.Remove(_oldestLog); _oldestLog = next; - + while(_oldestLog != null && _oldestLog.Value.type == Ice.LogMessageType.TraceMessage) { _oldestLog = _oldestLog.Next; @@ -249,7 +249,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ var next = _oldestTrace.Next; _queue.Remove(_oldestTrace); _oldestTrace = next; - + while(_oldestTrace != null && _oldestTrace.Value.type != Ice.LogMessageType.TraceMessage) { _oldestTrace = _oldestTrace.Next; @@ -267,18 +267,18 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ } } } - + // // Queue updated, now find which remote loggers want this message - // + // foreach(RemoteLoggerData p in _remoteLoggerMap.Values) { Filters filters = p.filters; - + if(filters.messageTypes.Count == 0 || filters.messageTypes.Contains(logMessage.type)) { if(logMessage.type != Ice.LogMessageType.TraceMessage || filters.traceCategories.Count == 0 || - filters.traceCategories.Contains(logMessage.traceCategory)) + filters.traceCategories.Contains(logMessage.traceCategory)) { if(remoteLoggers == null) { @@ -288,12 +288,12 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ } } } - + return remoteLoggers; } } - - internal void deadRemoteLogger(Ice.RemoteLoggerPrx remoteLogger, Ice.Logger logger, Ice.LocalException ex, + + internal void deadRemoteLogger(Ice.RemoteLoggerPrx remoteLogger, Ice.Logger logger, Ice.LocalException ex, string operation) { // @@ -303,31 +303,31 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ { if(_traceLevel > 0) { - logger.trace(_traceCategory, "detached `" + remoteLogger.ToString() + "' because " + logger.trace(_traceCategory, "detached `" + remoteLogger.ToString() + "' because " + operation + " raised:\n" + ex.ToString()); } } } - + internal int getTraceLevel() { return _traceLevel; } - + private bool removeRemoteLogger(Ice.RemoteLoggerPrx remoteLogger) { lock(this) { - return _remoteLoggerMap.Remove(remoteLogger.ice_getIdentity()); + return _remoteLoggerMap.Remove(remoteLogger.ice_getIdentity()); } } - + private static void filterLogMessages(LinkedList<Ice.LogMessage> logMessages, HashSet<Ice.LogMessageType> messageTypes, HashSet<string> traceCategories, int messageMax) { Debug.Assert(logMessages.Count > 0 && messageMax != 0); - + // // Filter only if one of the 3 filters is set; messageMax < 0 means "give me all" // that match the other filters, if any. @@ -348,7 +348,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ keepIt = true; } } - + if(keepIt) { ++count; @@ -415,7 +415,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ copyProperties("IceSSL.", mainProps, initData.properties); string[] extraProps = mainProps.getPropertyAsList("Ice.Admin.Logger.Properties"); - + if(extraProps.Length > 0) { for(int i = 0; i < extraProps.Length; ++i) @@ -431,7 +431,7 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ return Ice.Util.initialize(initData); } - + private readonly LinkedList<Ice.LogMessage> _queue = new LinkedList<Ice.LogMessage>(); private int _logCount = 0; // non-trace messages private readonly int _maxLogCount; @@ -466,9 +466,9 @@ sealed class LoggerAdminI : Ice.LoggerAdminDisp_ internal readonly Filters filters; } - private readonly Dictionary<Ice.Identity, RemoteLoggerData> _remoteLoggerMap - = new Dictionary<Ice.Identity, RemoteLoggerData>(); - + private readonly Dictionary<Ice.Identity, RemoteLoggerData> _remoteLoggerMap + = new Dictionary<Ice.Identity, RemoteLoggerData>(); + private readonly LoggerAdminLoggerI _logger; private Ice.Communicator _sendLogCommunicator = null; diff --git a/csharp/src/Ice/LoggerPlugin.cs b/csharp/src/Ice/LoggerPlugin.cs index 33aa8cba658..6f2583ae1a8 100644 --- a/csharp/src/Ice/LoggerPlugin.cs +++ b/csharp/src/Ice/LoggerPlugin.cs @@ -21,7 +21,7 @@ namespace Ice /// </summary> /// <param name="communicator">The communicator using the custom logger.</param> /// <param name="logger">The custom logger for the communicator.</param> - public + public LoggerPlugin(Communicator communicator, Logger logger) { if(communicator == null) @@ -30,14 +30,14 @@ namespace Ice ex.reason = "Communicator cannot be null"; throw ex; } - + if(logger == null) { PluginInitializationException ex = new PluginInitializationException(); ex.reason = "Logger cannot be null"; throw ex; } - + IceInternal.Instance instance = IceInternal.Util.getInstance(communicator); instance.setLogger(logger); } @@ -47,11 +47,11 @@ namespace Ice /// can override this method to perform any initialization that might be required /// by a custom logger. /// </summary> - public void + public void initialize() { } - + /// <summary> /// Called by the Ice run time when the communicator is destroyed. The derived class /// can override this method to perform any finalization that might be required diff --git a/csharp/src/Ice/MetricsAdminI.cs b/csharp/src/Ice/MetricsAdminI.cs index 53956277145..e5388bdb916 100644 --- a/csharp/src/Ice/MetricsAdminI.cs +++ b/csharp/src/Ice/MetricsAdminI.cs @@ -44,7 +44,7 @@ namespace IceInternal void update(); IMetricsMap create(string mapPrefix, Ice.Properties properties); } - + internal class SubMap<S> : ISubMap where S : IceMX.Metrics, new() { internal SubMap(MetricsMap<S> map, System.Reflection.FieldInfo field) @@ -57,7 +57,7 @@ namespace IceInternal { return _map.getMatching(helper, null); } - + public void addSubMapToMetrics(IceMX.Metrics metrics) { try @@ -69,7 +69,7 @@ namespace IceInternal Debug.Assert(false); } } - + readonly private MetricsMap<S> _map; readonly private System.Reflection.FieldInfo _field; } @@ -81,12 +81,12 @@ namespace IceInternal _map = map; _field = field; } - + public ISubMap create() { return new SubMap<S>(new MetricsMap<S>(_map), _field); } - + readonly private MetricsMap<S> _map; readonly private System.Reflection.FieldInfo _field; } @@ -97,7 +97,7 @@ namespace IceInternal { _field = field; } - + public ISubMapCloneFactory createCloneFactory(string subMapPrefix, Ice.Properties properties) { return new SubMapCloneFactory<S>(new MetricsMap<S>(subMapPrefix, properties, null), _field); @@ -208,7 +208,7 @@ namespace IceInternal { return _object.current == 0; } - + internal IceMX.Metrics clone() { T metrics = (T)_object.Clone(); @@ -237,7 +237,7 @@ namespace IceInternal { MetricsAdminI.validateProperties(mapPrefix, props); _properties = props.getPropertiesForPrefix(mapPrefix); - + _retain = props.getPropertyAsIntWithDefault(mapPrefix + "RetainDetached", 10); _accept = parseRule(props, mapPrefix + "Accept"); _reject = parseRule(props, mapPrefix + "Reject"); @@ -253,7 +253,7 @@ namespace IceInternal { _groupByAttributes.Add(""); } - + foreach(char p in groupBy) { bool isAlphaNum = char.IsLetter(p) || char.IsDigit(p) || p == '.'; @@ -274,7 +274,7 @@ namespace IceInternal v += p; } } - + if(attribute) { _groupByAttributes.Add(v); @@ -315,7 +315,7 @@ namespace IceInternal _subMaps = null; } } - + internal MetricsMap(MetricsMap<T> map) { _properties = map._properties; @@ -345,7 +345,7 @@ namespace IceInternal return metrics; } } - + public IceMX.MetricsFailures[] getFailures() { lock(this) @@ -362,7 +362,7 @@ namespace IceInternal return failures.ToArray(); } } - + public IceMX.MetricsFailures getFailures(string id) { lock(this) @@ -402,7 +402,7 @@ namespace IceInternal return null; } } - + foreach(KeyValuePair<string, Regex> e in _reject) { if(match(e.Key, e.Value, helper, true)) @@ -440,10 +440,10 @@ namespace IceInternal { return null; } - + // // Lookup the metrics object. - // + // lock(this) { if(previous != null && previous.getId().Equals(key)) @@ -451,7 +451,7 @@ namespace IceInternal Debug.Assert(_objects[key] == previous); return previous; } - + Entry e; if(!_objects.TryGetValue(key, out e)) { @@ -471,7 +471,7 @@ namespace IceInternal return e; } } - + private void detached(Entry entry) { if(_retain == 0) @@ -484,7 +484,7 @@ namespace IceInternal _detachedQueue = new LinkedList<Entry>(); } Debug.Assert(_detachedQueue.Count <= _retain); - + // Compress the queue by removing entries which are no longer detached. LinkedListNode<Entry> p = _detachedQueue.First; while(p != null) @@ -496,18 +496,18 @@ namespace IceInternal } p = next; } - + // If there's still no room, remove the oldest entry (at the front). if(_detachedQueue.Count == _retain) { _objects.Remove(_detachedQueue.First.Value.getId()); _detachedQueue.RemoveFirst(); } - + // Add the entry at the back of the queue. _detachedQueue.AddLast(entry); } - + private Dictionary<string, Regex> parseRule(Ice.Properties properties, string name) { Dictionary<string, Regex> pats = new Dictionary<string, Regex>(); @@ -552,7 +552,7 @@ namespace IceInternal _name = name; } - internal bool addOrUpdateMap(Ice.Properties properties, string mapName, IMetricsMapFactory factory, + internal bool addOrUpdateMap(Ice.Properties properties, string mapName, IMetricsMapFactory factory, Ice.Logger logger) { // @@ -561,7 +561,7 @@ namespace IceInternal string viewPrefix = "IceMX.Metrics." + _name + "."; string mapsPrefix = viewPrefix + "Map."; Dictionary<string, string> mapsProps = properties.getPropertiesForPrefix(mapsPrefix); - + string mapPrefix; Dictionary<string, string> mapProps = new Dictionary<string, string>(); if(mapsProps.Count > 0) @@ -585,14 +585,14 @@ namespace IceInternal // This map is disabled for this view. return _maps.Remove(mapName); } - + IMetricsMap m; - if(_maps.TryGetValue(mapName, out m) && + if(_maps.TryGetValue(mapName, out m) && IceUtilInternal.Collections.DictionaryEquals(m.getProperties(), mapProps)) { return false; // The map configuration didn't change, no need to re-create. } - + try { _maps[mapName] = factory.create(mapPrefix, properties); @@ -604,7 +604,7 @@ namespace IceInternal } return true; } - + internal bool removeMap(string mapName) { return _maps.Remove(mapName); @@ -648,7 +648,7 @@ namespace IceInternal { return _maps.Keys; } - + internal MetricsMap<T> getMap<T>(string mapName) where T : IceMX.Metrics, new() { IMetricsMap m; @@ -658,7 +658,7 @@ namespace IceInternal } return null; } - + readonly private string _name; readonly private Dictionary<string, IMetricsMap> _maps = new Dictionary<string, IMetricsMap>(); } @@ -696,7 +696,7 @@ namespace IceInternal unknownProps.Add(prop); } } - + if(unknownProps.Count != 0 && properties.getPropertyAsIntWithDefault("Ice.Warn.UnknownProperties", 1) > 0) { StringBuilder message = new StringBuilder("found unknown IceMX properties for `"); @@ -729,7 +729,7 @@ namespace IceInternal return new MetricsMap<T>(mapPrefix, properties, _subMaps); } - public void registerSubMap<S>(string subMap, System.Reflection.FieldInfo field) + public void registerSubMap<S>(string subMap, System.Reflection.FieldInfo field) where S : IceMX.Metrics, new() { _subMaps.Add(subMap, new SubMapFactory<S>(field)); @@ -763,20 +763,20 @@ namespace IceInternal { viewName = viewName.Substring(0, dotPos); } - + if(views.ContainsKey(viewName) || _disabledViews.Contains(viewName)) { continue; // View already configured. } - + validateProperties(viewsPrefix + viewName + ".", _properties); - + if(_properties.getPropertyAsIntWithDefault(viewsPrefix + viewName + ".Disabled", 0) > 0) { _disabledViews.Add(viewName); continue; // The view is disabled } - + // // Create the view or update it. // @@ -799,7 +799,7 @@ namespace IceInternal Dictionary<string, MetricsViewI> tmp = _views; _views = views; views = tmp; - + // // Go through removed views to collect maps to update. // @@ -814,7 +814,7 @@ namespace IceInternal } } } - + // // Call the updaters to update the maps. // @@ -853,7 +853,7 @@ namespace IceInternal updateViews(); } - override public Dictionary<string, IceMX.Metrics[]> getMetricsView(string viewName, out long timestamp, + override public Dictionary<string, IceMX.Metrics[]> getMetricsView(string viewName, out long timestamp, Ice.Current current) { lock(this) @@ -881,7 +881,7 @@ namespace IceInternal } } - override public IceMX.MetricsFailures getMetricsFailures(string viewName, string mapName, string id, + override public IceMX.MetricsFailures getMetricsFailures(string viewName, string mapName, string id, Ice.Current c) { lock(this) @@ -912,7 +912,7 @@ namespace IceInternal } } - public void registerSubMap<S>(string map, string subMap, System.Reflection.FieldInfo field) + public void registerSubMap<S>(string map, string subMap, System.Reflection.FieldInfo field) where S : IceMX.Metrics, new() { bool updated; @@ -972,7 +972,7 @@ namespace IceInternal } public void updated(Dictionary<string, string> props) - { + { foreach(KeyValuePair<string, string> e in props) { if(e.Key.IndexOf("IceMX.") == 0) @@ -984,7 +984,7 @@ namespace IceInternal } catch(Exception ex) { - _logger.warning("unexpected exception while updating metrics view configuration:\n" + + _logger.warning("unexpected exception while updating metrics view configuration:\n" + ex.ToString()); } return; @@ -1005,7 +1005,7 @@ namespace IceInternal } return view; } - + private bool addOrUpdateMap(string mapName, IMetricsMapFactory factory) { bool updated = false; @@ -1028,7 +1028,7 @@ namespace IceInternal private Ice.Properties _properties; readonly private Ice.Logger _logger; - readonly private Dictionary<string, IMetricsMapFactory> _factories = + readonly private Dictionary<string, IMetricsMapFactory> _factories = new Dictionary<string, IMetricsMapFactory>(); private Dictionary<string, MetricsViewI> _views = new Dictionary<string, MetricsViewI>(); private List<string> _disabledViews = new List<string>(); diff --git a/csharp/src/Ice/ObserverHelper.cs b/csharp/src/Ice/ObserverHelper.cs index 5ca670606c7..2d85c15a5f8 100644 --- a/csharp/src/Ice/ObserverHelper.cs +++ b/csharp/src/Ice/ObserverHelper.cs @@ -36,7 +36,7 @@ namespace IceInternal static public InvocationObserver get(Ice.ObjectPrx proxy, string op, Dictionary<string, string> context) { - CommunicatorObserver obsv = + CommunicatorObserver obsv = ((Ice.ObjectPrxHelperBase)proxy).iceReference().getInstance().initializationData().observer; if(obsv != null) { diff --git a/csharp/src/Ice/Options.cs b/csharp/src/Ice/Options.cs index 0b4b42b18e6..2b3208e665f 100644 --- a/csharp/src/Ice/Options.cs +++ b/csharp/src/Ice/Options.cs @@ -24,12 +24,12 @@ namespace IceUtilInternal } enum State { Normal, DoubleQuote, SingleQuote, ANSIQuote }; - + static public string[] split(string line) { string IFS = " \t\n"; - + string l = line.Trim(); if(l.Length == 0) { @@ -40,7 +40,7 @@ namespace IceUtilInternal string arg = ""; List<string> vec = new List<string>(); - + for(int i = 0; i < l.Length; ++i) { char c = l[i]; @@ -116,7 +116,7 @@ namespace IceUtilInternal { vec.Add(arg); arg = ""; - + // // Move to start of next argument. // @@ -317,9 +317,9 @@ namespace IceUtilInternal // case 'c': { - c = l[++i]; - if((char.ToUpper(c, CultureInfo.InvariantCulture) >= 'A' && char.ToUpper(c, CultureInfo.InvariantCulture) <= 'Z') || - c == '@' || + c = l[++i]; + if((char.ToUpper(c, CultureInfo.InvariantCulture) >= 'A' && char.ToUpper(c, CultureInfo.InvariantCulture) <= 'Z') || + c == '@' || (c >= '[' && c <= '_')) { arg += (char)(char.ToUpper(c, CultureInfo.InvariantCulture) - '@'); @@ -374,7 +374,7 @@ namespace IceUtilInternal } } } - + switch(state) { case State.Normal: @@ -400,7 +400,7 @@ namespace IceUtilInternal break; } } - + return vec.ToArray(); } } diff --git a/csharp/src/Ice/OutputBase.cs b/csharp/src/Ice/OutputBase.cs index 5e5b2ac926b..147be419a10 100644 --- a/csharp/src/Ice/OutputBase.cs +++ b/csharp/src/Ice/OutputBase.cs @@ -27,7 +27,7 @@ public class OutputBase indentSave_ = new Stack<int>(); separator_ = true; } - + public OutputBase(TextWriter writer) { @@ -39,7 +39,7 @@ public class OutputBase indentSave_ = new Stack<int>(); separator_ = true; } - + public OutputBase(string s) { @@ -57,13 +57,13 @@ public class OutputBase { indentSize_ = indentSize; } - + virtual public void setUseTab(bool useTab) { useTab_ = useTab; - } - + } + public virtual void open(string s) { @@ -75,7 +75,7 @@ public class OutputBase { } } - + public virtual void print(string s) { @@ -90,53 +90,53 @@ public class OutputBase { } } - + out_.Write(s); } - + public virtual void inc() { indent_ += indentSize_; } - + public virtual void dec() { Debug.Assert(indent_ >= indentSize_); indent_ -= indentSize_; } - + public virtual void useCurrentPosAsIndent() { indentSave_.Push(indent_); indent_ = pos_; } - + public virtual void zeroIndent() { indentSave_.Push(indent_); indent_ = 0; } - + public virtual void restoreIndent() { Debug.Assert(indentSave_.Count != 0); indent_ = (int)indentSave_.Pop(); } - + public virtual void nl() { out_.WriteLine(); pos_ = 0; separator_ = true; - + int indent = indent_; - + if(useTab_) { while(indent >= 8) @@ -155,17 +155,17 @@ public class OutputBase pos_ += indentSize_; } } - + while(indent > 0) { --indent; out_.Write(" "); ++pos_; } - + out_.Flush(); } - + public virtual void sp() { @@ -174,13 +174,13 @@ public class OutputBase out_.WriteLine(); } } - + public virtual bool valid() { return out_ != null; } - + protected internal TextWriter out_; protected internal int pos_; protected internal int indent_; diff --git a/csharp/src/Ice/ProcessI.cs b/csharp/src/Ice/ProcessI.cs index 1cd4e744f11..18e30d7c079 100644 --- a/csharp/src/Ice/ProcessI.cs +++ b/csharp/src/Ice/ProcessI.cs @@ -20,7 +20,7 @@ namespace IceInternal { _communicator.shutdown(); } - + public override void writeMessage(string message, int fd, Ice.Current current) { switch(fd) @@ -36,8 +36,8 @@ namespace IceInternal break; } } - } - + } + private Ice.Communicator _communicator; } } diff --git a/csharp/src/Ice/PropertiesI.cs b/csharp/src/Ice/PropertiesI.cs index 7d8c9569ffd..eee1f52925e 100644 --- a/csharp/src/Ice/PropertiesI.cs +++ b/csharp/src/Ice/PropertiesI.cs @@ -51,7 +51,7 @@ namespace Ice return result; } } - + public string getPropertyWithDefault(string key, string val) { lock(this) @@ -66,12 +66,12 @@ namespace Ice return result; } } - + public int getPropertyAsInt(string key) { return getPropertyAsIntWithDefault(key, 0); } - + public int getPropertyAsIntWithDefault(string key, int val) { lock(this) @@ -79,7 +79,7 @@ namespace Ice PropertyValue pv; if(!_properties.TryGetValue(key, out pv)) { - return val; + return val; } pv.used = true; try @@ -88,18 +88,18 @@ namespace Ice } catch(FormatException) { - Util.getProcessLogger().warning("numeric property " + key + + Util.getProcessLogger().warning("numeric property " + key + " set to non-numeric value, defaulting to " + val); return val; } } } - + public string[] getPropertyAsList(string key) { return getPropertyAsListWithDefault(key, null); } - + public string[] getPropertyAsListWithDefault(string key, string[] val) { if(val == null) @@ -120,7 +120,7 @@ namespace Ice string[] result = IceUtilInternal.StringUtil.splitString(pv.val, ", \t\r\n"); if(result == null) { - Util.getProcessLogger().warning("mismatched quotes in property " + key + Util.getProcessLogger().warning("mismatched quotes in property " + key + "'s value, returning default value"); return val; } @@ -150,7 +150,7 @@ namespace Ice return result; } } - + public void setProperty(string key, string val) { // @@ -252,7 +252,7 @@ namespace Ice } } } - + public string[] getCommandLineOptions() { lock(this) @@ -300,7 +300,7 @@ namespace Ice } return arr; } - + public string[] parseIceCommandLineOptions(string[] options) { string[] args = options; @@ -310,7 +310,7 @@ namespace Ice } return args; } - + public void load(string file) { if(file.StartsWith("HKLM\\", StringComparison.Ordinal)) @@ -349,7 +349,7 @@ namespace Ice } } } - + public Properties ice_clone_() { lock(this) @@ -357,7 +357,7 @@ namespace Ice return new PropertiesI(this); } } - + public List<string> getUnusedProperties() { lock(this) @@ -373,7 +373,7 @@ namespace Ice return unused; } } - + internal PropertiesI(PropertiesI p) { // @@ -392,7 +392,7 @@ namespace Ice { _properties = new Dictionary<string, PropertyValue>(); } - + internal PropertiesI(ref string[] args, Properties defaults) { if(defaults == null) @@ -412,7 +412,7 @@ namespace Ice _properties[entry.Key] = new PropertyValue(entry.Value); } } - + PropertyValue pv; if(_properties.TryGetValue("Ice.ProgramName", out pv)) { @@ -454,15 +454,15 @@ namespace Ice // loadConfigFiles = !_properties.ContainsKey("Ice.Config"); } - + if(loadConfigFiles) { loadConfig(); } - - args = parseIceCommandLineOptions(args); + + args = parseIceCommandLineOptions(args); } - + private void parse(System.IO.StreamReader input) { try @@ -482,7 +482,7 @@ namespace Ice private const int ParseStateKey = 0; private const int ParseStateValue = 1; - + private void parseLine(string line) { string key = ""; @@ -515,14 +515,14 @@ namespace Ice whitespace= ""; key += c; break; - + case ' ': if(key.Length != 0) { whitespace += c; } break; - + default: key += whitespace; whitespace= ""; @@ -537,7 +537,7 @@ namespace Ice key += c; } break; - + case ' ': case '\t': case '\r': @@ -547,16 +547,16 @@ namespace Ice whitespace += c; } break; - + case '=': whitespace= ""; state = ParseStateValue; break; - + case '#': finished = true; break; - + default: key += whitespace; whitespace= ""; @@ -584,12 +584,12 @@ namespace Ice escapedspace= ""; val += c; break; - + case ' ': whitespace += c; escapedspace += c; break; - + default: val += val.Length == 0 ? escapedspace : whitespace; whitespace= ""; @@ -605,7 +605,7 @@ namespace Ice val += c; } break; - + case ' ': case '\t': case '\r': @@ -615,11 +615,11 @@ namespace Ice whitespace += c; } break; - + case '#': finished = true; break; - + default: val += val.Length == 0 ? escapedspace : whitespace; whitespace = ""; @@ -636,7 +636,7 @@ namespace Ice } } val += escapedspace; - + if((state == ParseStateKey && key.Length != 0) || (state == ParseStateValue && key.Length == 0)) { Util.getProcessLogger().warning("invalid config file entry: \"" + line + "\""); @@ -649,7 +649,7 @@ namespace Ice setProperty(key, val); } - + private void loadConfig() { string val = getProperty("Ice.Config"); @@ -670,10 +670,10 @@ namespace Ice { load(files[i].Trim()); } - + _properties["Ice.Config"] = new PropertyValue(val, true); } - } + } private Dictionary<string, PropertyValue> _properties; } diff --git a/csharp/src/Ice/Protocol.cs b/csharp/src/Ice/Protocol.cs index 651079964ce..36e462aab31 100644 --- a/csharp/src/Ice/Protocol.cs +++ b/csharp/src/Ice/Protocol.cs @@ -24,12 +24,12 @@ namespace IceInternal // Message size (Int) // internal const int headerSize = 14; - + // // The magic number at the front of each message // internal static readonly byte[] magic = new byte[] { 0x49, 0x63, 0x65, 0x50 }; // 'I', 'c', 'e', 'P' - + // // The current Ice protocol and encoding version // @@ -50,7 +50,7 @@ namespace IceInternal public const byte FLAG_HAS_INDIRECTION_TABLE = (1<<3); public const byte FLAG_HAS_SLICE_SIZE = (1<<4); public const byte FLAG_IS_LAST_SLICE = (1<<5); - + // // The Ice protocol message types // @@ -81,7 +81,7 @@ namespace IceInternal 0, 0, 0, 0, // Message size (placeholder). 0, 0, 0, 0 // Number of requests in batch (placeholder). }; - + internal static readonly byte[] replyHdr = new byte[] { magic[0], magic[1], magic[2], magic[3], @@ -118,7 +118,7 @@ namespace IceInternal throw new Ice.UnsupportedEncodingException("", v, Ice.Util.currentEncoding); } } - + // // Either return the given protocol if not compatible, or the greatest // supported protocol otherwise. @@ -140,7 +140,7 @@ namespace IceInternal // Unsupported but compatible, use the currently supported // protocol, that's the best we can do. // - return Ice.Util.currentProtocol; + return Ice.Util.currentProtocol; } } @@ -165,7 +165,7 @@ namespace IceInternal // Unsupported but compatible, use the currently supported // encoding, that's the best we can do. // - return Ice.Util.currentEncoding; + return Ice.Util.currentEncoding; } } @@ -180,7 +180,7 @@ namespace IceInternal { return version.major == supported.major && version.minor <= supported.minor; } - + private Protocol() { } diff --git a/csharp/src/Ice/ProtocolInstance.cs b/csharp/src/Ice/ProtocolInstance.cs index 6cd500e44f1..83b843eefbc 100644 --- a/csharp/src/Ice/ProtocolInstance.cs +++ b/csharp/src/Ice/ProtocolInstance.cs @@ -52,6 +52,11 @@ namespace IceInternal return logger_; } + public EndpointFactory getEndpointFactory(short type) + { + return instance_.endpointFactoryManager().get(type); + } + public string protocol() { return protocol_; diff --git a/csharp/src/Ice/Proxy.cs b/csharp/src/Ice/Proxy.cs index cd304fd4299..5ebeb1f6a9d 100644 --- a/csharp/src/Ice/Proxy.cs +++ b/csharp/src/Ice/Proxy.cs @@ -770,6 +770,13 @@ namespace Ice /// <param name="os">Output stream object to write the proxy.</param> [EditorBrowsable(EditorBrowsableState.Never)] void iceWrite(OutputStream os); + + + /// <summary> + /// Returns an scheduler object that use the Ice thread pool. + /// </summary> + /// <returns>The task scheduler object.</returns> + System.Threading.Tasks.TaskScheduler ice_scheduler(); } /// <summary> @@ -2352,6 +2359,11 @@ namespace Ice resultI.wait(); } + public System.Threading.Tasks.TaskScheduler ice_scheduler() + { + return _reference.getThreadPool(); + } + /// <summary> /// Returns whether this proxy equals the passed object. Two proxies are equal if they are equal in all /// respects, that is, if their object identity, endpoints timeout settings, and so on are all equal. diff --git a/csharp/src/Ice/Reference.cs b/csharp/src/Ice/Reference.cs index 80b985544db..a27d37b2958 100644 --- a/csharp/src/Ice/Reference.cs +++ b/csharp/src/Ice/Reference.cs @@ -93,6 +93,7 @@ namespace IceInternal public abstract Ice.EndpointSelectionType getEndpointSelection(); public abstract int getLocatorCacheTimeout(); public abstract string getConnectionId(); + public abstract ThreadPool getThreadPool(); // // The change* methods (here and in derived classes) create @@ -606,6 +607,11 @@ namespace IceInternal return ""; } + public override ThreadPool getThreadPool() + { + return _fixedConnection.getThreadPool(); + } + public override Reference changeEndpoints(EndpointI[] newEndpoints) { throw new Ice.FixedProxyException(); @@ -828,6 +834,11 @@ namespace IceInternal return _connectionId; } + public override ThreadPool getThreadPool() + { + return getInstance().clientThreadPool(); + } + public override Reference changeEncoding(Ice.EncodingVersion newEncoding) { RoutableReference r = (RoutableReference)base.changeEncoding(newEncoding); diff --git a/csharp/src/Ice/TcpEndpointI.cs b/csharp/src/Ice/TcpEndpointI.cs index 0f0e7d628ac..9d6f7c6b6af 100644 --- a/csharp/src/Ice/TcpEndpointI.cs +++ b/csharp/src/Ice/TcpEndpointI.cs @@ -299,6 +299,10 @@ namespace IceInternal _instance = instance; } + public void initialize() + { + } + public short type() { return _instance.type(); @@ -326,7 +330,7 @@ namespace IceInternal _instance = null; } - public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) + public EndpointFactory clone(ProtocolInstance instance) { return new TcpEndpointFactory(instance); } diff --git a/csharp/src/Ice/ThreadPool.cs b/csharp/src/Ice/ThreadPool.cs index 226a0f9a04a..0f3cdfcfcad 100644 --- a/csharp/src/Ice/ThreadPool.cs +++ b/csharp/src/Ice/ThreadPool.cs @@ -154,7 +154,7 @@ namespace IceInternal internal readonly EventHandler _handler; } - public sealed class ThreadPool + public sealed class ThreadPool : System.Threading.Tasks.TaskScheduler { public ThreadPool(Instance instance, string prefix, int timeout) { @@ -486,6 +486,26 @@ namespace IceInternal return _serialize; } + protected sealed override void QueueTask(System.Threading.Tasks.Task task) + { + dispatch(() => { TryExecuteTask(task); }, null, false); + } + + protected sealed override bool TryExecuteTaskInline(System.Threading.Tasks.Task task, bool taskWasPreviouslyQueued) + { + return false; + } + + protected sealed override bool TryDequeue(System.Threading.Tasks.Task task) + { + return false; + } + + protected sealed override IEnumerable<System.Threading.Tasks.Task> GetScheduledTasks() + { + return new System.Threading.Tasks.Task[0]; + } + private void run(WorkerThread thread) { ThreadPoolWorkItem workItem = null; diff --git a/csharp/src/Ice/Timer.cs b/csharp/src/Ice/Timer.cs index cfa61c912b6..e2c84f5cd36 100644 --- a/csharp/src/Ice/Timer.cs +++ b/csharp/src/Ice/Timer.cs @@ -12,7 +12,7 @@ // the C++ & Java timers and it's not clear what is the cost of // scheduling and cancelling timers. // - + namespace IceInternal { using System.Diagnostics; @@ -37,7 +37,7 @@ namespace IceInternal _instance = null; Monitor.Pulse(this); - + _tokens.Clear(); _tasks.Clear(); } @@ -65,7 +65,7 @@ namespace IceInternal { Debug.Assert(false); } - + if(token.scheduledTime < _wakeUpTime) { Monitor.Pulse(this); @@ -99,8 +99,8 @@ namespace IceInternal Monitor.Pulse(this); } } - } - + } + public bool cancel(TimerTask task) { lock(this) @@ -154,7 +154,7 @@ namespace IceInternal lock(this) { Debug.Assert(obsv != null); - _observer = obsv.getThreadObserver("Communicator", + _observer = obsv.getThreadObserver("Communicator", _thread.Name, Ice.Instrumentation.ThreadState.ThreadStateIdle, _observer); @@ -199,12 +199,12 @@ namespace IceInternal _wakeUpTime = long.MaxValue; Monitor.Wait(this); } - + if(_instance == null) { break; } - + while(_tokens.Count > 0 && _instance != null) { long now = Time.currentMonotonicTimeMillis(); @@ -227,11 +227,11 @@ namespace IceInternal } break; } - + _wakeUpTime = first.scheduledTime; Monitor.Wait(this, (int)(first.scheduledTime - now)); } - + if(_instance == null) { break; @@ -272,7 +272,7 @@ namespace IceInternal _instance.initializationData().logger.error(s); } } - } + } } } } @@ -311,7 +311,7 @@ namespace IceInternal { return 1; } - + return 0; } @@ -350,7 +350,7 @@ namespace IceInternal // We use a volatile to avoid synchronization when reading // _observer. Reference assignement is atomic in Java so it // also doesn't need to be synchronized. - // + // private volatile Ice.Instrumentation.ThreadObserver _observer; } diff --git a/csharp/src/Ice/TraceLevels.cs b/csharp/src/Ice/TraceLevels.cs index b9f488ec4e0..9922e6d0ae8 100644 --- a/csharp/src/Ice/TraceLevels.cs +++ b/csharp/src/Ice/TraceLevels.cs @@ -19,9 +19,9 @@ namespace IceInternal locationCat = "Locator"; slicingCat = "Slicing"; threadPoolCat = "ThreadPool"; - + string keyBase = "Ice.Trace."; - + network = properties.getPropertyAsInt(keyBase + networkCat); protocol = properties.getPropertyAsInt(keyBase + protocolCat); retry = properties.getPropertyAsInt(keyBase + retryCat); @@ -29,7 +29,7 @@ namespace IceInternal slicing = properties.getPropertyAsInt(keyBase + slicingCat); threadPool = properties.getPropertyAsInt(keyBase + threadPoolCat); } - + public readonly int network; public readonly string networkCat; public readonly int protocol; diff --git a/csharp/src/Ice/UdpEndpointI.cs b/csharp/src/Ice/UdpEndpointI.cs index 45a9adcf6e6..45dd6199f14 100644 --- a/csharp/src/Ice/UdpEndpointI.cs +++ b/csharp/src/Ice/UdpEndpointI.cs @@ -436,6 +436,10 @@ namespace IceInternal _instance = instance; } + public void initialize() + { + } + public short type() { return _instance.type(); @@ -463,7 +467,7 @@ namespace IceInternal _instance = null; } - public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) + public EndpointFactory clone(ProtocolInstance instance) { return new UdpEndpointFactory(instance); } diff --git a/csharp/src/Ice/Value.cs b/csharp/src/Ice/Value.cs index 5d81d87df71..d6f459b5c66 100644 --- a/csharp/src/Ice/Value.cs +++ b/csharp/src/Ice/Value.cs @@ -115,5 +115,5 @@ namespace Ice } private string _id; - } + } } diff --git a/csharp/src/Ice/ValueWriter.cs b/csharp/src/Ice/ValueWriter.cs index 936a68c5d3f..97e78859ac6 100644 --- a/csharp/src/Ice/ValueWriter.cs +++ b/csharp/src/Ice/ValueWriter.cs @@ -21,7 +21,7 @@ namespace IceInternal { writeValue(null, obj, null, output); } - + private static void writeValue(string name, object val, Dictionary<Ice.Object, object> objectTable, OutputBase output) { if(val == null) @@ -95,10 +95,10 @@ namespace IceInternal else if(c.IsEnum) { writeName(name, output); - output.print(val.ToString()); + output.print(val.ToString()); } else - { + { // // Must be struct. // @@ -106,7 +106,7 @@ namespace IceInternal } } } - + private static void writeFields(string name, object obj, System.Type c, Dictionary<Ice.Object, object> objectTable, OutputBase output) { @@ -116,17 +116,17 @@ namespace IceInternal // Write the superclass first. // writeFields(name, obj, c.BaseType, objectTable, output); - + // // Write the declared fields of the given class. // - FieldInfo[] fields = + FieldInfo[] fields = c.GetFields(BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Public); for(int i = 0; i < fields.Length; i++) { string fieldName = (name != null ? name + '.' + fields[i].Name : fields[i].Name); - + try { object val = fields[i].GetValue(obj); @@ -139,7 +139,7 @@ namespace IceInternal } } } - + private static void writeName(string name, OutputBase output) { if(name != null) diff --git a/csharp/src/Ice/WSEndpoint.cs b/csharp/src/Ice/WSEndpoint.cs index 2749388f585..ef6df9486e8 100644 --- a/csharp/src/Ice/WSEndpoint.cs +++ b/csharp/src/Ice/WSEndpoint.cs @@ -342,46 +342,25 @@ namespace IceInternal private string _resource; } - public class WSEndpointFactory : EndpointFactory + public class WSEndpointFactory : EndpointFactoryWithUnderlying { - public WSEndpointFactory(ProtocolInstance instance, EndpointFactory del) + public WSEndpointFactory(ProtocolInstance instance, short type) : base(instance, type) { - _instance = instance; - _delegate = del; } - public short type() + override public EndpointFactory cloneWithUnderlying(ProtocolInstance instance, short underlying) { - return _instance.type(); + return new WSEndpointFactory(instance, underlying); } - public string protocol() + override protected EndpointI createWithUnderlying(EndpointI underlying, List<string> args, bool oaEndpoint) { - return _instance.protocol(); + return new WSEndpoint(instance_, underlying, args); } - public EndpointI create(List<string> args, bool oaEndpoint) + override protected EndpointI readWithUnderlying(EndpointI underlying, Ice.InputStream s) { - return new WSEndpoint(_instance, _delegate.create(args, oaEndpoint), args); + return new WSEndpoint(instance_, underlying, s); } - - public EndpointI read(Ice.InputStream s) - { - return new WSEndpoint(_instance, _delegate.read(s), s); - } - - public void destroy() - { - _delegate.destroy(); - _instance = null; - } - - public EndpointFactory clone(ProtocolInstance instance, EndpointFactory del) - { - return new WSEndpointFactory(instance, del); - } - - private ProtocolInstance _instance; - private EndpointFactory _delegate; } } diff --git a/csharp/src/IceBox/AssemblyInfo.cs b/csharp/src/IceBox/AssemblyInfo.cs index 3aacc4981a3..142c2b65e15 100644 --- a/csharp/src/IceBox/AssemblyInfo.cs +++ b/csharp/src/IceBox/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceBox/AssemblyInfoExe.cs b/csharp/src/IceBox/AssemblyInfoExe.cs index 11e2f9fddac..e62edf3e544 100644 --- a/csharp/src/IceBox/AssemblyInfoExe.cs +++ b/csharp/src/IceBox/AssemblyInfoExe.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceDiscovery/AssemblyInfo.cs b/csharp/src/IceDiscovery/AssemblyInfo.cs index ad89c454121..13135137377 100644 --- a/csharp/src/IceDiscovery/AssemblyInfo.cs +++ b/csharp/src/IceDiscovery/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceGrid/AssemblyInfo.cs b/csharp/src/IceGrid/AssemblyInfo.cs index 107aced514f..55e24aeab2f 100644 --- a/csharp/src/IceGrid/AssemblyInfo.cs +++ b/csharp/src/IceGrid/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceLocatorDiscovery/AssemblyInfo.cs b/csharp/src/IceLocatorDiscovery/AssemblyInfo.cs index 2de6cd29732..e4975b83209 100644 --- a/csharp/src/IceLocatorDiscovery/AssemblyInfo.cs +++ b/csharp/src/IceLocatorDiscovery/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IcePatch2/AssemblyInfo.cs b/csharp/src/IcePatch2/AssemblyInfo.cs index 43957783d63..611d9c424f3 100644 --- a/csharp/src/IcePatch2/AssemblyInfo.cs +++ b/csharp/src/IcePatch2/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceSSL/AssemblyInfo.cs b/csharp/src/IceSSL/AssemblyInfo.cs index a42f060a653..6df8db4d82b 100644 --- a/csharp/src/IceSSL/AssemblyInfo.cs +++ b/csharp/src/IceSSL/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] diff --git a/csharp/src/IceSSL/EndpointI.cs b/csharp/src/IceSSL/EndpointI.cs index 13028f96428..3ed47be71e0 100644 --- a/csharp/src/IceSSL/EndpointI.cs +++ b/csharp/src/IceSSL/EndpointI.cs @@ -267,48 +267,31 @@ namespace IceSSL private IceInternal.EndpointI _delegate; } - internal sealed class EndpointFactoryI : IceInternal.EndpointFactory + internal sealed class EndpointFactoryI : IceInternal.EndpointFactoryWithUnderlying { - internal EndpointFactoryI(Instance instance, IceInternal.EndpointFactory del) + public EndpointFactoryI(Instance instance, short type) : base(instance, type) { _instance = instance; - _delegate = del; - } - - public short type() - { - return _delegate.type(); - } - - public string protocol() - { - return _delegate.protocol(); - } - - public IceInternal.EndpointI create(List<string> args, bool oaEndpoint) - { - return new EndpointI(_instance, _delegate.create(args, oaEndpoint)); } - public IceInternal.EndpointI read(Ice.InputStream s) + override public IceInternal.EndpointFactory + cloneWithUnderlying(IceInternal.ProtocolInstance inst, short underlying) { - return new EndpointI(_instance, _delegate.read(s)); + return new EndpointFactoryI(new Instance(_instance.engine(), inst.type(), inst.protocol()), underlying); } - public void destroy() + override protected IceInternal.EndpointI + createWithUnderlying(IceInternal.EndpointI underlying, List<string> args, bool oaEndpoint) { - _delegate.destroy(); - _instance = null; + return new EndpointI(_instance, underlying); } - public IceInternal.EndpointFactory clone(IceInternal.ProtocolInstance inst, - IceInternal.EndpointFactory del) + override protected IceInternal.EndpointI + readWithUnderlying(IceInternal.EndpointI underlying, Ice.InputStream s) { - Instance instance = new Instance(_instance.engine(), inst.type(), inst.protocol()); - return new EndpointFactoryI(instance, del != null ? del : _delegate.clone(instance, null)); + return new EndpointI(_instance, underlying); } private Instance _instance; - private IceInternal.EndpointFactory _delegate; } } diff --git a/csharp/src/IceSSL/Plugin.cs b/csharp/src/IceSSL/Plugin.cs index 63647d31a63..f104a6268ba 100644 --- a/csharp/src/IceSSL/Plugin.cs +++ b/csharp/src/IceSSL/Plugin.cs @@ -56,13 +56,13 @@ namespace IceSSL abstract public void initialize(); /// <summary> - /// Specify the certificate authorities certificates to use + /// Specify the certificate authorities certificates to use /// when validating SSL peer certificates. This must be done - /// before the plug-in is initialized; therefore, the application - /// must define the property Ice.InitPlugins=0, set the certificates, + /// before the plug-in is initialized; therefore, the application + /// must define the property Ice.InitPlugins=0, set the certificates, /// and finally invoke initializePlugins on the PluginManager. - /// When the application supplies its own certificate authorities - /// certificates, the plug-in skips its normal property-based + /// When the application supplies its own certificate authorities + /// certificates, the plug-in skips its normal property-based /// configuration. /// </summary> /// <param name="certs">The certificate authorities certificates to use.</param> diff --git a/csharp/src/IceSSL/PluginI.cs b/csharp/src/IceSSL/PluginI.cs index f4d205e4c83..fba2919ae38 100644 --- a/csharp/src/IceSSL/PluginI.cs +++ b/csharp/src/IceSSL/PluginI.cs @@ -43,12 +43,8 @@ namespace IceSSL // // SSL based on TCP // - IceInternal.EndpointFactory tcp = facade.getEndpointFactory(Ice.TCPEndpointType.value); - if(tcp != null) - { - Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl"); - facade.addEndpointFactory(new EndpointFactoryI(instance, tcp.clone(instance, null))); - } + Instance instance = new Instance(_engine, Ice.SSLEndpointType.value, "ssl"); + facade.addEndpointFactory(new EndpointFactoryI(instance, Ice.TCPEndpointType.value)); } public override void initialize() diff --git a/csharp/src/IceSSL/SSLEngine.cs b/csharp/src/IceSSL/SSLEngine.cs index 4b7288808bc..119e5f97b8c 100644 --- a/csharp/src/IceSSL/SSLEngine.cs +++ b/csharp/src/IceSSL/SSLEngine.cs @@ -479,7 +479,7 @@ namespace IceSSL internal void verifyPeer(string address, IceSSL.ConnectionInfo info, string desc) { - + if(_verifyDepthMax > 0 && info.certs != null && info.certs.Length > _verifyDepthMax) { diff --git a/csharp/src/IceSSL/Util.cs b/csharp/src/IceSSL/Util.cs index 30ca194b8e2..cf6d8212f9f 100644 --- a/csharp/src/IceSSL/Util.cs +++ b/csharp/src/IceSSL/Util.cs @@ -17,13 +17,7 @@ namespace IceSSL { public static X509Certificate2 createCertificate(string certPEM) { - char[] chars = certPEM.ToCharArray(); - byte[] bytes = new byte[chars.Length]; - for(int i = 0; i < chars.Length; ++i) - { - bytes[i] = (byte)chars[i]; - } - return new X509Certificate2(bytes); + return new X509Certificate2(System.Text.Encoding.ASCII.GetBytes(certPEM)); } } } diff --git a/csharp/src/IceStorm/AssemblyInfo.cs b/csharp/src/IceStorm/AssemblyInfo.cs index 93bf0ed5d81..5fc287db0fb 100644 --- a/csharp/src/IceStorm/AssemblyInfo.cs +++ b/csharp/src/IceStorm/AssemblyInfo.cs @@ -20,7 +20,7 @@ using System.Runtime.InteropServices; [assembly: AssemblyConfiguration("")] [assembly: AssemblyProduct("Ice")] [assembly: AssemblyCopyright("© 2003-2016 ZeroC, Inc.")] -[assembly: AssemblyCulture("")] +[assembly: AssemblyCulture("")] [assembly: AssemblyVersion("3.7.60")] [assembly: AssemblyDelaySign(false)] |