Imported Upstream version 3.12.0

Former-commit-id: cf92446697332992ec36726e78eb8703e1f259d7
This commit is contained in:
Jo Shields
2015-01-13 10:44:36 +00:00
parent 8b9b85e7f5
commit 181b81b4a4
659 changed files with 12743 additions and 16300 deletions

View File

@@ -24,14 +24,10 @@ TEST_MCS_FLAGS = -r:System.Drawing.dll -r:Mono.Security.dll -r:System.Data -r:Sy
LIB_MCS_FLAGS = -nowarn:618 -d:CONFIGURATION_2_0 -unsafe $(RESOURCE_FILES:%=-resource:%)
TEST_MCS_FLAGS += -r:System.Configuration
PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac, $(PROFILE))
NOT_SL := $(filter net_2_0 net_4_0 net_4_5 monotouch_runtime mobile xammac, $(PROFILE))
PROFILE_ANY_MOBILE := $(filter monotouch monotouch_runtime monodroid xammac mobile mobile_static, $(PROFILE))
ifeq (2.1, $(FRAMEWORK_VERSION))
LIB_MCS_FLAGS += -d:INSIDE_SYSTEM
ifeq (moonlight_raw, $(PROFILE))
LIB_MCS_FLAGS += -d:SECURITY_DEP
endif
endif
ifeq (monotouch, $(subst _runtime,,$(PROFILE)))
LIB_MCS_FLAGS += -d:SECURITY_DEP
@@ -154,4 +150,4 @@ csproj-local:
$(MAKE) csproj-local intermediate=bare/
$(MAKE) csproj-local intermediate=secxml/
endif
endif
endif

View File

