Imported Upstream version 5.8.0.22

Former-commit-id: df344e34b07851d296efb3e6604c8db42b6f7aa3
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-10-19 20:04:20 +00:00
parent 5f4a27cc8a
commit 7d05485754
5020 changed files with 114082 additions and 186061 deletions

View File

@@ -87,15 +87,15 @@ namespace System.ServiceModel.Channels.Http
{
// HTTP channel could be accepted while there is no incoming request yet. The reply channel waits for the actual request.
// HTTP channel listeners do not accept more than one channel at a time.
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
TimeSpan waitTimeout;
if (timeout == TimeSpan.MaxValue)
waitTimeout = TimeSpan.FromMilliseconds(int.MaxValue);
else
waitTimeout = timeout - (DateTime.Now - start);
waitTimeout = timeout - (DateTime.UtcNow - start);
accept_channel_handle.WaitOne (waitTimeout);
accept_channel_handle.Reset ();
TChannel ch = CreateChannel (timeout - (DateTime.Now - start));
TChannel ch = CreateChannel (timeout - (DateTime.UtcNow - start));
ch.Closed += delegate {
accept_channel_handle.Set ();
};

View File

@@ -94,7 +94,7 @@ namespace System.ServiceModel.Channels.Http
public bool TryDequeueRequest (ChannelDispatcher channel, TimeSpan timeout, out HttpContextInfo context)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
context = null;
HttpChannelListenerEntry ce = null;
@@ -111,7 +111,7 @@ namespace System.ServiceModel.Channels.Http
if (timeout == TimeSpan.MaxValue)
waitTimeout = TimeSpan.FromMilliseconds (int.MaxValue);
bool ret = ce.WaitHandle.WaitOne (waitTimeout);
return ret && TryDequeueRequest (channel, waitTimeout - (DateTime.Now - start), out context); // recurse, am lazy :/
return ret && TryDequeueRequest (channel, waitTimeout - (DateTime.UtcNow - start), out context); // recurse, am lazy :/
}
context = q.Dequeue ();
return true;

View File

@@ -113,12 +113,12 @@ namespace System.ServiceModel.Channels.Http
return;
close_started = true;
}
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// FIXME: consider timeout
AbortConnections (timeout - (DateTime.Now - start));
AbortConnections (timeout - (DateTime.UtcNow - start));
base.OnClose (timeout - (DateTime.Now - start));
base.OnClose (timeout - (DateTime.UtcNow - start));
}
protected string GetHeaderItem (string raw)

View File

