Imported Upstream version 5.2.0.175

Former-commit-id: bb0468d0f257ff100aa895eb5fe583fb5dfbf900
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2017-06-07 13:16:24 +00:00
parent 4bdbaf4a88
commit 966bba02bb
8776 changed files with 346420 additions and 149650 deletions

View File

@ -709,11 +709,11 @@ namespace System.Net.Sockets
sockares.Complete (acc_socket, total);
});
public Socket EndAccept (IAsyncResult result)
public Socket EndAccept (IAsyncResult asyncResult)
{
int bytes;
byte[] buffer;
return EndAccept (out buffer, out bytes, result);
return EndAccept (out buffer, out bytes, asyncResult);
}
public Socket EndAccept (out byte[] buffer, out int bytesTransferred, IAsyncResult asyncResult)
@ -947,7 +947,7 @@ namespace System.Net.Sockets
}
});
public IAsyncResult BeginConnect (string host, int port, AsyncCallback callback, object state)
public IAsyncResult BeginConnect (string host, int port, AsyncCallback requestCallback, object state)
{
ThrowIfDisposedAndClosed ();
@ -960,31 +960,31 @@ namespace System.Net.Sockets
if (is_listening)
throw new InvalidOperationException ();
return BeginConnect (Dns.GetHostAddresses (host), port, callback, state);
return BeginConnect (Dns.GetHostAddresses (host), port, requestCallback, state);
}
public IAsyncResult BeginConnect (EndPoint end_point, AsyncCallback callback, object state)
public IAsyncResult BeginConnect (EndPoint remoteEP, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
if (end_point == null)
throw new ArgumentNullException ("end_point");
if (remoteEP == null)
throw new ArgumentNullException ("remoteEP");
if (is_listening)
throw new InvalidOperationException ();
SocketAsyncResult sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
EndPoint = end_point,
EndPoint = remoteEP,
};
// Bug #75154: Connect() should not succeed for .Any addresses.
if (end_point is IPEndPoint) {
IPEndPoint ep = (IPEndPoint) end_point;
if (remoteEP is IPEndPoint) {
IPEndPoint ep = (IPEndPoint) remoteEP;
if (ep.Address.Equals (IPAddress.Any) || ep.Address.Equals (IPAddress.IPv6Any)) {
sockares.Complete (new SocketException ((int) SocketError.AddressNotAvailable), true);
return sockares;
}
sockares.EndPoint = end_point = RemapIPEndPoint (ep);
sockares.EndPoint = remoteEP = RemapIPEndPoint (ep);
}
int error = 0;
@ -1003,7 +1003,7 @@ namespace System.Net.Sockets
bool blk = is_blocking;
if (blk)
Blocking = false;
Connect_internal (m_Handle, end_point.Serialize (), out error, false);
Connect_internal (m_Handle, remoteEP.Serialize (), out error, false);
if (blk)
Blocking = true;
@ -1033,7 +1033,7 @@ namespace System.Net.Sockets
return sockares;
}
public IAsyncResult BeginConnect (IPAddress[] addresses, int port, AsyncCallback callback, object state)
public IAsyncResult BeginConnect (IPAddress[] addresses, int port, AsyncCallback requestCallback, object state)
{
ThrowIfDisposedAndClosed ();
@ -1048,7 +1048,7 @@ namespace System.Net.Sockets
if (is_listening)
throw new InvalidOperationException ();
SocketAsyncResult sockares = new SocketAsyncResult (this, callback, state, SocketOperation.Connect) {
SocketAsyncResult sockares = new SocketAsyncResult (this, requestCallback, state, SocketOperation.Connect) {
Addresses = addresses,
Port = port,
};
@ -1141,11 +1141,11 @@ namespace System.Net.Sockets
}
});
public void EndConnect (IAsyncResult result)
public void EndConnect (IAsyncResult asyncResult)
{
ThrowIfDisposedAndClosed ();
SocketAsyncResult sockares = ValidateEndIAsyncResult (result, "EndConnect", "result");
SocketAsyncResult sockares = ValidateEndIAsyncResult (asyncResult, "EndConnect", "asyncResult");
if (!sockares.IsCompleted)
sockares.AsyncWaitHandle.WaitOne();
@ -1628,21 +1628,21 @@ namespace System.Net.Sockets
}
});
public IAsyncResult BeginReceiveFrom (byte[] buffer, int offset, int size, SocketFlags socket_flags, ref EndPoint remote_end, AsyncCallback callback, object state)
public IAsyncResult BeginReceiveFrom (byte[] buffer, int offset, int size, SocketFlags socketFlags, ref EndPoint remoteEP, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
ThrowIfBufferNull (buffer);
ThrowIfBufferOutOfRange (buffer, offset, size);
if (remote_end == null)
throw new ArgumentNullException ("remote_end");
if (remoteEP == null)
throw new ArgumentNullException ("remoteEP");
SocketAsyncResult sockares = new SocketAsyncResult (this, callback, state, SocketOperation.ReceiveFrom) {
Buffer = buffer,
Offset = offset,
Size = size,
SockFlags = socket_flags,
EndPoint = remote_end,
SockFlags = socketFlags,
EndPoint = remoteEP,
};
QueueIOSelectorJob (ReadSem, sockares.Handle, new IOSelectorJob (IOOperation.Read, BeginReceiveFromCallback, sockares));
@ -1670,21 +1670,21 @@ namespace System.Net.Sockets
sockares.Complete (total);
});
public int EndReceiveFrom(IAsyncResult result, ref EndPoint end_point)
public int EndReceiveFrom(IAsyncResult asyncResult, ref EndPoint endPoint)
{
ThrowIfDisposedAndClosed ();
if (end_point == null)
throw new ArgumentNullException ("remote_end");
if (endPoint == null)
throw new ArgumentNullException ("endPoint");
SocketAsyncResult sockares = ValidateEndIAsyncResult (result, "EndReceiveFrom", "result");
SocketAsyncResult sockares = ValidateEndIAsyncResult (asyncResult, "EndReceiveFrom", "asyncResult");
if (!sockares.IsCompleted)
sockares.AsyncWaitHandle.WaitOne();
sockares.CheckIfThrowDelayedException();
end_point = sockares.EndPoint;
endPoint = sockares.EndPoint;
return sockares.Total;
}
@ -2094,7 +2094,7 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
}
});
public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, SocketFlags socket_flags, EndPoint remote_end, AsyncCallback callback, object state)
public IAsyncResult BeginSendTo(byte[] buffer, int offset, int size, SocketFlags socketFlags, EndPoint remoteEP, AsyncCallback callback, object state)
{
ThrowIfDisposedAndClosed ();
ThrowIfBufferNull (buffer);
@ -2104,8 +2104,8 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
Buffer = buffer,
Offset = offset,
Size = size,
SockFlags = socket_flags,
EndPoint = remote_end,
SockFlags = socketFlags,
EndPoint = remoteEP,
};
QueueIOSelectorJob (WriteSem, sockares.Handle, new IOSelectorJob (IOOperation.Write, s => BeginSendToCallback ((SocketAsyncResult) s, 0), sockares));
@ -2139,11 +2139,11 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
sockares.Complete ();
}
public int EndSendTo (IAsyncResult result)
public int EndSendTo (IAsyncResult asyncResult)
{
ThrowIfDisposedAndClosed ();
SocketAsyncResult sockares = ValidateEndIAsyncResult (result, "EndSendTo", "result");
SocketAsyncResult sockares = ValidateEndIAsyncResult (asyncResult, "EndSendTo", "result");
if (!sockares.IsCompleted)
sockares.AsyncWaitHandle.WaitOne();
@ -2680,14 +2680,25 @@ m_Handle, buffer, offset + sent, size - sent, socketFlags, out nativeError, is_b
void QueueIOSelectorJob (SemaphoreSlim sem, IntPtr handle, IOSelectorJob job)
{
sem.WaitAsync ().ContinueWith (t => {
var task = sem.WaitAsync();
// fast path without Task<Action> allocation.
if (task.IsCompleted) {
if (CleanedUp) {
job.MarkDisposed ();
return;
}
IOSelector.Add (handle, job);
});
}
else
{
task.ContinueWith( t => {
if (CleanedUp) {
job.MarkDisposed ();
return;
}
IOSelector.Add(handle, job);
});
}
}
void InitSocketAsyncEventArgs (SocketAsyncEventArgs e, AsyncCallback callback, object state, SocketOperation operation)