@@ -124,8 +124,12 @@ namespace System.Collections.Concurrent
int cachedRemoveId = removeId;
int itemsIn = cachedAddId - cachedRemoveId;
// Check our transaction id against completed stored one
if (isComplete.Value && cachedAddId >= completeId)
ThrowCompleteException ();
// If needed, we check and wait that the collection isn't full
if (upperBound != -1 && itemsIn > upperBound) {
if (upperBound != -1 && itemsIn >= upperBound) {
if (millisecondsTimeout == 0)
return false;
@@ -144,10 +148,6 @@ namespace System.Collections.Concurrent
continue;
}
// Check our transaction id against completed stored one
if (isComplete.Value && cachedAddId >= completeId)
ThrowCompleteException ();
// Validate the steps we have been doing until now
if (Interlocked.CompareExchange (ref addId, cachedAddId + 1, cachedAddId) != cachedAddId)
continue;
@@ -291,30 +291,28 @@ namespace System.Collections.Concurrent
public static int AddToAny (BlockingCollection<T>[] collections, T item)
{
CheckArray (collections);
int index = 0;
foreach (var coll in collections) {
try {
coll.Add (item);
return index;
} catch {}
index++;
}
return -1;
return AddToAny (collections, item, CancellationToken.None);
}
public static int AddToAny (BlockingCollection<T>[] collections, T item, CancellationToken cancellationToken)
{
CheckArray (collections);
int index = 0;
foreach (var coll in collections) {
try {
coll.Add (item, cancellationToken);
return index;
} catch {}
index++;
WaitHandle[] wait_table = null;
while (true) {
for (int i = 0; i < collections.Length; ++i) {
if (collections [i].TryAdd (item))
return i;
}
cancellationToken.ThrowIfCancellationRequested ();
if (wait_table == null) {
wait_table = new WaitHandle [collections.Length + 1];
for (int i = 0; i < collections.Length; ++i)
wait_table [i] = collections [i].mreAdd.WaitHandle;
wait_table [collections.Length] = cancellationToken.WaitHandle;
}
WaitHandle.WaitAny (wait_table);
cancellationToken.ThrowIfCancellationRequested ();
}
return -1;
}
public static int TryAddToAny (BlockingCollection<T>[] collections, T item)
@@ -368,21 +366,7 @@ namespace System.Collections.Concurrent
public static int TakeFromAny (BlockingCollection<T>[] collections, out T item)
{
item = default (T);
CheckArray (collections);
WaitHandle[] wait_table = null;
while (true) {
for (int i = 0; i < collections.Length; ++i) {
if (collections [i].TryTake (out item))
return i;
}
if (wait_table == null) {
wait_table = new WaitHandle [collections.Length];
for (int i = 0; i < collections.Length; ++i)
wait_table [i] = collections [i].mreRemove.WaitHandle;
}
WaitHandle.WaitAny (wait_table);
}
return TakeFromAny (collections, out item, CancellationToken.None);
}
public static int TakeFromAny (BlockingCollection<T>[] collections, out T item, CancellationToken cancellationToken)

View File

@@ -94,6 +94,7 @@ namespace System.Diagnostics
public DiagnosticsConfigurationHandler ()
{
elementHandlers ["assert"] = new ElementHandler (AddAssertNode);
elementHandlers ["performanceCounters"] = new ElementHandler (AddPerformanceCountersNode);
elementHandlers ["switches"] = new ElementHandler (AddSwitchesNode);
elementHandlers ["trace"] = new ElementHandler (AddTraceNode);
elementHandlers ["sources"] = new ElementHandler (AddSourcesNode);
@@ -181,6 +182,25 @@ namespace System.Diagnostics
ThrowUnrecognizedElement (node.ChildNodes[0]);
}
private void AddPerformanceCountersNode (IDictionary d, XmlNode node)
{
XmlAttributeCollection c = node.Attributes;
string filemappingsize = GetAttribute (c, "filemappingsize", false, node);
ValidateInvalidAttributes (c, node);
if (filemappingsize != null) {
try {
d ["filemappingsize"] = int.Parse (filemappingsize);
}
catch (Exception e) {
throw new ConfigurationException ("The `filemappingsize' attribute must be an integral value.",
e, node);
}
}
if (node.ChildNodes.Count > 0)
ThrowUnrecognizedElement (node.ChildNodes[0]);
}
// name and value attributes are required
// Docs do not define "remove" or "clear" elements, but .NET recognizes
// them

View File

@@ -29,7 +29,7 @@
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
@@ -227,7 +227,7 @@ namespace System.Diagnostics
DateFormat, CultureInfo.InvariantCulture);
DateTime timeWritten = File.GetLastWriteTime (file);
int stringNums = int.Parse (tr.ReadLine ().Substring (20));
ArrayList replacementTemp = new ArrayList ();
var replacementTemp = new List<string> ();
StringBuilder sb = new StringBuilder ();
while (replacementTemp.Count < stringNums) {
char c = (char) tr.Read ();
@@ -238,8 +238,7 @@ namespace System.Diagnostics
sb.Append (c);
}
}
string [] replacementStrings = new string [replacementTemp.Count];
replacementTemp.CopyTo (replacementStrings, 0);
string [] replacementStrings = replacementTemp.ToArray ();
string message = FormatMessage (source, instanceID, replacementStrings);
int eventID = EventLog.GetEventID (instanceID);

View File