@@ -221,7 +221,7 @@ namespace System.ServiceModel.Channels
{
ThrowIfDisposedOrNotOpen ();
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// FIXME: give max buffer size
var mb = message.CreateBufferedCopy (0x10000);
@@ -234,14 +234,14 @@ namespace System.ServiceModel.Channels
pc.Status = RemotePeerStatus.Error; // prepare for cases that it resulted in an error in the middle.
var inner = CreateInnerClient (pc);
pc.Channel = inner;
inner.Open (timeout - (DateTime.Now - start));
inner.OperationTimeout = timeout - (DateTime.Now - start);
inner.Open (timeout - (DateTime.UtcNow - start));
inner.OperationTimeout = timeout - (DateTime.UtcNow - start);
inner.Connect (new ConnectInfo () { Address = local_node_address, NodeId = (uint) node.NodeId });
pc.Instance.WaitForConnectResponse (timeout - (DateTime.Now - start));
pc.Instance.WaitForConnectResponse (timeout - (DateTime.UtcNow - start));
pc.Status = RemotePeerStatus.Connected;
}
pc.Channel.OperationTimeout = timeout - (DateTime.Now - start);
pc.Channel.OperationTimeout = timeout - (DateTime.UtcNow - start);
// see [MC-PRCH] 3.2.4.1
if (message.Headers.MessageId == null)
@@ -265,7 +265,6 @@ namespace System.ServiceModel.Channels
public override bool TryReceive (TimeSpan timeout, out Message message)
{
ThrowIfDisposedOrNotOpen ();
DateTime start = DateTime.Now;
if (queue.Count > 0 || receive_handle.WaitOne (timeout)) {
message = queue.Dequeue ();
@@ -296,21 +295,21 @@ namespace System.ServiceModel.Channels
protected override void OnClose (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
if (client_factory != null)
client_factory.Close (timeout - (DateTime.Now - start));
client_factory.Close (timeout - (DateTime.UtcNow - start));
peers.Clear ();
resolver.Unregister (node.RegisteredId, timeout - (DateTime.Now - start));
resolver.Unregister (node.RegisteredId, timeout - (DateTime.UtcNow - start));
node.SetOffline ();
if (listener_host != null)
listener_host.Close (timeout - (DateTime.Now - start));
listener_host.Close (timeout - (DateTime.UtcNow - start));
node.RegisteredId = null;
}
protected override void OnOpen (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// FIXME: supply maxAddresses
foreach (var a in resolver.Resolve (node.MeshId, 3, timeout))
@@ -323,7 +322,7 @@ namespace System.ServiceModel.Channels
int port = 0;
var rnd = new Random ();
for (int i = 0; i < 1000; i++) {
if (DateTime.Now - start > timeout)
if (DateTime.UtcNow - start > timeout)
throw new TimeoutException ();
try {
port = rnd.Next (50000, 51000);
@@ -351,13 +350,13 @@ namespace System.ServiceModel.Channels
// FIXME: remove debugging code
listener_host.UnknownMessageReceived += delegate (object obj, UnknownMessageReceivedEventArgs earg) { Console.WriteLine ("%%%%% UNKOWN MESSAGE " + earg.Message); };
listener_host.Open (timeout - (DateTime.Now - start));
listener_host.Open (timeout - (DateTime.UtcNow - start));
var nid = (ulong) new Random ().Next (0, int.MaxValue);
var ea = new EndpointAddress (uri);
var pna = new PeerNodeAddress (ea, new ReadOnlyCollection<IPAddress> (Dns.GetHostEntry (name).AddressList));
local_node_address = pna;
node.RegisteredId = resolver.Register (node.MeshId, pna, timeout - (DateTime.Now - start));
node.RegisteredId = resolver.Register (node.MeshId, pna, timeout - (DateTime.UtcNow - start));
node.NodeId = nid;
// Add itself to the local list as well.

View File

@@ -73,7 +73,7 @@ namespace System.ServiceModel.Channels.NetTcp
protected override TChannel OnAcceptChannel (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// Close channels that are incorrectly kept open first.
var l = new List<TcpDuplexSessionChannel> ();
@@ -83,9 +83,9 @@ namespace System.ServiceModel.Channels.NetTcp
l.Add (dch);
}
foreach (var dch in l)
dch.Close (timeout - (DateTime.Now - start));
dch.Close (timeout - (DateTime.UtcNow - start));
TcpClient client = AcceptTcpClient (timeout - (DateTime.Now - start));
TcpClient client = AcceptTcpClient (timeout - (DateTime.UtcNow - start));
if (client == null)
return null; // onclose
@@ -109,7 +109,7 @@ namespace System.ServiceModel.Channels.NetTcp
// TcpReplyChannel requires refreshed connection after each request processing.
internal TcpClient AcceptTcpClient (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
TcpClient client = accepted_clients.Count == 0 ? null : accepted_clients.Dequeue ();
if (client == null) {
@@ -121,7 +121,7 @@ namespace System.ServiceModel.Channels.NetTcp
}
accept_handles.Remove (wait);
// recurse with new timeout, or return null if it's either being closed or timed out.
timeout -= (DateTime.Now - start);
timeout -= (DateTime.UtcNow - start);
return State == CommunicationState.Opened && timeout > TimeSpan.Zero ? AcceptTcpClient (timeout) : null;
}
@@ -132,7 +132,7 @@ namespace System.ServiceModel.Channels.NetTcp
continue;
if (((IPEndPoint) dch.TcpClient.Client.RemoteEndPoint).Equals (client.Client.RemoteEndPoint))
// ... then it should be handled in another BeginTryReceive/EndTryReceive loop in ChannelDispatcher.
return AcceptTcpClient (timeout - (DateTime.Now - start));
return AcceptTcpClient (timeout - (DateTime.UtcNow - start));
}
return client;

View File

@@ -187,12 +187,12 @@ namespace System.ServiceModel.Channels.NetTcp
if (client.Available > 0)
return true;
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
do {
Thread.Sleep (50);
if (client.Available > 0)
return true;
} while (DateTime.Now - start < timeout);
} while (DateTime.UtcNow - start < timeout);
return false;
}

View File

@@ -58,8 +58,6 @@ namespace System.ServiceModel.Channels.NetTcp
if (timeout <= TimeSpan.Zero)
throw new ArgumentException (String.Format ("Timeout value must be positive value. It was {0}", timeout));
DateTime start = DateTime.Now;
// FIXME: use timeout
if (client == null)
client = ((TcpChannelListener<IReplyChannel>) Manager).AcceptTcpClient (timeout);
@@ -110,7 +108,6 @@ namespace System.ServiceModel.Channels.NetTcp
{
Logger.LogMessage (MessageLogSourceKind.TransportSend, ref message, owner.info.BindingElement.MaxReceivedMessageSize);
DateTime start = DateTime.Now;
owner.frame.WriteUnsizedMessage (message, timeout);
// FIXME: consider timeout here too.
owner.frame.WriteEndRecord ();
@@ -120,7 +117,6 @@ namespace System.ServiceModel.Channels.NetTcp
public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
{
try {
DateTime start = DateTime.Now;
context = ReceiveRequest (timeout);
return context != null;
} catch (Exception ex) {

View File

@@ -82,7 +82,7 @@ namespace System.ServiceModel.Channels.NetTcp
public override Message Request (Message input, TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// FIXME: use timeouts.
frame.ProcessPreambleInitiator ();
@@ -95,13 +95,13 @@ namespace System.ServiceModel.Channels.NetTcp
Logger.LogMessage (MessageLogSourceKind.TransportSend, ref input, int.MaxValue); // It is not a receive buffer
frame.WriteUnsizedMessage (input, timeout - (DateTime.Now - start));
frame.WriteUnsizedMessage (input, timeout - (DateTime.UtcNow - start));
// LAMESPEC: it contradicts the protocol described at section 3.1.1.1.1 in [MC-NMF].
// Moving this WriteEndRecord() after ReadUnsizedMessage() causes TCP connection blocking.
frame.WriteEndRecord ();
var ret = frame.ReadUnsizedMessage (timeout - (DateTime.Now - start));
var ret = frame.ReadUnsizedMessage (timeout - (DateTime.UtcNow - start));
Logger.LogMessage (MessageLogSourceKind.TransportReceive, ref ret, info.BindingElement.MaxReceivedMessageSize);

View File

@@ -77,7 +77,7 @@ namespace System.ServiceModel.Channels.Security
public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
if (!inner.TryReceiveRequest (timeout, out context))
return false;
@@ -95,14 +95,14 @@ namespace System.ServiceModel.Channels.Security
var support = Source.SecuritySupport;
var commAuth = support.TokenAuthenticator as CommunicationSecurityTokenAuthenticator;
if (commAuth != null)
res = commAuth.Communication.ProcessNegotiation (req, timeout - (DateTime.Now - start));
res = commAuth.Communication.ProcessNegotiation (req, timeout - (DateTime.UtcNow - start));
else
throw new MessageSecurityException ("This reply channel does not expect incoming WS-Trust requests");
context.Reply (res, timeout - (DateTime.Now - start));
context.Close (timeout - (DateTime.Now - start));
context.Reply (res, timeout - (DateTime.UtcNow - start));
context.Close (timeout - (DateTime.UtcNow - start));
// wait for another incoming message
return TryReceiveRequest (timeout - (DateTime.Now - start), out context);
return TryReceiveRequest (timeout - (DateTime.UtcNow - start), out context);
break;
}

View File

@@ -132,11 +132,11 @@ namespace System.ServiceModel.Channels
protected override void OnClose (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
// this implicitly premises: TChannel is IChannel
foreach (IChannel ch in channels)
ch.Close (timeout - (DateTime.Now - start));
base.OnClose (timeout - (DateTime.Now - start));
ch.Close (timeout - (DateTime.UtcNow - start));
base.OnClose (timeout - (DateTime.UtcNow - start));
}
protected override IAsyncResult OnBeginClose (TimeSpan timeout, AsyncCallback callback, object state)

View File

@@ -69,7 +69,6 @@ namespace System.ServiceModel.Channels
{
Console.WriteLine ("NamedPipeChannelListener.OnAcceptChannel");
DateTime start = DateTime.Now;
if (active_server != null) {
try {
server_release_handle.WaitOne (timeout);

View File

@@ -95,7 +95,6 @@ namespace System.ServiceModel.Channels
if (message.Headers.RelatesTo == null)
message.Headers.RelatesTo = request.Headers.MessageId;
DateTime start = DateTime.Now;
owner.frame.WriteUnsizedMessage (message, timeout);
owner.frame.WriteEndRecord ();
owner.server.Close ();
@@ -106,7 +105,6 @@ namespace System.ServiceModel.Channels
public override bool TryReceiveRequest (TimeSpan timeout, out RequestContext context)
{
try {
DateTime start = DateTime.Now;
context = ReceiveRequest (timeout);
return context != null;
} catch (TimeoutException) {
@@ -126,8 +124,6 @@ namespace System.ServiceModel.Channels
protected override void OnOpen (TimeSpan timeout)
{
DateTime start = DateTime.Now;
// FIXME: use timeout
frame = new TcpBinaryFrameManager (TcpBinaryFrameManager.SingletonUnsizedMode, server, true) { Encoder = this.Encoder };
frame.ProcessPreambleRecipient ();

View File

@@ -78,7 +78,7 @@ namespace System.ServiceModel.Channels
public override Message Request (Message input, TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
CreateClient (timeout);
@@ -87,11 +87,11 @@ namespace System.ServiceModel.Channels
if (input.Headers.MessageId == null)
input.Headers.MessageId = new UniqueId ();
frame.WriteUnsizedMessage (input, timeout - (DateTime.Now - start));
frame.WriteUnsizedMessage (input, timeout - (DateTime.UtcNow - start));
frame.WriteEndRecord ();
var ret = frame.ReadUnsizedMessage (timeout - (DateTime.Now - start));
var ret = frame.ReadUnsizedMessage (timeout - (DateTime.UtcNow - start));
frame.ReadEndRecord ();
return ret;
}

View File

@@ -70,11 +70,11 @@ namespace System.ServiceModel.Channels
protected override TChannel OnAcceptChannel (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
if (channel != null)
if (!accept_handle.WaitOne (timeout))
throw new TimeoutException ();
channel = PopulateChannel (timeout - (DateTime.Now - start));
channel = PopulateChannel (timeout - (DateTime.UtcNow - start));
((CommunicationObject) (object) channel).Closed += delegate {
this.channel = null;
accept_handle.Set ();

View File

@@ -68,9 +68,8 @@ namespace System.ServiceModel.Description
get { return behaviors; }
}
[MonoTODO]
public KeyedCollection<Type,IEndpointBehavior> EndpointBehaviors {
get { throw new NotImplementedException (); }
get { return behaviors; }
}
public ContractDescription Contract {

View File

@@ -414,7 +414,7 @@ namespace System.ServiceModel.Dispatcher
if (loop_thread == null)
return;
close_started = DateTime.Now;
close_started = DateTime.UtcNow;
close_timeout = timeout;
loop = false;
creator_handle.Set ();
@@ -467,7 +467,7 @@ namespace System.ServiceModel.Dispatcher
}
else {
try {
ch.Close (close_timeout - (DateTime.Now - close_started));
ch.Close (close_timeout - (DateTime.UtcNow - close_started));
} catch (Exception ex) {
// FIXME: log it.
Logger.Error (String.Format ("Exception on closing channel ({0})", ch.GetType ()), ex);

View File

@@ -45,11 +45,16 @@ namespace System.ServiceModel.PeerResolvers
public class CustomPeerResolverService : IPeerResolverContract
{
static ServiceHost localhost;
static int port;
static void SetupCustomPeerResolverServiceHost ()
{
string customPort = Environment.GetEnvironmentVariable ("MONO_CUSTOMPEERRESOLVERSERVICE_PORT");
if (customPort == null || !int.TryParse (customPort, out port))
port = 8931;
// launch peer resolver service locally only when it does not seem to be running ...
var t = new TcpListener (8931);
var t = new TcpListener (port);
try {
t.Start ();
t.Stop ();
@@ -59,7 +64,7 @@ namespace System.ServiceModel.PeerResolvers
Console.WriteLine ("WARNING: it is running peer resolver service locally. This means, the node registration is valid only within this application domain...");
var host = new ServiceHost (new LocalPeerResolverService (TextWriter.Null));
host.Description.Behaviors.Find<ServiceBehaviorAttribute> ().InstanceContextMode = InstanceContextMode.Single;
host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), "http://localhost:8931");
host.AddServiceEndpoint (typeof (ICustomPeerResolverContract), new BasicHttpBinding (), $"http://localhost:{port}");
localhost = host;
host.Open ();
}
@@ -70,7 +75,7 @@ namespace System.ServiceModel.PeerResolvers
public CustomPeerResolverService ()
{
client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ("http://localhost:8931"));
client = ChannelFactory<ICustomPeerResolverClient>.CreateChannel (new BasicHttpBinding (), new EndpointAddress ($"http://localhost:{port}"));
refresh_interval = new TimeSpan (0, 10, 0);
cleanup_interval = new TimeSpan (0, 1, 0);

View File

@@ -95,7 +95,7 @@ namespace System.ServiceModel.PeerResolvers
if (node == null)
return new RefreshResponseInfo () { Result = RefreshResult.RegistrationNotFound };
node.Refresh ();
return new RefreshResponseInfo () { Result = RefreshResult.Success, RegistrationLifetime = RefreshInterval - (DateTime.Now - node.LastRefreshTime) };
return new RefreshResponseInfo () { Result = RefreshResult.Success, RegistrationLifetime = RefreshInterval - (DateTime.UtcNow - node.LastRefreshTime) };
}
public RegisterResponseInfo Register (RegisterInfo registerInfo)
@@ -163,7 +163,7 @@ namespace System.ServiceModel.PeerResolvers
lock (mesh) {
var node = new Node () { ClientId = clientId, Address = addr };
mesh.Add (node);
node.LastRefreshTime = DateTime.Now;
node.LastRefreshTime = DateTime.UtcNow;
return node;
}
}
@@ -201,13 +201,13 @@ namespace System.ServiceModel.PeerResolvers
public void Refresh ()
{
LastRefreshTime = DateTime.Now;
LastRefreshTime = DateTime.UtcNow;
}
public void Update (PeerNodeAddress addr)
{
Address = addr;
LastRefreshTime = DateTime.Now;
LastRefreshTime = DateTime.UtcNow;
}
}
}

View File

@@ -383,7 +383,6 @@ namespace System.ServiceModel.MonoInternal
protected override void OnClose (TimeSpan timeout)
{
DateTime start = DateTime.Now;
if (channel.State == CommunicationState.Opened)
channel.Close (timeout);
}
@@ -593,9 +592,9 @@ namespace System.ServiceModel.MonoInternal
// FIXME: implement ConcurrencyMode check:
// if it is .Single && this instance for a callback channel && the operation is invoked inside service operation, then error.
DateTime startTime = DateTime.Now;
DateTime startTime = DateTime.UtcNow;
OutputChannel.Send (msg, timeout);
return ((IDuplexChannel) channel).Receive (timeout - (DateTime.Now - startTime));
return ((IDuplexChannel) channel).Receive (timeout - (DateTime.UtcNow - startTime));
}
internal IAsyncResult BeginRequest (Message msg, TimeSpan timeout, AsyncCallback callback, object state)

View File

@@ -115,12 +115,12 @@ namespace System.ServiceModel.MonoInternal
protected override void OnClose (TimeSpan timeout)
{
DateTime start = DateTime.Now;
DateTime start = DateTime.UtcNow;
base.OnClose (timeout);
loop = false;
if (!loop_handle.WaitOne (timeout - (DateTime.Now - start)))
if (!loop_handle.WaitOne (timeout - (DateTime.UtcNow - start)))
throw new TimeoutException ();
if (!finish_handle.WaitOne (timeout - (DateTime.Now - start)))
if (!finish_handle.WaitOne (timeout - (DateTime.UtcNow - start)))
throw new TimeoutException ();
}
@@ -204,7 +204,7 @@ namespace System.ServiceModel.MonoInternal
internal override Message RequestCorrelated (Message msg, TimeSpan timeout, IOutputChannel channel)
{
DateTime startTime = DateTime.Now;
DateTime startTime = DateTime.UtcNow;
Message ret = null;
ManualResetEvent wait = new ManualResetEvent (false);
Action<Message> handler = delegate (Message reply) {
@@ -213,7 +213,7 @@ namespace System.ServiceModel.MonoInternal
};
ReplyHandlerQueue.Enqueue (handler);
channel.Send (msg, timeout);
if (ret == null && !wait.WaitOne (timeout - (DateTime.Now - startTime)))
if (ret == null && !wait.WaitOne (timeout - (DateTime.UtcNow - startTime)))
throw new TimeoutException ();
return ret;
}

Some files were not shown because too many files have changed in this diff Show More