@@ -39,7 +39,7 @@ using System.ComponentModel.Design;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using System.Collections;
using System.Collections.Generic;
using System.Security;
using System.Threading;
@@ -832,13 +832,13 @@ namespace System.Diagnostics {
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static int[] GetProcesses_internal();
public static Process[] GetProcesses()
public static Process[] GetProcesses ()
{
int [] pids = GetProcesses_internal ();
if (pids == null)
return new Process [0];
ArrayList proclist = new ArrayList (pids.Length);
var proclist = new List<Process> (pids.Length);
for (int i = 0; i < pids.Length; i++) {
try {
proclist.Add (GetProcessById (pids [i]));
@@ -851,7 +851,7 @@ namespace System.Diagnostics {
}
}
return ((Process []) proclist.ToArray (typeof (Process)));
return proclist.ToArray ();
}
[MonoTODO ("There is no support for retrieving process information from a remote machine")]
@@ -871,7 +871,7 @@ namespace System.Diagnostics {
if (pids == null)
return new Process [0];
ArrayList proclist = new ArrayList (pids.Length);
var proclist = new List<Process> (pids.Length);
for (int i = 0; i < pids.Length; i++) {
try {
Process p = GetProcessById (pids [i]);
@@ -886,7 +886,7 @@ namespace System.Diagnostics {
}
}
return ((Process []) proclist.ToArray (typeof (Process)));
return proclist.ToArray ();
}
[MonoTODO]
@@ -940,7 +940,7 @@ namespace System.Diagnostics {
ref proc_info);
} finally {
if (proc_info.Password != IntPtr.Zero)
Marshal.FreeBSTR (proc_info.Password);
Marshal.ZeroFreeBSTR (proc_info.Password);
proc_info.Password = IntPtr.Zero;
}
if (!ret) {
@@ -1080,7 +1080,7 @@ namespace System.Diagnostics {
ref proc_info);
} finally {
if (proc_info.Password != IntPtr.Zero)
Marshal.FreeBSTR (proc_info.Password);
Marshal.ZeroFreeBSTR (proc_info.Password);
proc_info.Password = IntPtr.Zero;
}
if (!ret) {

View File

@@ -59,15 +59,11 @@ namespace System.Diagnostics
{
switch (eventType) {
case TraceEventType.Critical:
return (Level & SourceLevels.Critical) != 0;
case TraceEventType.Error:
return (Level & SourceLevels.Error) != 0;
case TraceEventType.Warning:
return (Level & SourceLevels.Warning) != 0;
case TraceEventType.Information:
return (Level & SourceLevels.Information) != 0;
case TraceEventType.Verbose:
return (Level & SourceLevels.Verbose) != 0;
return (Level & (SourceLevels)eventType) != 0;
case TraceEventType.Start:
case TraceEventType.Stop:
case TraceEventType.Suspend:
@@ -78,6 +74,7 @@ namespace System.Diagnostics
}
}
protected override void OnValueChanged ()
{
SwitchSetting = (int) Enum.Parse (typeof (SourceLevels),

View File

@@ -64,8 +64,8 @@ namespace System.Diagnostics
protected Switch(string displayName, string description)
{
this.name = displayName;
this.description = description;
this.name = displayName ?? string.Empty;
this.description = description ?? string.Empty;
}
protected Switch(string displayName, string description, string defaultSwitchValue)

View File

@@ -28,7 +28,7 @@
//
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
@@ -177,12 +177,11 @@ namespace System.Diagnostics
string [] sources = (string []) logKey.GetValue ("Sources");
if (sources != null) {
ArrayList temp = new ArrayList ();
var temp = new List<string> ();
for (int i = 0; i < sources.Length; i++)
if (sources [i] != source)
temp.Add (sources [i]);
string [] newSources = new string [temp.Count];
temp.CopyTo (newSources, 0);
string [] newSources = temp.ToArray ();
logKey.SetValue ("Sources", newSources);
}
}

View File

@@ -529,7 +529,7 @@ namespace System.IO.Ports
// Probe for Linux-styled devices: /dev/ttyS* or /dev/ttyUSB*
//
foreach (string dev in ttys) {
if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB")){
if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB") || dev.StartsWith("/dev/ttyACM")) {
linux_style = true;
break;
}
@@ -537,7 +537,7 @@ namespace System.IO.Ports
foreach (string dev in ttys) {
if (linux_style){
if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB"))
if (dev.StartsWith("/dev/ttyS") || dev.StartsWith("/dev/ttyUSB") || dev.StartsWith("/dev/ttyACM"))
serial_ports.Add (dev);
} else {
if (dev != "/dev/tty" && dev.StartsWith ("/dev/tty") && !dev.StartsWith ("/dev/ttyC"))

View File

@@ -211,7 +211,10 @@ namespace System.IO.Ports
~SerialPortStream ()
{
Dispose (false);
try {
Dispose (false);
} catch (IOException) {
}
}
void CheckDisposed ()

View File

@@ -30,6 +30,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Threading;
@@ -240,12 +241,12 @@ namespace System.IO {
return;
/* Removed files */
ArrayList removed = null;
List<string> removed = null;
foreach (string filename in data.Files.Keys) {
FileData fd = (FileData) data.Files [filename];
if (fd.NotExists) {
if (removed == null)
removed = new ArrayList ();
removed = new List<string> ();
removed.Add (filename);
DispatchEvents (data.FSW, FileAction.Removed, filename);
@@ -269,7 +270,7 @@ namespace System.IO {
} catch {
/* Deleted */
if (removed == null)
removed = new ArrayList ();
removed = new List<string> ();
removed.Add (filename);
DispatchEvents (data.FSW, FileAction.Removed, filename);

View File

@@ -183,7 +183,10 @@ namespace System.IO {
internal SearchPattern2 Pattern {
get {
if (pattern == null) {
pattern = new SearchPattern2 (MangledFilter);
if (watcher.GetType () == typeof (KeventWatcher))
pattern = new SearchPattern2 (MangledFilter, true); //assume we want to ignore case (OS X)
else
pattern = new SearchPattern2 (MangledFilter);
}
return pattern;
}
@@ -372,52 +375,60 @@ namespace System.IO {
ErrorEvent,
RenameEvent
}
private void RaiseEvent (Delegate ev, EventArgs arg, EventType evtype)
{
if (ev == null)
return;
if (synchronizingObject == null) {
switch (evtype) {
case EventType.RenameEvent:
((RenamedEventHandler)ev).BeginInvoke (this, (RenamedEventArgs) arg, null, null);
break;
case EventType.ErrorEvent:
((ErrorEventHandler)ev).BeginInvoke (this, (ErrorEventArgs) arg, null, null);
break;
case EventType.FileSystemEvent:
((FileSystemEventHandler)ev).BeginInvoke (this, (FileSystemEventArgs) arg, null, null);
break;
}
return;
}
synchronizingObject.BeginInvoke (ev, new object [] {this, arg});
}
protected void OnChanged (FileSystemEventArgs e)
{
RaiseEvent (Changed, e, EventType.FileSystemEvent);
if (Changed == null)
return;
if (synchronizingObject == null)
Changed (this, e);
else
synchronizingObject.BeginInvoke (Changed, new object[] { this, e });
}
protected void OnCreated (FileSystemEventArgs e)
{
RaiseEvent (Created, e, EventType.FileSystemEvent);
if (Created == null)
return;
if (synchronizingObject == null)
Created (this, e);
else
synchronizingObject.BeginInvoke (Created, new object[] { this, e });
}
protected void OnDeleted (FileSystemEventArgs e)
{
RaiseEvent (Deleted, e, EventType.FileSystemEvent);
if (Deleted == null)
return;
if (synchronizingObject == null)
Deleted (this, e);
else
synchronizingObject.BeginInvoke (Deleted, new object[] { this, e });
}
protected void OnError (ErrorEventArgs e)
internal void OnError (ErrorEventArgs e)
{
RaiseEvent (Error, e, EventType.ErrorEvent);
if (Error == null)
return;
if (synchronizingObject == null)
Error (this, e);
else
synchronizingObject.BeginInvoke (Error, new object[] { this, e });
}
protected void OnRenamed (RenamedEventArgs e)
{
RaiseEvent (Renamed, e, EventType.RenameEvent);
if (Renamed == null)
return;
if (synchronizingObject == null)
Renamed (this, e);
else
synchronizingObject.BeginInvoke (Renamed, new object[] { this, e });
}
public WaitForChangedResult WaitForChanged (WatcherChangeTypes changeType)

File diff suppressed because it is too large Load Diff

View File

@@ -47,7 +47,7 @@ namespace System.IO {
Compile (pattern);
}
// OSX has a retarded case-insensitive yet case-aware filesystem
// OSX has a case-insensitive yet case-aware filesystem
// so we need a overload in here for the Kqueue watcher
public bool IsMatch (string text, bool ignorecase)
{
@@ -55,20 +55,17 @@ namespace System.IO {
bool match = String.Compare (pattern, text, ignorecase) == 0;
if (match)
return true;
// This is a special case for FSW. It needs to match e.g. subdir/file.txt
// when the pattern is "file.txt"
int idx = text.LastIndexOf ('/');
if (idx == -1)
return false;
idx++;
if (idx == text.Length)
return false;
return (String.Compare (pattern, text.Substring (idx), ignorecase) == 0);
}
// This is a special case for FSW. It needs to match e.g. subdir/file.txt
// when the pattern is "file.txt"
var fileName = Path.GetFileName (text);
return Match (ops, text, 0);
if (!hasWildcard)
return (String.Compare (pattern, fileName, ignorecase) == 0);
return Match (ops, fileName, 0);
}
public bool IsMatch (string text)

View File

@@ -200,6 +200,8 @@ namespace Mono.Audio {
snd_pcm_hw_params_free (hw_param);
if (handle != IntPtr.Zero)
snd_pcm_close (handle);
sw_param = IntPtr.Zero;
hw_param = IntPtr.Zero;
handle = IntPtr.Zero;
}
@@ -278,10 +280,14 @@ namespace Mono.Audio {
Console.WriteLine ("failed to alloc Alsa sw param struct");
}
if (hw_param != IntPtr.Zero)
if (hw_param != IntPtr.Zero) {
snd_pcm_hw_params_free (hw_param); // free hw params
if (sw_param != IntPtr.Zero)
hw_param = IntPtr.Zero;
}
if (sw_param != IntPtr.Zero) {
snd_pcm_sw_params_free (sw_param); // free sw params
sw_param = IntPtr.Zero;
}
return alsa_err == 0;
}

View File

@@ -260,6 +260,8 @@ namespace System.Net.Sockets
curSocket.EndConnect (ares);
} catch (SocketException se) {
SocketError = se.SocketErrorCode;
} catch (ObjectDisposedException) {
SocketError = SocketError.OperationAborted;
} finally {
OnCompleted (this);
}

View File

@@ -952,6 +952,14 @@ namespace System.Net.Sockets {
#endif
}
#if NET_4_5
[MonoTODO ("Currently hardcoded to IPv4. Ideally, support v4/v6 dual-stack.")]
public Socket (SocketType socketType, ProtocolType protocolType)
: this (AddressFamily.InterNetwork, socketType, protocolType)
{
}
#endif
~Socket ()
{
Dispose (false);

View File

@@ -61,6 +61,7 @@ namespace System.Net.WebSockets
const int HeaderMaxLength = 14;
byte[] headerBuffer;
byte[] sendBuffer;
long remaining;
public ClientWebSocket ()
{
@@ -226,32 +227,43 @@ namespace System.Net.WebSockets
ValidateArraySegment (buffer);
return Task.Run (() => {
EnsureWebSocketState (WebSocketState.Open, WebSocketState.CloseSent);
// First read the two first bytes to know what we are doing next
connection.Read (req, headerBuffer, 0, 2);
var isLast = (headerBuffer[0] >> 7) > 0;
var isMasked = (headerBuffer[1] >> 7) > 0;
int mask = 0;
var type = WireToMessageType ((byte)(headerBuffer[0] & 0xF));
long length = headerBuffer[1] & 0x7F;
int offset = 0;
if (length == 126) {
offset = 2;
connection.Read (req, headerBuffer, 2, offset);
length = (headerBuffer[2] << 8) | headerBuffer[3];
} else if (length == 127) {
offset = 8;
connection.Read (req, headerBuffer, 2, offset);
length = 0;
for (int i = 2; i <= 9; i++)
length = (length << 8) | headerBuffer[i];
}
if (isMasked) {
connection.Read (req, headerBuffer, 2 + offset, 4);
for (int i = 0; i < 4; i++) {
var pos = i + offset + 2;
mask = (mask << 8) | headerBuffer[pos];
bool isLast;
WebSocketMessageType type;
long length;
if (remaining == 0) {
// First read the two first bytes to know what we are doing next
connection.Read (req, headerBuffer, 0, 2);
isLast = (headerBuffer[0] >> 7) > 0;
var isMasked = (headerBuffer[1] >> 7) > 0;
int mask = 0;
type = WireToMessageType ((byte)(headerBuffer[0] & 0xF));
length = headerBuffer[1] & 0x7F;
int offset = 0;
if (length == 126) {
offset = 2;
connection.Read (req, headerBuffer, 2, offset);
length = (headerBuffer[2] << 8) | headerBuffer[3];
} else if (length == 127) {
offset = 8;
connection.Read (req, headerBuffer, 2, offset);
length = 0;
for (int i = 2; i <= 9; i++)
length = (length << 8) | headerBuffer[i];
}
if (isMasked) {
connection.Read (req, headerBuffer, 2 + offset, 4);
for (int i = 0; i < 4; i++) {
var pos = i + offset + 2;
mask = (mask << 8) | headerBuffer[pos];
}
}
} else {
isLast = (headerBuffer[0] >> 7) > 0;
type = WireToMessageType ((byte)(headerBuffer[0] & 0xF));
length = remaining;
}
if (type == WebSocketMessageType.Close) {
@@ -264,8 +276,9 @@ namespace System.Net.WebSockets
} else {
var readLength = (int)(buffer.Count < length ? buffer.Count : length);
connection.Read (req, buffer.Array, buffer.Offset, readLength);
remaining = length - readLength;
return new WebSocketReceiveResult ((int)length, type, isLast);
return new WebSocketReceiveResult ((int)readLength, type, isLast && remaining == 0);
}
});
}

View File

@@ -225,6 +225,14 @@ namespace System.Net
}
}
internal struct CFStreamClientContext {
public IntPtr Version;
public IntPtr Info;
public IntPtr Retain;
public IntPtr Release;
public IntPtr CopyDescription;
}
internal class CFString : CFObject
{
string str;
@@ -361,6 +369,52 @@ namespace System.Net
}
}
internal class CFRunLoop : CFObject
{
[DllImport (CFObject.CoreFoundationLibrary)]
static extern void CFRunLoopAddSource (IntPtr rl, IntPtr source, IntPtr mode);
[DllImport (CFObject.CoreFoundationLibrary)]
static extern void CFRunLoopRemoveSource (IntPtr rl, IntPtr source, IntPtr mode);
[DllImport (CFObject.CoreFoundationLibrary)]
static extern int CFRunLoopRunInMode (IntPtr mode, double seconds, bool returnAfterSourceHandled);
[DllImport (CFObject.CoreFoundationLibrary)]
static extern IntPtr CFRunLoopGetCurrent ();
[DllImport (CFObject.CoreFoundationLibrary)]
static extern void CFRunLoopStop (IntPtr rl);
public CFRunLoop (IntPtr handle, bool own): base (handle, own)
{
}
public static CFRunLoop CurrentRunLoop {
get { return new CFRunLoop (CFRunLoopGetCurrent (), false); }
}
public void AddSource (IntPtr source, CFString mode)
{
CFRunLoopAddSource (Handle, source, mode.Handle);
}
public void RemoveSource (IntPtr source, CFString mode)
{
CFRunLoopRemoveSource (Handle, source, mode.Handle);
}
public int RunInMode (CFString mode, double seconds, bool returnAfterSourceHandled)
{
return CFRunLoopRunInMode (mode.Handle, seconds, returnAfterSourceHandled);
}
public void Stop ()
{
CFRunLoopStop (Handle);
}
}
internal enum CFProxyType {
None,
AutoConfigurationUrl,
@@ -615,6 +669,10 @@ namespace System.Net
// CFArrayRef CFNetworkCopyProxiesForAutoConfigurationScript (CFStringRef proxyAutoConfigurationScript, CFURLRef targetURL, CFErrorRef* error);
extern static IntPtr CFNetworkCopyProxiesForAutoConfigurationScriptSequential (IntPtr proxyAutoConfigurationScript, IntPtr targetURL, out IntPtr error);
[DllImport (CFNetworkLibrary)]
extern static IntPtr CFNetworkExecuteProxyAutoConfigurationURL (IntPtr proxyAutoConfigURL, IntPtr targetURL, CFProxyAutoConfigurationResultCallback cb, ref CFStreamClientContext clientContext);
class GetProxyData : IDisposable {
public IntPtr script;
public IntPtr targetUri;
@@ -737,6 +795,45 @@ namespace System.Net
return proxies;
}
delegate void CFProxyAutoConfigurationResultCallback (IntPtr client, IntPtr proxyList, IntPtr error);
public static CFProxy[] ExecuteProxyAutoConfigurationURL (IntPtr proxyAutoConfigURL, Uri targetURL)
{
CFUrl url = CFUrl.Create (targetURL.AbsoluteUri);
if (url == null)
return null;
CFProxy[] proxies = null;
var runLoop = CFRunLoop.CurrentRunLoop;
// Callback that will be called after executing the configuration script
CFProxyAutoConfigurationResultCallback cb = delegate (IntPtr client, IntPtr proxyList, IntPtr error) {
if (proxyList != IntPtr.Zero) {
var array = new CFArray (proxyList, false);
proxies = new CFProxy [array.Count];
for (int i = 0; i < proxies.Length; i++) {
CFDictionary dict = new CFDictionary (array[i], false);
proxies[i] = new CFProxy (dict);
}
array.Dispose ();
}
runLoop.Stop ();
};
var clientContext = new CFStreamClientContext ();
var loopSource = CFNetworkExecuteProxyAutoConfigurationURL (proxyAutoConfigURL, url.Handle, cb, ref clientContext);
// Create a private mode
var mode = CFString.Create ("Mono.MacProxy");
runLoop.AddSource (loopSource, mode);
runLoop.RunInMode (mode, double.MaxValue, false);
runLoop.RemoveSource (loopSource, mode);
return proxies;
}
[DllImport (CFNetworkLibrary)]
// CFArrayRef CFNetworkCopyProxiesForURL (CFURLRef url, CFDictionaryRef proxySettings);
@@ -859,7 +956,18 @@ namespace System.Net
static Uri GetProxyUriFromScript (IntPtr script, Uri targetUri, out NetworkCredential credentials)
{
CFProxy[] proxies = CFNetwork.GetProxiesForAutoConfigurationScript (script, targetUri);
return SelectProxy (proxies, targetUri, out credentials);
}
static Uri ExecuteProxyAutoConfigurationURL (IntPtr proxyAutoConfigURL, Uri targetUri, out NetworkCredential credentials)
{
CFProxy[] proxies = CFNetwork.ExecuteProxyAutoConfigurationURL (proxyAutoConfigURL, targetUri);
return SelectProxy (proxies, targetUri, out credentials);
}
static Uri SelectProxy (CFProxy[] proxies, Uri targetUri, out NetworkCredential credentials)
{
if (proxies == null) {
credentials = null;
return targetUri;
@@ -907,7 +1015,7 @@ namespace System.Net
proxy = GetProxyUriFromScript (proxies[i].AutoConfigurationJavaScript, targetUri, out credentials);
break;
case CFProxyType.AutoConfigurationUrl:
// unsupported proxy type (requires fetching script from remote url)
proxy = ExecuteProxyAutoConfigurationURL (proxies[i].AutoConfigurationUrl, targetUri, out credentials);
break;
case CFProxyType.HTTPS:
case CFProxyType.HTTP:

View File

@@ -369,6 +369,15 @@ namespace System.Net
return sp;
}
internal static void CloseConnectionGroup (string connectionGroupName)
{
lock (servicePoints) {
foreach (ServicePoint sp in servicePoints.Values) {
sp.CloseConnectionGroup (connectionGroupName);
}
}
}
#if SECURITY_DEP
internal class ChainValidationHelper {

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