mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-17 19:10:23 -10:00
Compare commits
41
Commits
xcode8
...
mono-1-1-7-5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cb211e4e89 | ||
|
|
723e38c82c | ||
|
|
669e1211f9 | ||
|
|
a121bd210e | ||
|
|
354e6526a6 | ||
|
|
930459baa1 | ||
|
|
01ce78e62b | ||
|
|
eb5faf4ab7 | ||
|
|
50678d6f8c | ||
|
|
34a6c90b23 | ||
|
|
8dd4410b05 | ||
|
|
d2cccf33e6 | ||
|
|
1afaea4eba | ||
|
|
0812c95b98 | ||
|
|
e415615e81 | ||
|
|
3f03ba2025 | ||
|
|
8dbf91bf20 | ||
|
|
de2c90c4e0 | ||
|
|
f2b7e542a0 | ||
|
|
5dc8ca409d | ||
|
|
ce91af0332 | ||
|
|
6706112e8b | ||
|
|
d9162c6073 | ||
|
|
5bd902eb2f | ||
|
|
899c06b166 | ||
|
|
98b125bc4e | ||
|
|
0304982471 | ||
|
|
0e3bb5c75d | ||
|
|
01e00f43cf | ||
|
|
a04f30944b | ||
|
|
85d8b97aa5 | ||
|
|
84c0ba0211 | ||
|
|
7ef2afa6a8 | ||
|
|
f7f844aa64 | ||
|
|
ea0d5e5a7e | ||
|
|
aae51015d3 | ||
|
|
999eedbde2 | ||
|
|
22812f2442 | ||
|
|
40c96c75f8 | ||
|
|
5467fae98f | ||
|
|
0b70115dbf |
No files matched your search
@@ -1,3 +1,7 @@
|
||||
2005-05-09 Ben Maurer <[email protected]>
|
||||
|
||||
* configure.in: 1.1.7.1
|
||||
|
||||
2005-04-28 James Willcox <[email protected]>
|
||||
|
||||
* man/mkbundle.1: add --config-dir flag
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ AC_CANONICAL_SYSTEM
|
||||
m4_ifdef([_A][M_PROG_TAR],[_A][M_SET_OPTION([tar-ustar])])
|
||||
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.7)
|
||||
AM_INIT_AUTOMAKE(mono,1.1.7.5)
|
||||
AM_MAINTAINER_MODE
|
||||
|
||||
AC_PROG_LN_S
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
}
|
||||
#else
|
||||
#include <gmodule.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
#include "jni.h"
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
2005-06-17 Zoltan Varga <[email protected]>
|
||||
|
||||
* pthread_support.c: Workaround gcc-3.3 compiler bug.
|
||||
|
||||
Tue May 3 16:28:26 CEST 2005 Paolo Molaro <[email protected]>
|
||||
|
||||
|
||||
@@ -556,6 +556,27 @@ GC_bool GC_thr_initialized = FALSE;
|
||||
|
||||
volatile GC_thread GC_threads[THREAD_TABLE_SZ];
|
||||
|
||||
/*
|
||||
* gcc-3.3.6 miscompiles the &GC_thread_key+sizeof(&GC_thread_key) expression so
|
||||
* put it into a separate function.
|
||||
*/
|
||||
# ifdef __GNUC__
|
||||
static __attribute__((noinline)) unsigned char* get_gc_thread_key_addr GC_PROTO((void))
|
||||
{
|
||||
return (unsigned char*)&GC_thread_key;
|
||||
}
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
# if defined(THREAD_LOCAL_ALLOC) && !defined(DBG_HDRS_ALL)
|
||||
GC_push_all((ptr_t)get_gc_thread_key_addr(),
|
||||
(ptr_t)(get_gc_thread_key_addr())+sizeof(&GC_thread_key));
|
||||
# endif
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void GC_push_thread_structures GC_PROTO((void))
|
||||
{
|
||||
GC_push_all((ptr_t)(GC_threads), (ptr_t)(GC_threads)+sizeof(GC_threads));
|
||||
@@ -565,6 +586,8 @@ void GC_push_thread_structures GC_PROTO((void))
|
||||
# endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef THREAD_LOCAL_ALLOC
|
||||
/* We must explicitly mark ptrfree and gcj free lists, since the free */
|
||||
/* list links wouldn't otherwise be found. We also set them in the */
|
||||
|
||||
+3
-2
@@ -454,8 +454,9 @@ shared state data (files, events, mutexes, pipes). By default Mono
|
||||
will store the ".wapi" directory in the users's home directory.
|
||||
.TP
|
||||
.I "MONO_THREADS_PER_CPU"
|
||||
Sets the maximum number of threads in the threadpool per CPU. The default is
|
||||
50 for non-windows systems and 25 for windows.
|
||||
The maximum number of threads in the general threadpool will be
|
||||
20 + (MONO_THREADS_PER_CPU * number of CPUs). The default value for this
|
||||
variable is 5.
|
||||
.TP
|
||||
.I "MONO_TRACE"
|
||||
If set, enables the System.Diagnostics.DefaultTraceListener, which will
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2005-05-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* SslClientStream.cs: check for the dispose in NetworkReadCallback.
|
||||
Patch by Sebastien "Cryptoman" Pouliot.
|
||||
|
||||
2005-04-14 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* SslClientStream.cs: gotta call EndInvoke, not EndRead.
|
||||
|
||||
@@ -510,6 +510,9 @@ namespace Mono.Security.Protocol.Tls
|
||||
// record and return are the records (may be more than one) we have
|
||||
private void NetworkReadCallback (IAsyncResult result)
|
||||
{
|
||||
if (this.disposed)
|
||||
return;
|
||||
|
||||
byte[] recbuf = (byte[])result.AsyncState;
|
||||
int n = innerStream.EndRead (result);
|
||||
if (n > 0)
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2005-05-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpApplicationFactory.cs: ignore any exception thrown when invoking
|
||||
an application event.
|
||||
|
||||
2005-04-23 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpBrowserCapabilities.cs: fix Win32 property.
|
||||
|
||||
@@ -156,10 +156,13 @@ namespace System.Web {
|
||||
return false;
|
||||
|
||||
if (method.GetParameters ().Length == 0)
|
||||
method.Invoke (target, null);
|
||||
else
|
||||
method.Invoke (target, args);
|
||||
args = null;
|
||||
|
||||
try {
|
||||
method.Invoke (target, args);
|
||||
} catch {
|
||||
// Ignore any exception here
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2005-05-05 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* ProcessStringDictionary.cs: on non-windows system, don't make the
|
||||
hashtable case-insensitive. Fixes bug #74796.
|
||||
|
||||
2005-03-23 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* OrderedDictionary.cs: Fix bug in item setter.
|
||||
|
||||
@@ -41,8 +41,14 @@ namespace System.Collections.Specialized
|
||||
|
||||
public ProcessStringDictionary ()
|
||||
{
|
||||
table = new Hashtable (CaseInsensitiveHashCodeProvider.Default,
|
||||
CaseInsensitiveComparer.Default);
|
||||
IHashCodeProvider hash_provider = null;
|
||||
IComparer comparer = null;
|
||||
if ((int) Environment.OSVersion.Platform != 128) {
|
||||
hash_provider = CaseInsensitiveHashCodeProvider.DefaultInvariant;
|
||||
comparer = CaseInsensitiveComparer.DefaultInvariant;
|
||||
}
|
||||
|
||||
table = new Hashtable (hash_provider, comparer);
|
||||
}
|
||||
|
||||
public override int Count {
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2005-05-31 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* Win32Exception.cs: add 10049 WSAEADDRNOTAVAIL. Fixes bug #75106.
|
||||
|
||||
2005-04-28 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* TypeDescriptor.cs: implemented GetEditor. Patch by Jonathan Chambers.
|
||||
|
||||
@@ -132,6 +132,9 @@ namespace System.ComponentModel
|
||||
case 10048:
|
||||
message = Locale.GetText ("Address already in use");
|
||||
break;
|
||||
case 10049:
|
||||
message = Locale.GetText ("The requested address is not valid in this context");
|
||||
break;
|
||||
case 10050:
|
||||
message = Locale.GetText ("Network subsystem is down");
|
||||
break;
|
||||
|
||||
@@ -1,3 +1,35 @@
|
||||
2005-06-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs:
|
||||
* HttpWebRequest.cs:
|
||||
* WebConnectionStream.cs: initiate the polling for input data after
|
||||
sending the header so that we detect any response that the server sends
|
||||
back even if we're still trying to write the request for a POST/PUT.
|
||||
If we get the response (or an error) before any one calls GetResponse(),
|
||||
keep it around instead of ignoring it.
|
||||
|
||||
2005-06-03 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* HttpWebRequest.cs: send the right header/user/password in
|
||||
PreAuthenticate in presence of a proxy.
|
||||
|
||||
2005-06-03 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* ServicePointManager.cs: when going through a proxy, use 2 different
|
||||
service points depending on the scheme. Fixes bug #75135.
|
||||
|
||||
2005-05-23 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs: prevent 2 nullrefs when the aborting during
|
||||
Connect() and reset the status to Success before starting a new
|
||||
request.
|
||||
|
||||
2005-05-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* WebConnection.cs: don't rethrow errors in Write, as the error will be
|
||||
received by GetResponse*. The result is that the threadpool thread doing
|
||||
this will not end up printing the exception. Fixes bug #74817.
|
||||
|
||||
2005-05-03 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* ServicePoint.cs: HostEntry needs to be thread safe.
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace System.Net
|
||||
byte[] bodyBuffer;
|
||||
int bodyBufferLength;
|
||||
bool getResponseCalled;
|
||||
Exception saved_exc;
|
||||
#if NET_1_1
|
||||
int maxResponseHeadersLength;
|
||||
static int defaultMaxResponseHeadersLength;
|
||||
@@ -664,8 +665,13 @@ namespace System.Net
|
||||
initialMethod = method;
|
||||
if (haveResponse) {
|
||||
if (webResponse != null) {
|
||||
Exception saved = saved_exc;
|
||||
Monitor.Exit (this);
|
||||
asyncRead.SetCompleted (true, webResponse);
|
||||
if (saved == null) {
|
||||
asyncRead.SetCompleted (true, webResponse);
|
||||
} else {
|
||||
asyncRead.SetCompleted (true, saved);
|
||||
}
|
||||
asyncRead.DoCallback ();
|
||||
return asyncRead;
|
||||
}
|
||||
@@ -704,9 +710,6 @@ namespace System.Net
|
||||
|
||||
public override WebResponse GetResponse()
|
||||
{
|
||||
if (haveResponse && webResponse != null)
|
||||
return webResponse;
|
||||
|
||||
WebAsyncResult result = (WebAsyncResult) BeginGetResponse (null, null);
|
||||
return EndGetResponse (result);
|
||||
}
|
||||
@@ -896,12 +899,12 @@ namespace System.Net
|
||||
webHeaders.RemoveInternal ("Proxy-Authorization");
|
||||
webHeaders.RemoveInternal ("Authorization");
|
||||
bool isProxy = (proxy != null && !proxy.IsBypassed (actualUri));
|
||||
ICredentials creds = (!isProxy) ? credentials : proxy.Credentials;
|
||||
ICredentials creds = (!isProxy || credentials != null) ? credentials : proxy.Credentials;
|
||||
Authorization auth = AuthenticationManager.PreAuthenticate (this, creds);
|
||||
if (auth == null)
|
||||
return;
|
||||
|
||||
string authHeader = (isProxy) ? "Proxy-Authorization" : "Authorization";
|
||||
string authHeader = (isProxy && credentials == null) ? "Proxy-Authorization" : "Authorization";
|
||||
webHeaders [authHeader] = auth.Message;
|
||||
usedPreAuth = true;
|
||||
}
|
||||
@@ -1008,7 +1011,21 @@ namespace System.Net
|
||||
asyncWrite = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CheckSendError (WebConnectionData data)
|
||||
{
|
||||
// Got here, but no one called GetResponse
|
||||
if (data.StatusCode < 400)
|
||||
return;
|
||||
|
||||
if (writeStream != null && asyncRead == null && !writeStream.CompleteRequestWritten) {
|
||||
// The request has not been completely sent and we got here!
|
||||
// We should probably just close and cause an error in any case,
|
||||
saved_exc = new WebException (data.StatusDescription, null, WebExceptionStatus.ProtocolError, webResponse);
|
||||
webResponse.ReadAll ();
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetResponseData (WebConnectionData data)
|
||||
{
|
||||
if (aborted) {
|
||||
@@ -1027,6 +1044,14 @@ namespace System.Net
|
||||
data.stream.Close ();
|
||||
}
|
||||
|
||||
if (wexc == null && (method == "POST" || method == "PUT")) {
|
||||
lock (this) {
|
||||
CheckSendError (data);
|
||||
if (saved_exc != null)
|
||||
wexc = (WebException) saved_exc;
|
||||
}
|
||||
}
|
||||
|
||||
WebAsyncResult r = asyncRead;
|
||||
if (r != null) {
|
||||
if (wexc != null) {
|
||||
|
||||
@@ -202,7 +202,8 @@ namespace System.Net
|
||||
|
||||
ServicePoint sp = null;
|
||||
lock (servicePoints) {
|
||||
sp = servicePoints [address] as ServicePoint;
|
||||
int key = address.GetHashCode () + (int) ((useConnect) ? 1 : 0);
|
||||
sp = servicePoints [key] as ServicePoint;
|
||||
if (sp != null)
|
||||
return sp;
|
||||
|
||||
@@ -218,7 +219,7 @@ namespace System.Net
|
||||
#endif
|
||||
sp.UsesProxy = usesProxy;
|
||||
sp.UseConnect = useConnect;
|
||||
servicePoints.Add (address, sp);
|
||||
servicePoints.Add (key, sp);
|
||||
}
|
||||
|
||||
return sp;
|
||||
|
||||
@@ -126,9 +126,12 @@ namespace System.Net
|
||||
status = WebExceptionStatus.Success;
|
||||
break;
|
||||
} catch (SocketException) {
|
||||
socket.Close();
|
||||
socket = null;
|
||||
status = WebExceptionStatus.ConnectFailure;
|
||||
// This might be null if the request is aborted
|
||||
if (socket != null) {
|
||||
socket.Close();
|
||||
socket = null;
|
||||
status = WebExceptionStatus.ConnectFailure;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,6 +248,7 @@ namespace System.Net
|
||||
request.ClientCertificates,
|
||||
request, buffer};
|
||||
nstream = (Stream) Activator.CreateInstance (sslStream, args);
|
||||
certsAvailable = false;
|
||||
}
|
||||
// we also need to set ServicePoint.Certificate
|
||||
// and ServicePoint.ClientCertificate but this can
|
||||
@@ -525,8 +529,10 @@ namespace System.Net
|
||||
Data.request = request;
|
||||
Connect ();
|
||||
if (status != WebExceptionStatus.Success) {
|
||||
request.SetWriteStreamError (status);
|
||||
Close (true);
|
||||
if (status != WebExceptionStatus.RequestCanceled) {
|
||||
request.SetWriteStreamError (status);
|
||||
Close (true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -545,6 +551,7 @@ namespace System.Net
|
||||
lock (this) {
|
||||
if (!busy) {
|
||||
busy = true;
|
||||
status = WebExceptionStatus.Success;
|
||||
ThreadPool.QueueUserWorkItem (initConn, request);
|
||||
} else {
|
||||
lock (queue) {
|
||||
@@ -757,10 +764,18 @@ namespace System.Net
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void EndWrite (IAsyncResult result)
|
||||
internal bool EndWrite (IAsyncResult result)
|
||||
{
|
||||
if (nstream != null)
|
||||
if (nstream == null)
|
||||
return false;
|
||||
|
||||
try {
|
||||
nstream.EndWrite (result);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
status = WebExceptionStatus.SendFailure;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
internal int Read (byte [] buffer, int offset, int size)
|
||||
@@ -809,18 +824,20 @@ namespace System.Net
|
||||
if (ssl && !certsAvailable)
|
||||
GetCertificates ();
|
||||
} catch (Exception e) {
|
||||
if (e is WebException)
|
||||
throw e;
|
||||
|
||||
WebExceptionStatus wes = WebExceptionStatus.SendFailure;
|
||||
string msg = "Write";
|
||||
if (e is WebException) {
|
||||
HandleError (wes, e, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// if SSL is in use then check for TrustFailure
|
||||
if (ssl && (bool) piTrustFailure.GetValue (nstream, null)) {
|
||||
wes = WebExceptionStatus.TrustFailure;
|
||||
msg = "Trust failure";
|
||||
}
|
||||
|
||||
HandleError (wes, e, "Write");
|
||||
throw new WebException ("Not connected", e, wes, null);
|
||||
HandleError (wes, e, msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,7 @@ namespace System.Net
|
||||
object locker = new object ();
|
||||
bool initRead;
|
||||
bool read_eof;
|
||||
bool complete_request_written;
|
||||
|
||||
public WebConnectionStream (WebConnection cnc)
|
||||
{
|
||||
@@ -96,6 +97,10 @@ namespace System.Net
|
||||
pending = new ManualResetEvent (true);
|
||||
}
|
||||
|
||||
internal bool CompleteRequestWritten {
|
||||
get { return complete_request_written; }
|
||||
}
|
||||
|
||||
internal bool SendChunked {
|
||||
set { sendChunked = value; }
|
||||
}
|
||||
@@ -513,14 +518,28 @@ namespace System.Net
|
||||
if (cnc.Data.StatusCode != 0 && cnc.Data.StatusCode != 100)
|
||||
return;
|
||||
|
||||
cnc.Write (bytes, 0, length);
|
||||
if (!initRead) {
|
||||
initRead = true;
|
||||
WebConnection.InitRead (cnc);
|
||||
}
|
||||
|
||||
IAsyncResult result = cnc.BeginWrite (bytes, 0, length, null, null);
|
||||
complete_request_written = cnc.EndWrite (result);
|
||||
}
|
||||
|
||||
internal void InternalClose ()
|
||||
{
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
|
||||
internal void ForceCloseConnection ()
|
||||
{
|
||||
if (!disposed) {
|
||||
disposed = true;
|
||||
cnc.Close (true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Close ()
|
||||
{
|
||||
if (sendChunked) {
|
||||
@@ -541,6 +560,7 @@ namespace System.Net
|
||||
}
|
||||
return;
|
||||
} else if (!allowBuffering) {
|
||||
complete_request_written = true;
|
||||
if (!initRead) {
|
||||
initRead = true;
|
||||
WebConnection.InitRead (cnc);
|
||||
@@ -551,17 +571,12 @@ namespace System.Net
|
||||
if (disposed)
|
||||
return;
|
||||
|
||||
disposed = true;
|
||||
|
||||
long length = request.ContentLength;
|
||||
if (length != -1 && length > writeBuffer.Length)
|
||||
throw new IOException ("Cannot close the stream until all bytes are written");
|
||||
|
||||
WriteRequest ();
|
||||
if (!initRead) {
|
||||
initRead = true;
|
||||
WebConnection.InitRead (cnc);
|
||||
}
|
||||
disposed = true;
|
||||
}
|
||||
|
||||
public override long Seek (long a, SeekOrigin b)
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
2005-05-04 Miguel de Icaza <[email protected]>
|
||||
|
||||
* Enum.cs (MonoEnumInfo): Based on a patch from James Willcox,
|
||||
initialize cache as a static method. Fixes #74828.
|
||||
|
||||
2005-05-03 Marek Safar <[email protected]>
|
||||
|
||||
* Console.cs: CancelKeyPress is stubbed.
|
||||
|
||||
|
||||
* Console.cs: CancelKeyPress is stubbed.
|
||||
|
||||
2005-04-25 Sebastien Pouliot <[email protected]>
|
||||
|
||||
* ActivationContext.cs: Updated for beta2.
|
||||
|
||||
@@ -49,6 +49,11 @@ namespace System
|
||||
|
||||
[MethodImplAttribute (MethodImplOptions.InternalCall)]
|
||||
private static extern void get_enum_info (Type enumType, out MonoEnumInfo info);
|
||||
|
||||
static MonoEnumInfo ()
|
||||
{
|
||||
cache = Hashtable.Synchronized (new Hashtable ());
|
||||
}
|
||||
|
||||
private MonoEnumInfo (MonoEnumInfo other)
|
||||
{
|
||||
@@ -59,8 +64,6 @@ namespace System
|
||||
|
||||
internal static void GetInfo (Type enumType, out MonoEnumInfo info)
|
||||
{
|
||||
if (cache == null)
|
||||
cache = Hashtable.Synchronized (new Hashtable ());
|
||||
lock (cache) {
|
||||
if (cache.ContainsKey (enumType)) {
|
||||
info = (MonoEnumInfo) cache [enumType];
|
||||
|
||||
@@ -22,6 +22,3 @@ cs0652.cs
|
||||
cs1540-3.cs # new in GMCS
|
||||
cs1540-5.cs # new in GMCS
|
||||
cs2023.cs
|
||||
cs3007.cs
|
||||
cs3026.cs
|
||||
cs3027.cs
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyVersion("1.1.5")]
|
||||
[assembly: AssemblyVersion("1.1.7")]
|
||||
[assembly: AssemblyTitle ("Mono ILasm Compiler")]
|
||||
[assembly: AssemblyDescription ("Mono ILasm Compiler")]
|
||||
[assembly: AssemblyCopyright ("Sergey Chaban and Jackson Harper")]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
[assembly: AssemblyVersion("1.1.5")]
|
||||
[assembly: AssemblyVersion("1.1.7")]
|
||||
[assembly: AssemblyTitle ("Mono C# Compiler")]
|
||||
[assembly: AssemblyDescription ("Mono C# Compiler")]
|
||||
[assembly: AssemblyCopyright ("2001, 2002, 2003 Ximian, Inc.")]
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
(Foreach.EmitArrayForeach): Removed; this is now in the new
|
||||
ArrayForeach class.
|
||||
|
||||
2005-05-18 Martin Baulig <[email protected]>
|
||||
|
||||
* flowanalysis.cs (FlowBranching.UsageVector.MergeChild): If we're
|
||||
a loop and may leave it, reset the barrier; fixes #74974.
|
||||
|
||||
2005-05-03 Raja R Harinath <[email protected]>
|
||||
|
||||
* pending.cs (BaseImplements): Move the #74773 fix here. This is
|
||||
@@ -1609,6 +1614,20 @@
|
||||
|
||||
2005-01-24 Martin Baulig <[email protected]>
|
||||
|
||||
Fix #74978.
|
||||
|
||||
* flowanalysis.cs
|
||||
(FlowBranching.Reachability): Add non-static public And() and Or()
|
||||
methods.
|
||||
(FlowBranchingSwitch): New class; do the `break_origins' thing
|
||||
like in FlowBranchingLoop.
|
||||
(FlowBranching.UsageVector.MergeBreakOrigins): Also merge the
|
||||
reachability, not just locals and parameters.
|
||||
(FlowBranching.MergeChild): Remove some of the hacks for loop and
|
||||
switch; MergeBreakOrigins() now takes care of that.
|
||||
|
||||
2005-05-18 Martin Baulig <[email protected]>
|
||||
|
||||
* flowanalysis.cs (FlowBranching.UsageVector.MergeChild): If we're
|
||||
merging an implicit block, just use its reachability.
|
||||
|
||||
|
||||
+3
-82
@@ -4125,66 +4125,6 @@ namespace Mono.CSharp {
|
||||
Invocation.EmitCall (ec, true, false, ec.GetThis (loc), base_constructor, argument_list, loc);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method search for base ctor. (We do not cache it).
|
||||
/// </summary>
|
||||
Constructor GetOverloadedConstructor (TypeContainer tc)
|
||||
{
|
||||
if (tc.InstanceConstructors == null)
|
||||
return null;
|
||||
|
||||
foreach (Constructor c in tc.InstanceConstructors) {
|
||||
if (Arguments == null) {
|
||||
if (c.ParameterTypes.Length == 0)
|
||||
return c;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
bool ok = true;
|
||||
|
||||
int count = c.ParameterInfo.Count;
|
||||
if ((count > 0) &&
|
||||
c.ParameterInfo.ParameterModifier (count - 1) == Parameter.Modifier.PARAMS) {
|
||||
for (int i = 0; i < count-1; i++)
|
||||
if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (c.ParameterTypes.Length != Arguments.Count)
|
||||
continue;
|
||||
|
||||
for (int i = 0; i < Arguments.Count; ++i)
|
||||
if (c.ParameterTypes [i] != ((Argument)Arguments [i]).Type) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ok)
|
||||
continue;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//TODO: implement caching when it will be necessary
|
||||
public virtual void CheckObsoleteAttribute (TypeContainer tc, Location loc)
|
||||
{
|
||||
Constructor ctor = GetOverloadedConstructor (tc);
|
||||
if (ctor == null)
|
||||
return;
|
||||
|
||||
ObsoleteAttribute oa = ctor.GetObsoleteAttribute (tc);
|
||||
if (oa == null)
|
||||
return;
|
||||
|
||||
AttributeTester.Report_ObsoleteMessage (oa, ctor.GetSignatureForError (), loc);
|
||||
}
|
||||
}
|
||||
|
||||
public class ConstructorBaseInitializer : ConstructorInitializer {
|
||||
@@ -4192,24 +4132,6 @@ namespace Mono.CSharp {
|
||||
base (argument_list, pars, l)
|
||||
{
|
||||
}
|
||||
|
||||
public override void CheckObsoleteAttribute(TypeContainer tc, Location loc) {
|
||||
if (base_constructor == null)
|
||||
return;
|
||||
|
||||
TypeContainer type_ds = TypeManager.LookupTypeContainer (tc.TypeBuilder.BaseType);
|
||||
if (type_ds == null) {
|
||||
ObsoleteAttribute oa = AttributeTester.GetMemberObsoleteAttribute (base_constructor);
|
||||
|
||||
if (oa != null)
|
||||
AttributeTester.Report_ObsoleteMessage (oa, TypeManager.CSharpSignature (base_constructor), loc);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
base.CheckObsoleteAttribute (type_ds, loc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ConstructorThisInitializer : ConstructorInitializer {
|
||||
@@ -4469,10 +4391,9 @@ namespace Mono.CSharp {
|
||||
}
|
||||
}
|
||||
if (Initializer != null) {
|
||||
if (GetObsoleteAttribute (Parent) == null && Parent.GetObsoleteAttribute (Parent) == null)
|
||||
Initializer.CheckObsoleteAttribute (Parent, Location);
|
||||
else
|
||||
if (GetObsoleteAttribute () != null || Parent.GetObsoleteAttribute (Parent) != null)
|
||||
ec.TestObsoleteMethodUsage = false;
|
||||
|
||||
Initializer.Emit (ec);
|
||||
}
|
||||
|
||||
@@ -4569,7 +4490,7 @@ namespace Mono.CSharp {
|
||||
|
||||
public ObsoleteAttribute GetObsoleteAttribute ()
|
||||
{
|
||||
return null;
|
||||
return GetObsoleteAttribute (Parent);
|
||||
}
|
||||
|
||||
public bool IsExcluded(EmitContext ec)
|
||||
|
||||
+59
-36
@@ -168,10 +168,15 @@ namespace Mono.CSharp
|
||||
return;
|
||||
}
|
||||
|
||||
a.And (b, do_break);
|
||||
}
|
||||
|
||||
public void And (Reachability b, bool do_break)
|
||||
{
|
||||
//
|
||||
// `break' does not "break" in a Switch or a LoopBlock
|
||||
//
|
||||
bool a_breaks = do_break && a.AlwaysBreaks;
|
||||
bool a_breaks = do_break && AlwaysBreaks;
|
||||
bool b_breaks = do_break && b.AlwaysBreaks;
|
||||
|
||||
bool a_has_barrier, b_has_barrier;
|
||||
@@ -180,55 +185,55 @@ namespace Mono.CSharp
|
||||
// This is the normal case: the code following a barrier
|
||||
// cannot be reached.
|
||||
//
|
||||
a_has_barrier = a.AlwaysHasBarrier;
|
||||
a_has_barrier = AlwaysHasBarrier;
|
||||
b_has_barrier = b.AlwaysHasBarrier;
|
||||
} else {
|
||||
//
|
||||
// Special case for Switch and LoopBlocks: we can reach the
|
||||
// code after the barrier via the `break'.
|
||||
//
|
||||
a_has_barrier = !a.AlwaysBreaks && a.AlwaysHasBarrier;
|
||||
a_has_barrier = !AlwaysBreaks && AlwaysHasBarrier;
|
||||
b_has_barrier = !b.AlwaysBreaks && b.AlwaysHasBarrier;
|
||||
}
|
||||
|
||||
bool a_unreachable = a_breaks || a.AlwaysThrows || a_has_barrier;
|
||||
bool a_unreachable = a_breaks || AlwaysThrows || a_has_barrier;
|
||||
bool b_unreachable = b_breaks || b.AlwaysThrows || b_has_barrier;
|
||||
|
||||
//
|
||||
// Do all code paths always return ?
|
||||
//
|
||||
if (a.AlwaysReturns) {
|
||||
if (AlwaysReturns) {
|
||||
if (b.AlwaysReturns || b_unreachable)
|
||||
a.returns = FlowReturns.Always;
|
||||
returns = FlowReturns.Always;
|
||||
else
|
||||
a.returns = FlowReturns.Sometimes;
|
||||
returns = FlowReturns.Sometimes;
|
||||
} else if (b.AlwaysReturns) {
|
||||
if (a.AlwaysReturns || a_unreachable)
|
||||
a.returns = FlowReturns.Always;
|
||||
if (AlwaysReturns || a_unreachable)
|
||||
returns = FlowReturns.Always;
|
||||
else
|
||||
a.returns = FlowReturns.Sometimes;
|
||||
} else if (!a.MayReturn) {
|
||||
returns = FlowReturns.Sometimes;
|
||||
} else if (!MayReturn) {
|
||||
if (b.MayReturn)
|
||||
a.returns = FlowReturns.Sometimes;
|
||||
returns = FlowReturns.Sometimes;
|
||||
else
|
||||
a.returns = FlowReturns.Never;
|
||||
returns = FlowReturns.Never;
|
||||
} else if (!b.MayReturn) {
|
||||
if (a.MayReturn)
|
||||
a.returns = FlowReturns.Sometimes;
|
||||
if (MayReturn)
|
||||
returns = FlowReturns.Sometimes;
|
||||
else
|
||||
a.returns = FlowReturns.Never;
|
||||
returns = FlowReturns.Never;
|
||||
}
|
||||
|
||||
a.breaks = AndFlowReturns (a.breaks, b.breaks);
|
||||
a.throws = AndFlowReturns (a.throws, b.throws);
|
||||
a.barrier = AndFlowReturns (a.barrier, b.barrier);
|
||||
breaks = AndFlowReturns (breaks, b.breaks);
|
||||
throws = AndFlowReturns (throws, b.throws);
|
||||
barrier = AndFlowReturns (barrier, b.barrier);
|
||||
|
||||
if (a_unreachable && b_unreachable)
|
||||
a.barrier = FlowReturns.Always;
|
||||
barrier = FlowReturns.Always;
|
||||
else if (a_unreachable || b_unreachable)
|
||||
a.barrier = FlowReturns.Sometimes;
|
||||
barrier = FlowReturns.Sometimes;
|
||||
else
|
||||
a.barrier = FlowReturns.Never;
|
||||
barrier = FlowReturns.Never;
|
||||
}
|
||||
|
||||
public void Or (Reachability b)
|
||||
@@ -367,7 +372,7 @@ namespace Mono.CSharp
|
||||
throw new InvalidOperationException ();
|
||||
|
||||
case BranchingType.Switch:
|
||||
return new FlowBranchingBlock (parent, type, SiblingType.SwitchSection, block, loc);
|
||||
return new FlowBranchingSwitch (parent, block, loc);
|
||||
|
||||
case BranchingType.SwitchSection:
|
||||
return new FlowBranchingBlock (parent, type, SiblingType.Block, block, loc);
|
||||
@@ -650,19 +655,10 @@ namespace Mono.CSharp
|
||||
}
|
||||
|
||||
new_r.SetBarrier ();
|
||||
} else {
|
||||
if (new_r.Returns == FlowReturns.Always) {
|
||||
// We're either finite or we may leave the loop.
|
||||
new_r.SetReturnsSometimes ();
|
||||
}
|
||||
if (new_r.Throws == FlowReturns.Always) {
|
||||
// We're either finite or we may leave the loop.
|
||||
new_r.SetThrowsSometimes ();
|
||||
}
|
||||
|
||||
if (!new_r.MayReturn && !new_r.MayThrow)
|
||||
new_r.ResetBarrier ();
|
||||
}
|
||||
|
||||
if (may_leave_loop)
|
||||
new_r.ResetBarrier ();
|
||||
} else if (branching.Type == BranchingType.Switch) {
|
||||
if (new_r.MayBreak || new_r.MayReturn)
|
||||
new_r.ResetBarrier ();
|
||||
@@ -822,7 +818,7 @@ namespace Mono.CSharp
|
||||
|
||||
for (UsageVector vector = o_vectors; vector != null;
|
||||
vector = vector.Next) {
|
||||
Report.Debug (1, " MERGING BREAK ORIGIN", vector);
|
||||
Report.Debug (1, " MERGING BREAK ORIGIN", vector, first);
|
||||
|
||||
if (first) {
|
||||
if (locals != null && vector.Locals != null)
|
||||
@@ -837,6 +833,8 @@ namespace Mono.CSharp
|
||||
if (parameters != null)
|
||||
parameters.And (vector.parameters);
|
||||
}
|
||||
|
||||
reachability.And (vector.Reachability, false);
|
||||
}
|
||||
|
||||
Report.Debug (1, " MERGING BREAK ORIGINS DONE", this);
|
||||
@@ -1360,6 +1358,31 @@ namespace Mono.CSharp
|
||||
}
|
||||
}
|
||||
|
||||
public class FlowBranchingSwitch : FlowBranchingBlock
|
||||
{
|
||||
UsageVector break_origins;
|
||||
|
||||
public FlowBranchingSwitch (FlowBranching parent, Block block, Location loc)
|
||||
: base (parent, BranchingType.Switch, SiblingType.SwitchSection, block, loc)
|
||||
{ }
|
||||
|
||||
public override void AddBreakVector (UsageVector vector)
|
||||
{
|
||||
vector = vector.Clone ();
|
||||
vector.Next = break_origins;
|
||||
break_origins = vector;
|
||||
}
|
||||
|
||||
protected override UsageVector Merge ()
|
||||
{
|
||||
UsageVector vector = base.Merge ();
|
||||
|
||||
vector.MergeBreakOrigins (this, break_origins);
|
||||
|
||||
return vector;
|
||||
}
|
||||
}
|
||||
|
||||
public class FlowBranchingException : FlowBranching
|
||||
{
|
||||
ExceptionStatement stmt;
|
||||
|
||||
@@ -917,7 +917,7 @@ namespace Mono.CSharp {
|
||||
} else if (ec.CurrentBranching.InTryOrCatch (false))
|
||||
ec.CurrentBranching.AddFinallyVector (
|
||||
ec.CurrentBranching.CurrentUsageVector);
|
||||
else if (ec.CurrentBranching.InLoop ())
|
||||
else if (ec.CurrentBranching.InLoop () || ec.CurrentBranching.InSwitch ())
|
||||
ec.CurrentBranching.AddBreakVector (
|
||||
ec.CurrentBranching.CurrentUsageVector);
|
||||
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ namespace Mono.CSharp {
|
||||
|
||||
Type t = pi [pos].ParameterType;
|
||||
if (t.IsByRef){
|
||||
if ((pi [pos].Attributes & ParameterAttributes.Out) != 0)
|
||||
if ((pi [pos].Attributes & (ParameterAttributes.Out|ParameterAttributes.In)) == ParameterAttributes.Out)
|
||||
return Parameter.Modifier.ISBYREF | Parameter.Modifier.OUT;
|
||||
else
|
||||
return Parameter.Modifier.ISBYREF | Parameter.Modifier.REF;
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
2005-05-06 Zoltan Varga <[email protected]>
|
||||
|
||||
* main.c: Respect MONO_PATH when loading assemblies.
|
||||
|
||||
2005-04-23 Ankit Jain <[email protected]>
|
||||
|
||||
* get.c : Revert Atsushi's earlier patch. Its already been fixed with r43342.
|
||||
|
||||
@@ -1602,6 +1602,89 @@ load_filter (const char* filename)
|
||||
sort_filter_elems ();
|
||||
}
|
||||
|
||||
|
||||
static gboolean
|
||||
try_load_from (MonoAssembly **assembly, const gchar *path1, const gchar *path2,
|
||||
const gchar *path3, const gchar *path4, gboolean refonly)
|
||||
{
|
||||
gchar *fullpath;
|
||||
|
||||
*assembly = NULL;
|
||||
fullpath = g_build_filename (path1, path2, path3, path4, NULL);
|
||||
if (g_file_test (fullpath, G_FILE_TEST_IS_REGULAR))
|
||||
*assembly = mono_assembly_open_full (fullpath, NULL, refonly);
|
||||
|
||||
g_free (fullpath);
|
||||
return (*assembly != NULL);
|
||||
}
|
||||
|
||||
static MonoAssembly *
|
||||
real_load (gchar **search_path, const gchar *culture, const gchar *name, gboolean refonly)
|
||||
{
|
||||
MonoAssembly *result = NULL;
|
||||
gchar **path;
|
||||
gchar *filename;
|
||||
const gchar *local_culture;
|
||||
gint len;
|
||||
|
||||
if (!culture || *culture == '\0') {
|
||||
local_culture = "";
|
||||
} else {
|
||||
local_culture = culture;
|
||||
}
|
||||
|
||||
filename = g_strconcat (name, ".dll", NULL);
|
||||
len = strlen (filename);
|
||||
|
||||
for (path = search_path; *path; path++) {
|
||||
if (**path == '\0')
|
||||
continue; /* Ignore empty ApplicationBase */
|
||||
|
||||
/* See test cases in bug #58992 and bug #57710 */
|
||||
/* 1st try: [culture]/[name].dll (culture may be empty) */
|
||||
strcpy (filename + len - 4, ".dll");
|
||||
if (try_load_from (&result, *path, local_culture, "", filename, refonly))
|
||||
break;
|
||||
|
||||
/* 2nd try: [culture]/[name].exe (culture may be empty) */
|
||||
strcpy (filename + len - 4, ".exe");
|
||||
if (try_load_from (&result, *path, local_culture, "", filename, refonly))
|
||||
break;
|
||||
|
||||
/* 3rd try: [culture]/[name]/[name].dll (culture may be empty) */
|
||||
strcpy (filename + len - 4, ".dll");
|
||||
if (try_load_from (&result, *path, local_culture, name, filename, refonly))
|
||||
break;
|
||||
|
||||
/* 4th try: [culture]/[name]/[name].exe (culture may be empty) */
|
||||
strcpy (filename + len - 4, ".exe");
|
||||
if (try_load_from (&result, *path, local_culture, name, filename, refonly))
|
||||
break;
|
||||
}
|
||||
|
||||
g_free (filename);
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* Try to load referenced assemblies from assemblies_path.
|
||||
*/
|
||||
static MonoAssembly *
|
||||
monodis_preload (MonoAssemblyName *aname,
|
||||
gchar **assemblies_path,
|
||||
gpointer user_data)
|
||||
{
|
||||
MonoAssembly *result = NULL;
|
||||
gboolean refonly = GPOINTER_TO_UINT (user_data);
|
||||
|
||||
if (assemblies_path && assemblies_path [0] != NULL) {
|
||||
result = real_load (assemblies_path, aname->culture, aname->name, refonly);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
usage (void)
|
||||
{
|
||||
@@ -1684,6 +1767,9 @@ main (int argc, char *argv [])
|
||||
char *filename = input_files->data;
|
||||
|
||||
mono_init_from_assembly (argv [0], filename);
|
||||
|
||||
mono_install_assembly_preload_hook (monodis_preload, GUINT_TO_POINTER (FALSE));
|
||||
|
||||
disassemble_file (filename);
|
||||
} else {
|
||||
mono_init (argv [0]);
|
||||
|
||||
+8
-11
@@ -45,28 +45,28 @@ int main (int argc, char **argv)
|
||||
{
|
||||
guint32 i;
|
||||
|
||||
_wapi_shared_layout = _wapi_shm_attach();
|
||||
_wapi_shared_layout = _wapi_shm_attach(WAPI_SHM_DATA);
|
||||
if (_wapi_shared_layout == FALSE) {
|
||||
g_error ("Failed to attach shared memory!");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
_wapi_fileshare_layout = _wapi_fileshare_shm_attach();
|
||||
_wapi_fileshare_layout = _wapi_shm_attach(WAPI_SHM_FILESHARE);
|
||||
if (_wapi_fileshare_layout == FALSE) {
|
||||
g_error ("Failed to attach fileshare shared memory!");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
if (argc > 1) {
|
||||
_wapi_shm_semaphores_init ();
|
||||
_wapi_collection_init ();
|
||||
_wapi_handle_collect ();
|
||||
}
|
||||
|
||||
g_print ("master: %d namespace: %d collection: %d signals: %d\n",
|
||||
_wapi_shared_layout->master_timestamp,
|
||||
_wapi_shared_layout->namespace_check,
|
||||
g_print ("collection: %d signals: %d sem: 0x%x\n",
|
||||
_wapi_shared_layout->collection_count,
|
||||
_wapi_shared_layout->signal_count);
|
||||
_wapi_shared_layout->signal_count,
|
||||
_wapi_shared_layout->sem_key);
|
||||
|
||||
for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) {
|
||||
struct _WapiHandleShared *shared;
|
||||
@@ -84,19 +84,16 @@ int main (int argc, char **argv)
|
||||
|
||||
shared = &_wapi_shared_layout->handles[meta->offset];
|
||||
if (shared->type != WAPI_HANDLE_UNUSED) {
|
||||
g_print ("%3x (%3x) [%7s] %c %4u %s (%s)\n",
|
||||
g_print ("%3x (%3x) [%7s] %4u %s (%s)\n",
|
||||
i, meta->offset,
|
||||
_wapi_handle_typename[shared->type],
|
||||
meta->checking == 0?' ':'X',
|
||||
now - meta->timestamp,
|
||||
meta->signalled?"Sg":"Un",
|
||||
details[shared->type](shared));
|
||||
}
|
||||
}
|
||||
|
||||
g_print ("Fileshare check: %d hwm: %d\n",
|
||||
_wapi_fileshare_layout->share_check,
|
||||
_wapi_fileshare_layout->hwm);
|
||||
g_print ("Fileshare hwm: %d\n", _wapi_fileshare_layout->hwm);
|
||||
|
||||
for (i = 0; i <= _wapi_fileshare_layout->hwm; i++) {
|
||||
struct _WapiFileShare *file_share;
|
||||
|
||||
@@ -1,3 +1,47 @@
|
||||
2005-05-26 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* processes.c: make ExitCode be valid even if the user didn't call
|
||||
WaitForExit() and is just polling on HasExited.
|
||||
|
||||
2005-05-17 Dick Porter <[email protected]>
|
||||
|
||||
* io.c (file_getfilesize): Clear the error value, so that files
|
||||
with sizes with the low bits 0xFFFFFFFF can be distinguished from
|
||||
a genuine error.
|
||||
|
||||
2005-05-11 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* shared.c: forgot to ignore a warning.
|
||||
|
||||
2005-05-10 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* shared.c: don't display warnings after reboots.
|
||||
|
||||
2005-05-07 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* sockets.c: on windows, getsockopt/setsockopt for send/receive timeout
|
||||
use an integer in milliseconds. We were using a struct timeval.
|
||||
|
||||
2005-05-06 Dick Porter <[email protected]>
|
||||
|
||||
* handles-private.h:
|
||||
* mutexes.c:
|
||||
* wapi-private.h:
|
||||
* shared.h:
|
||||
* shared.c:
|
||||
* wait.c:
|
||||
* handles.c:
|
||||
* collection.h: Use SysV semaphores for managing access to the
|
||||
shared memory - in return for the ludicrous api we get
|
||||
synchronisation primitives that can be cleaned up by the kernel
|
||||
even when a process quits unexpectedly. This removes the
|
||||
timestamp issues.
|
||||
|
||||
2005-05-05 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* handles.c: Always use polling in the waits, since
|
||||
mono_cond_timedwait can't be interruped by the thread abort signal.
|
||||
|
||||
2005-04-30 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* events.c: calling Set on AutoResetEvent several times has the same
|
||||
|
||||
+11
-18
@@ -15,27 +15,20 @@
|
||||
#define _WAPI_HANDLE_COLLECTION_UPDATE_INTERVAL 10
|
||||
#define _WAPI_HANDLE_COLLECTION_EXPIRED_INTERVAL 60
|
||||
|
||||
#define _WAPI_HANDLE_COLLECTION_UNSAFE \
|
||||
{ \
|
||||
guint32 _wapi_save_start; \
|
||||
int _wapi_thr_ret; \
|
||||
\
|
||||
do { \
|
||||
_wapi_save_start = (guint32)(time(NULL) & 0xFFFFFFFF);\
|
||||
\
|
||||
_wapi_thr_ret = _wapi_timestamp_exclusion (&_wapi_shared_layout->master_timestamp, _wapi_save_start); \
|
||||
if (_wapi_thr_ret == EBUSY) { \
|
||||
_wapi_handle_spin (100); \
|
||||
} \
|
||||
} while (_wapi_thr_ret == EBUSY); \
|
||||
g_assert (_wapi_thr_ret == 0);
|
||||
#include <mono/io-layer/shared.h>
|
||||
|
||||
|
||||
#define _WAPI_HANDLE_COLLECTION_SAFE \
|
||||
_wapi_thr_ret = _wapi_timestamp_release (&_wapi_shared_layout->master_timestamp, _wapi_save_start); \
|
||||
#define _WAPI_HANDLE_COLLECTION_UNSAFE \
|
||||
{ \
|
||||
int _wapi_thr_ret; \
|
||||
\
|
||||
_wapi_thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_COLLECTION); \
|
||||
g_assert(_wapi_thr_ret == 0);
|
||||
|
||||
#define _WAPI_HANDLE_COLLECTION_SAFE \
|
||||
_wapi_thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_COLLECTION); \
|
||||
g_assert (_wapi_thr_ret == 0); \
|
||||
}
|
||||
|
||||
|
||||
extern void _wapi_collection_init (void);
|
||||
extern void _wapi_handle_collect (void);
|
||||
|
||||
|
||||
+22
-102
@@ -19,6 +19,7 @@
|
||||
#include <mono/io-layer/wapi-private.h>
|
||||
#include <mono/io-layer/misc-private.h>
|
||||
#include <mono/io-layer/collection.h>
|
||||
#include <mono/io-layer/shared.h>
|
||||
|
||||
#define _WAPI_PRIVATE_MAX_SLOTS 1024
|
||||
#define _WAPI_PRIVATE_HANDLES(x) (_wapi_private_handles [x / _WAPI_HANDLE_INITIAL_COUNT][x % _WAPI_HANDLE_INITIAL_COUNT])
|
||||
@@ -33,6 +34,7 @@ extern struct _WapiFileShareLayout *_wapi_fileshare_layout;
|
||||
extern guint32 _wapi_fd_reserve;
|
||||
extern mono_mutex_t _wapi_global_signal_mutex;
|
||||
extern pthread_cond_t _wapi_global_signal_cond;
|
||||
extern int _wapi_sem_id;
|
||||
|
||||
extern gpointer _wapi_handle_new (WapiHandleType type,
|
||||
gpointer handle_specific);
|
||||
@@ -50,8 +52,6 @@ extern gpointer _wapi_search_handle (WapiHandleType type,
|
||||
gboolean (*check)(gpointer, gpointer),
|
||||
gpointer user_data,
|
||||
gpointer *handle_specific);
|
||||
extern int _wapi_namespace_timestamp_release (gpointer nowptr);
|
||||
extern int _wapi_namespace_timestamp (guint32 now);
|
||||
extern gint32 _wapi_search_handle_namespace (WapiHandleType type,
|
||||
gchar *utf8_name);
|
||||
extern void _wapi_handle_ref (gpointer handle);
|
||||
@@ -71,10 +71,9 @@ extern gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
|
||||
gpointer *handles,
|
||||
gboolean waitall,
|
||||
guint32 *retcount,
|
||||
guint32 *lowest,
|
||||
guint32 *now);
|
||||
guint32 *lowest);
|
||||
extern void _wapi_handle_unlock_handles (guint32 numhandles,
|
||||
gpointer *handles, guint32 now);
|
||||
gpointer *handles);
|
||||
extern int _wapi_handle_wait_signal (void);
|
||||
extern int _wapi_handle_timedwait_signal (struct timespec *timeout);
|
||||
extern int _wapi_handle_wait_signal_poll_share (void);
|
||||
@@ -275,43 +274,6 @@ static inline int _wapi_handle_unlock_handle (gpointer handle)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static inline int _wapi_timestamp_exclusion (volatile gint32 *timestamp,
|
||||
guint32 now)
|
||||
{
|
||||
guint32 then;
|
||||
int ret;
|
||||
|
||||
then = InterlockedCompareExchange (timestamp, now, 0);
|
||||
if (then == 0) {
|
||||
ret = 0;
|
||||
} else if (now - then > 10) {
|
||||
/* Try to overwrite the previous
|
||||
* attempt, but make sure noone else
|
||||
* got in first
|
||||
*/
|
||||
g_warning ("%s: Breaking a previous timestamp", __func__);
|
||||
|
||||
ret = InterlockedCompareExchange (timestamp, now,
|
||||
then) == then?0:EBUSY;
|
||||
} else {
|
||||
/* Someone else is working on this one */
|
||||
ret = EBUSY;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
static inline int _wapi_timestamp_release (volatile gint32 *timestamp,
|
||||
guint32 now)
|
||||
{
|
||||
/* The timestamp can be either: now, in which case we reset
|
||||
* it; 0, in which case we don't do anything; any other value,
|
||||
* in which case we don't do anything because someone else is
|
||||
* in charge of resetting it.
|
||||
*/
|
||||
return(InterlockedCompareExchange (timestamp, 0, now) != now);
|
||||
}
|
||||
|
||||
static inline void _wapi_handle_spin (guint32 ms)
|
||||
{
|
||||
struct timespec sleepytime;
|
||||
@@ -324,89 +286,47 @@ static inline void _wapi_handle_spin (guint32 ms)
|
||||
nanosleep (&sleepytime, NULL);
|
||||
}
|
||||
|
||||
static inline int _wapi_handle_shared_lock_handle (gpointer handle, guint32 *now)
|
||||
static inline int _wapi_handle_lock_shared_handles (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
g_assert (_WAPI_SHARED_HANDLE(_wapi_handle_type(handle)));
|
||||
|
||||
_wapi_handle_ref (handle);
|
||||
|
||||
/* We don't lock shared handles, but we need to be able to
|
||||
* tell other threads to hold off.
|
||||
*
|
||||
* We do this by atomically putting the least-significant 32
|
||||
* bits of time(2) into the 'checking' field if it is zero.
|
||||
* If it isn't zero, then it means that either another thread
|
||||
* is looking at this handle right now, or someone crashed
|
||||
* here. Assume that if the time value is more than 10
|
||||
* seconds old, its a crash and override it. 10 seconds
|
||||
* should be enough for anyone...
|
||||
*
|
||||
* If the time value is within 10 seconds, back off and try
|
||||
* again as per the non-shared case.
|
||||
*/
|
||||
do {
|
||||
*now = (guint32)(time (NULL) & 0xFFFFFFFF);
|
||||
|
||||
ret = _wapi_timestamp_exclusion (&WAPI_SHARED_HANDLE_METADATA(handle).checking, *now);
|
||||
if (ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (ret == EBUSY);
|
||||
|
||||
return (ret);
|
||||
return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_HANDLE));
|
||||
}
|
||||
|
||||
static inline int _wapi_handle_shared_trylock_handle (gpointer handle, guint32 now)
|
||||
static inline int _wapi_handle_trylock_shared_handles (void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
g_assert (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle)));
|
||||
|
||||
_wapi_handle_ref (handle);
|
||||
|
||||
ret = _wapi_timestamp_exclusion (&WAPI_SHARED_HANDLE_METADATA(handle).checking, now);
|
||||
if (ret == EBUSY) {
|
||||
_wapi_handle_unref (handle);
|
||||
}
|
||||
|
||||
return (ret);
|
||||
return(_wapi_shm_sem_trylock (_WAPI_SHARED_SEM_HANDLE));
|
||||
}
|
||||
|
||||
static inline int _wapi_handle_shared_unlock_handle (gpointer handle, guint32 now)
|
||||
static inline int _wapi_handle_unlock_shared_handles (void)
|
||||
{
|
||||
g_assert (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle)));
|
||||
|
||||
_wapi_timestamp_release (&WAPI_SHARED_HANDLE_METADATA(handle).checking, now);
|
||||
_wapi_handle_unref (handle);
|
||||
return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_HANDLE));
|
||||
}
|
||||
|
||||
return (0);
|
||||
static inline int _wapi_namespace_lock (void)
|
||||
{
|
||||
return(_wapi_shm_sem_lock (_WAPI_SHARED_SEM_NAMESPACE));
|
||||
}
|
||||
|
||||
/* This signature makes it easier to use in pthread cleanup handlers */
|
||||
static inline int _wapi_namespace_unlock (gpointer data G_GNUC_UNUSED)
|
||||
{
|
||||
return(_wapi_shm_sem_unlock (_WAPI_SHARED_SEM_NAMESPACE));
|
||||
}
|
||||
|
||||
static inline void _wapi_handle_share_release (struct _WapiFileShare *info)
|
||||
{
|
||||
guint32 now;
|
||||
int thr_ret;
|
||||
|
||||
g_assert (info->handle_refs > 0);
|
||||
|
||||
/* Prevent new entries racing with us */
|
||||
do {
|
||||
now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
|
||||
thr_ret = _wapi_timestamp_exclusion (&_wapi_fileshare_layout->share_check, now);
|
||||
if (thr_ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (thr_ret == EBUSY);
|
||||
thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_SHARE);
|
||||
g_assert(thr_ret == 0);
|
||||
|
||||
if (InterlockedDecrement (&info->handle_refs) == 0) {
|
||||
memset (info, '\0', sizeof(struct _WapiFileShare));
|
||||
}
|
||||
|
||||
thr_ret = _wapi_timestamp_release (&_wapi_fileshare_layout->share_check, now);
|
||||
thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_SHARE);
|
||||
}
|
||||
|
||||
#endif /* _WAPI_HANDLES_PRIVATE_H_ */
|
||||
+72
-216
@@ -102,6 +102,8 @@ guint32 _wapi_fd_reserve;
|
||||
mono_mutex_t _wapi_global_signal_mutex;
|
||||
pthread_cond_t _wapi_global_signal_cond;
|
||||
|
||||
int _wapi_sem_id;
|
||||
|
||||
static mono_mutex_t scan_mutex = MONO_MUTEX_INITIALIZER;
|
||||
|
||||
static mono_once_t shared_init_once = MONO_ONCE_INIT;
|
||||
@@ -119,10 +121,12 @@ static void shared_init (void)
|
||||
_wapi_private_handle_count += _WAPI_HANDLE_INITIAL_COUNT;
|
||||
} while(_wapi_fd_reserve > _wapi_private_handle_count);
|
||||
|
||||
_wapi_shared_layout = _wapi_shm_attach ();
|
||||
_wapi_shared_layout = _wapi_shm_attach (WAPI_SHM_DATA);
|
||||
g_assert (_wapi_shared_layout != NULL);
|
||||
|
||||
_wapi_shm_semaphores_init ();
|
||||
|
||||
_wapi_fileshare_layout = _wapi_fileshare_shm_attach ();
|
||||
_wapi_fileshare_layout = _wapi_shm_attach (WAPI_SHM_FILESHARE);
|
||||
g_assert (_wapi_fileshare_layout != NULL);
|
||||
|
||||
_wapi_collection_init ();
|
||||
@@ -138,7 +142,6 @@ static void _wapi_handle_init_shared_metadata (struct _WapiHandleSharedMetadata
|
||||
{
|
||||
meta->timestamp = (guint32)(time (NULL) & 0xFFFFFFFF);
|
||||
meta->signalled = FALSE;
|
||||
meta->checking = 0;
|
||||
}
|
||||
|
||||
static void _wapi_handle_init_shared (struct _WapiHandleShared *handle,
|
||||
@@ -811,30 +814,6 @@ done:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* This signature makes it easier to use in pthread cleanup handlers */
|
||||
int _wapi_namespace_timestamp_release (gpointer nowptr)
|
||||
{
|
||||
guint32 now = GPOINTER_TO_UINT(nowptr);
|
||||
|
||||
return (_wapi_timestamp_release (&_wapi_shared_layout->namespace_check,
|
||||
now));
|
||||
}
|
||||
|
||||
int _wapi_namespace_timestamp (guint32 now)
|
||||
{
|
||||
int ret;
|
||||
|
||||
do {
|
||||
ret = _wapi_timestamp_exclusion (&_wapi_shared_layout->namespace_check, now);
|
||||
/* sleep for a bit */
|
||||
if (ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (ret == EBUSY);
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
/* Returns the offset of the metadata array, or -1 on error, or 0 for
|
||||
* not found (0 is not a valid offset)
|
||||
*/
|
||||
@@ -847,7 +826,6 @@ gint32 _wapi_search_handle_namespace (WapiHandleType type,
|
||||
gint32 ret = 0;
|
||||
|
||||
g_assert(_WAPI_SHARED_HANDLE(type));
|
||||
g_assert(_wapi_shared_layout->namespace_check != 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: Lookup for handle named [%s] type %s", __func__,
|
||||
@@ -1116,8 +1094,7 @@ gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
|
||||
gpointer *handles,
|
||||
gboolean waitall,
|
||||
guint32 *retcount,
|
||||
guint32 *lowest,
|
||||
guint32 *now)
|
||||
guint32 *lowest)
|
||||
{
|
||||
guint32 count, i, iter=0;
|
||||
gboolean ret;
|
||||
@@ -1126,6 +1103,9 @@ gboolean _wapi_handle_count_signalled_handles (guint32 numhandles,
|
||||
|
||||
/* Lock all the handles, with backoff */
|
||||
again:
|
||||
thr_ret = _wapi_handle_lock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
for(i=0; i<numhandles; i++) {
|
||||
gpointer handle = handles[i];
|
||||
guint32 idx = GPOINTER_TO_UINT(handle);
|
||||
@@ -1134,15 +1114,9 @@ again:
|
||||
g_message ("%s: attempting to lock %p", __func__, handle);
|
||||
#endif
|
||||
|
||||
*now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
type = _WAPI_PRIVATE_HANDLES(idx).type;
|
||||
|
||||
if (_WAPI_SHARED_HANDLE(type)) {
|
||||
thr_ret = _wapi_handle_shared_trylock_handle (handle,
|
||||
*now);
|
||||
} else {
|
||||
thr_ret = _wapi_handle_trylock_handle (handle);
|
||||
}
|
||||
thr_ret = _wapi_handle_trylock_handle (handle);
|
||||
|
||||
if (thr_ret != 0) {
|
||||
/* Bummer */
|
||||
@@ -1152,16 +1126,14 @@ again:
|
||||
handle, strerror (thr_ret));
|
||||
#endif
|
||||
|
||||
thr_ret = _wapi_handle_unlock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
while (i--) {
|
||||
handle = handles[i];
|
||||
idx = GPOINTER_TO_UINT(handle);
|
||||
|
||||
if (_WAPI_SHARED_HANDLE(type)) {
|
||||
thr_ret = _wapi_handle_shared_unlock_handle (handle, *now);
|
||||
} else {
|
||||
thr_ret = _wapi_handle_unlock_handle (handle);
|
||||
}
|
||||
|
||||
thr_ret = _wapi_handle_unlock_handle (handle);
|
||||
g_assert (thr_ret == 0);
|
||||
}
|
||||
|
||||
@@ -1243,221 +1215,127 @@ again:
|
||||
return(ret);
|
||||
}
|
||||
|
||||
void _wapi_handle_unlock_handles (guint32 numhandles, gpointer *handles,
|
||||
guint32 now)
|
||||
void _wapi_handle_unlock_handles (guint32 numhandles, gpointer *handles)
|
||||
{
|
||||
guint32 i;
|
||||
int thr_ret;
|
||||
|
||||
thr_ret = _wapi_handle_unlock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
for(i=0; i<numhandles; i++) {
|
||||
gpointer handle = handles[i];
|
||||
guint32 idx = GPOINTER_TO_UINT(handle);
|
||||
WapiHandleType type = _WAPI_PRIVATE_HANDLES(idx).type;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: unlocking handle %p", __func__, handle);
|
||||
#endif
|
||||
|
||||
if (_WAPI_SHARED_HANDLE(type)) {
|
||||
thr_ret = _wapi_handle_shared_unlock_handle (handle,
|
||||
now);
|
||||
} else {
|
||||
thr_ret = _wapi_handle_unlock_handle (handle);
|
||||
}
|
||||
thr_ret = _wapi_handle_unlock_handle (handle);
|
||||
g_assert (thr_ret == 0);
|
||||
}
|
||||
}
|
||||
|
||||
static int timedwait_signal_poll_cond (pthread_cond_t *cond, mono_mutex_t *mutex, struct timespec *timeout)
|
||||
{
|
||||
struct timespec fake_timeout;
|
||||
int ret;
|
||||
|
||||
_wapi_calc_timeout (&fake_timeout, 100);
|
||||
|
||||
if (timeout != NULL && ((fake_timeout.tv_sec > timeout->tv_sec) ||
|
||||
(fake_timeout.tv_sec == timeout->tv_sec &&
|
||||
fake_timeout.tv_nsec > timeout->tv_nsec))) {
|
||||
/* Real timeout is less than 100ms time */
|
||||
ret=mono_cond_timedwait (cond, mutex, timeout);
|
||||
} else {
|
||||
ret=mono_cond_timedwait (cond, mutex, &fake_timeout);
|
||||
|
||||
/* Mask the fake timeout, this will cause
|
||||
* another poll if the cond was not really signaled
|
||||
*/
|
||||
if (ret==ETIMEDOUT) {
|
||||
ret=0;
|
||||
}
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int _wapi_handle_wait_signal (void)
|
||||
{
|
||||
return(mono_cond_wait (&_wapi_global_signal_cond,
|
||||
&_wapi_global_signal_mutex));
|
||||
return timedwait_signal_poll_cond (&_wapi_global_signal_cond, &_wapi_global_signal_mutex, NULL);
|
||||
}
|
||||
|
||||
int _wapi_handle_timedwait_signal (struct timespec *timeout)
|
||||
{
|
||||
return(mono_cond_timedwait (&_wapi_global_signal_cond,
|
||||
&_wapi_global_signal_mutex,
|
||||
timeout));
|
||||
return timedwait_signal_poll_cond (&_wapi_global_signal_cond, &_wapi_global_signal_mutex, timeout);
|
||||
}
|
||||
|
||||
int _wapi_handle_wait_signal_poll_share (void)
|
||||
{
|
||||
struct timespec fake_timeout;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: poll private and shared handles", __func__);
|
||||
#endif
|
||||
|
||||
_wapi_calc_timeout (&fake_timeout, 100);
|
||||
|
||||
ret = mono_cond_timedwait (&_wapi_global_signal_cond,
|
||||
&_wapi_global_signal_mutex, &fake_timeout);
|
||||
|
||||
if (ret == ETIMEDOUT) {
|
||||
/* This will cause the waiting thread to check signal
|
||||
* status for all handles
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: poll timed out, returning success", __func__);
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
} else {
|
||||
/* This will be 0 indicating a private handle was
|
||||
* signalled, or an error
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning: %d", __func__, ret);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
}
|
||||
return timedwait_signal_poll_cond (&_wapi_global_signal_cond, &_wapi_global_signal_mutex, NULL);
|
||||
}
|
||||
|
||||
int _wapi_handle_timedwait_signal_poll_share (struct timespec *timeout)
|
||||
{
|
||||
struct timespec fake_timeout;
|
||||
guint32 signal_count = _wapi_shared_layout->signal_count;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: poll private and shared handles", __func__);
|
||||
#endif
|
||||
|
||||
do {
|
||||
_wapi_calc_timeout (&fake_timeout, 100);
|
||||
|
||||
if ((fake_timeout.tv_sec > timeout->tv_sec) ||
|
||||
(fake_timeout.tv_sec == timeout->tv_sec &&
|
||||
fake_timeout.tv_nsec > timeout->tv_nsec)) {
|
||||
/* Real timeout is less than 100ms time */
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: last few ms", __func__);
|
||||
#endif
|
||||
|
||||
ret = mono_cond_timedwait (&_wapi_global_signal_cond,
|
||||
&_wapi_global_signal_mutex,
|
||||
timeout);
|
||||
/* If this times out, it will compare the
|
||||
* shared signal counter and then if that
|
||||
* hasn't increased will fall out of the
|
||||
* do-while loop.
|
||||
*/
|
||||
if (ret != ETIMEDOUT) {
|
||||
/* Either a private handle was
|
||||
* signalled, or an error.
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning: %d", __func__, ret);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
} else {
|
||||
ret = mono_cond_timedwait (&_wapi_global_signal_cond,
|
||||
&_wapi_global_signal_mutex,
|
||||
&fake_timeout);
|
||||
|
||||
/* Mask the fake timeout, this will cause
|
||||
* another poll if the shared counter hasn't
|
||||
* changed
|
||||
*/
|
||||
if (ret == ETIMEDOUT) {
|
||||
ret = 0;
|
||||
} else {
|
||||
/* Either a private handle was
|
||||
* signalled, or an error
|
||||
*/
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning: %d", __func__, ret);
|
||||
#endif
|
||||
return (ret);
|
||||
}
|
||||
}
|
||||
|
||||
/* No private handle was signalled, so check the
|
||||
* shared signal counter
|
||||
*/
|
||||
if (signal_count != _wapi_shared_layout->signal_count) {
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: A shared handle was signalled",
|
||||
__func__);
|
||||
#endif
|
||||
return (0);
|
||||
}
|
||||
} while (ret != ETIMEDOUT);
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning ETIMEDOUT", __func__);
|
||||
#endif
|
||||
|
||||
return (ret);
|
||||
return timedwait_signal_poll_cond (&_wapi_global_signal_cond, &_wapi_global_signal_mutex, timeout);
|
||||
}
|
||||
|
||||
int _wapi_handle_wait_signal_handle (gpointer handle)
|
||||
{
|
||||
guint32 idx = GPOINTER_TO_UINT(handle);
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: waiting for %p", __func__, handle);
|
||||
#endif
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
while(1) {
|
||||
if (WAPI_SHARED_HANDLE_METADATA(handle).signalled == TRUE) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} else {
|
||||
return(mono_cond_wait (&_WAPI_PRIVATE_HANDLES(idx).signal_cond,
|
||||
&_WAPI_PRIVATE_HANDLES(idx).signal_mutex));
|
||||
}
|
||||
return _wapi_handle_timedwait_signal_handle (handle, NULL);
|
||||
}
|
||||
|
||||
int _wapi_handle_timedwait_signal_handle (gpointer handle,
|
||||
struct timespec *timeout)
|
||||
{
|
||||
guint32 idx = GPOINTER_TO_UINT(handle);
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: waiting for %p (type %s)", __func__, handle,
|
||||
_wapi_handle_typename[_wapi_handle_type (handle)]);
|
||||
#endif
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
struct timespec fake_timeout;
|
||||
|
||||
while (1) {
|
||||
if (WAPI_SHARED_HANDLE_METADATA(handle).signalled == TRUE) {
|
||||
return (0);
|
||||
}
|
||||
|
||||
if (WAPI_SHARED_HANDLE_METADATA(handle).signalled == TRUE) {
|
||||
return (0);
|
||||
}
|
||||
if (timeout != NULL) {
|
||||
struct timespec fake_timeout;
|
||||
_wapi_calc_timeout (&fake_timeout, 100);
|
||||
|
||||
if ((fake_timeout.tv_sec > timeout->tv_sec) ||
|
||||
(fake_timeout.tv_sec == timeout->tv_sec &&
|
||||
fake_timeout.tv_nsec > timeout->tv_nsec)) {
|
||||
(fake_timeout.tv_sec == timeout->tv_sec &&
|
||||
fake_timeout.tv_nsec > timeout->tv_nsec)) {
|
||||
/* FIXME: Real timeout is less than
|
||||
* 100ms time, but is it really worth
|
||||
* calculating to the exact ms?
|
||||
*/
|
||||
_wapi_handle_spin (100);
|
||||
|
||||
|
||||
if (WAPI_SHARED_HANDLE_METADATA(handle).signalled == TRUE) {
|
||||
return (0);
|
||||
} else {
|
||||
return (ETIMEDOUT);
|
||||
}
|
||||
} else {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
}
|
||||
_wapi_handle_spin (100);
|
||||
return (0);
|
||||
|
||||
} else {
|
||||
return(mono_cond_timedwait (&_WAPI_PRIVATE_HANDLES(idx).signal_cond, &_WAPI_PRIVATE_HANDLES(idx).signal_mutex, timeout));
|
||||
guint32 idx = GPOINTER_TO_UINT(handle);
|
||||
return timedwait_signal_poll_cond (&_WAPI_PRIVATE_HANDLES(idx).signal_cond, &_WAPI_PRIVATE_HANDLES(idx).signal_mutex, timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1479,14 +1357,7 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
|
||||
_WAPI_HANDLE_COLLECTION_UNSAFE;
|
||||
|
||||
/* Prevent new entries racing with us */
|
||||
do {
|
||||
now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
|
||||
thr_ret = _wapi_timestamp_exclusion (&_wapi_fileshare_layout->share_check, now);
|
||||
if (thr_ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (thr_ret == EBUSY);
|
||||
thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_SHARE);
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
/* If a linear scan gets too slow we'll have to fit a hash
|
||||
@@ -1551,7 +1422,7 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
|
||||
InterlockedExchange (&(*share_info)->timestamp, now);
|
||||
}
|
||||
|
||||
thr_ret = _wapi_timestamp_release (&_wapi_fileshare_layout->share_check, now);
|
||||
thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_SHARE);
|
||||
|
||||
_WAPI_HANDLE_COLLECTION_SAFE;
|
||||
|
||||
@@ -1591,7 +1462,6 @@ void _wapi_handle_check_share (struct _WapiFileShare *share_info, int fd)
|
||||
gboolean found = FALSE, proc_fds = FALSE;
|
||||
pid_t self = getpid();
|
||||
int pid;
|
||||
guint32 now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
int thr_ret, i;
|
||||
|
||||
/* If there is no /proc, there's nothing more we can do here */
|
||||
@@ -1606,14 +1476,7 @@ void _wapi_handle_check_share (struct _WapiFileShare *share_info, int fd)
|
||||
_WAPI_HANDLE_COLLECTION_UNSAFE;
|
||||
|
||||
/* Prevent new entries racing with us */
|
||||
do {
|
||||
now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
|
||||
thr_ret = _wapi_timestamp_exclusion (&_wapi_fileshare_layout->share_check, now);
|
||||
if (thr_ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (thr_ret == EBUSY);
|
||||
thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_SHARE);
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
for (i = 0; i < _WAPI_HANDLE_INITIAL_COUNT; i++) {
|
||||
@@ -1692,7 +1555,7 @@ void _wapi_handle_check_share (struct _WapiFileShare *share_info, int fd)
|
||||
memset (share_info, '\0', sizeof(struct _WapiFileShare));
|
||||
}
|
||||
|
||||
thr_ret = _wapi_timestamp_release (&_wapi_fileshare_layout->share_check, now);
|
||||
thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_SHARE);
|
||||
|
||||
_WAPI_HANDLE_COLLECTION_SAFE;
|
||||
}
|
||||
@@ -1730,21 +1593,13 @@ static void _wapi_shared_details (gpointer handle_info)
|
||||
|
||||
void _wapi_handle_update_refs (void)
|
||||
{
|
||||
guint32 i, k, lock_now;
|
||||
guint32 i, k;
|
||||
int thr_ret;
|
||||
|
||||
_WAPI_HANDLE_COLLECTION_UNSAFE;
|
||||
|
||||
/* Prevent file share entries racing with us */
|
||||
do {
|
||||
lock_now = (guint32)(time(NULL) & 0xFFFFFFFF);
|
||||
|
||||
thr_ret = _wapi_timestamp_exclusion (&_wapi_fileshare_layout->share_check, lock_now);
|
||||
|
||||
if (thr_ret == EBUSY) {
|
||||
_wapi_handle_spin (100);
|
||||
}
|
||||
} while (thr_ret == EBUSY);
|
||||
thr_ret = _wapi_shm_sem_lock (_WAPI_SHARED_SEM_SHARE);
|
||||
g_assert(thr_ret == 0);
|
||||
|
||||
for(i = SLOT_INDEX (0); _wapi_private_handles [i] != NULL; i++) {
|
||||
@@ -1790,6 +1645,7 @@ void _wapi_handle_update_refs (void)
|
||||
}
|
||||
}
|
||||
|
||||
thr_ret = _wapi_timestamp_release (&_wapi_fileshare_layout->share_check, lock_now);
|
||||
thr_ret = _wapi_shm_sem_unlock (_WAPI_SHARED_SEM_SHARE);
|
||||
|
||||
_WAPI_HANDLE_COLLECTION_SAFE;
|
||||
}
|
||||
+40
-12
@@ -673,11 +673,17 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
|
||||
return(INVALID_FILE_SIZE);
|
||||
}
|
||||
|
||||
ret=fstat(fd, &statbuf);
|
||||
if(ret==-1) {
|
||||
/* If the file has a size with the low bits 0xFFFFFFFF the
|
||||
* caller can't tell if this is an error, so clear the error
|
||||
* value
|
||||
*/
|
||||
SetLastError (ERROR_SUCCESS);
|
||||
|
||||
ret = fstat(fd, &statbuf);
|
||||
if (ret == -1) {
|
||||
#ifdef DEBUG
|
||||
g_message("%s: handle %p fstat failed: %s", __func__,
|
||||
handle, strerror(errno));
|
||||
g_message ("%s: handle %p fstat failed: %s", __func__,
|
||||
handle, strerror(errno));
|
||||
#endif
|
||||
|
||||
_wapi_set_last_error_from_errno ();
|
||||
@@ -685,20 +691,20 @@ static guint32 file_getfilesize(gpointer handle, guint32 *highsize)
|
||||
}
|
||||
|
||||
#ifdef HAVE_LARGE_FILE_SUPPORT
|
||||
size=statbuf.st_size & 0xFFFFFFFF;
|
||||
if(highsize!=NULL) {
|
||||
*highsize=statbuf.st_size>>32;
|
||||
size = statbuf.st_size & 0xFFFFFFFF;
|
||||
if (highsize != NULL) {
|
||||
*highsize = statbuf.st_size>>32;
|
||||
}
|
||||
#else
|
||||
if(highsize!=NULL) {
|
||||
if (highsize != NULL) {
|
||||
/* Accurate, but potentially dodgy :-) */
|
||||
*highsize=0;
|
||||
*highsize = 0;
|
||||
}
|
||||
size=statbuf.st_size;
|
||||
size = statbuf.st_size;
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message("%s: Returning size %d/%d", __func__, size, *highsize);
|
||||
g_message ("%s: Returning size %d/%d", __func__, size, *highsize);
|
||||
#endif
|
||||
|
||||
return(size);
|
||||
@@ -3512,7 +3518,14 @@ static gboolean _wapi_lock_file_region (int fd, off_t offset, off_t length)
|
||||
* if locks are not available (NFS for example),
|
||||
* ignore the error
|
||||
*/
|
||||
if (errno == ENOLCK) {
|
||||
if (errno == ENOLCK
|
||||
#ifdef EOPNOTSUPP
|
||||
|| errno == EOPNOTSUPP
|
||||
#endif
|
||||
#ifdef ENOTSUP
|
||||
|| errno == ENOTSUP
|
||||
#endif
|
||||
) {
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
@@ -3542,6 +3555,21 @@ static gboolean _wapi_unlock_file_region (int fd, off_t offset, off_t length)
|
||||
#endif
|
||||
|
||||
if (ret == -1) {
|
||||
/*
|
||||
* if locks are not available (NFS for example),
|
||||
* ignore the error
|
||||
*/
|
||||
if (errno == ENOLCK
|
||||
#ifdef EOPNOTSUPP
|
||||
|| errno == EOPNOTSUPP
|
||||
#endif
|
||||
#ifdef ENOTSUP
|
||||
|| errno == ENOTSUP
|
||||
#endif
|
||||
) {
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
SetLastError (ERROR_LOCK_VIOLATION);
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
+8
-11
@@ -298,7 +298,6 @@ static gboolean namedmutex_check (gpointer handle, gpointer user_data)
|
||||
gboolean ok;
|
||||
struct mutex_check_data *data = (struct mutex_check_data *)user_data;
|
||||
int thr_ret;
|
||||
guint32 now;
|
||||
|
||||
ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX,
|
||||
(gpointer *)&mutex_handle);
|
||||
@@ -308,7 +307,7 @@ static gboolean namedmutex_check (gpointer handle, gpointer user_data)
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
thr_ret = _wapi_handle_shared_lock_handle (handle, &now);
|
||||
thr_ret = _wapi_handle_lock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
if (mutex_handle->pid == data->pid &&
|
||||
@@ -324,7 +323,7 @@ static gboolean namedmutex_check (gpointer handle, gpointer user_data)
|
||||
_wapi_shared_handle_set_signal_state (handle, TRUE);
|
||||
}
|
||||
|
||||
_wapi_handle_shared_unlock_handle (handle, now);
|
||||
_wapi_handle_unlock_shared_handles ();
|
||||
|
||||
/* Return false to keep searching */
|
||||
return(FALSE);
|
||||
@@ -397,15 +396,14 @@ static gpointer namedmutex_create (WapiSecurityAttributes *security G_GNUC_UNUSE
|
||||
gchar *utf8_name;
|
||||
int thr_ret;
|
||||
gpointer ret = NULL;
|
||||
guint32 now = (guint32)(time(NULL) & 0xFFFFFFFF), locknow;
|
||||
guint32 namelen;
|
||||
gint32 offset;
|
||||
|
||||
/* w32 seems to guarantee that opening named mutexes can't
|
||||
* race each other
|
||||
*/
|
||||
pthread_cleanup_push ((void(*)(void *))_wapi_namespace_timestamp_release, GUINT_TO_POINTER(now));
|
||||
thr_ret = _wapi_namespace_timestamp (now);
|
||||
pthread_cleanup_push ((void(*)(void *))_wapi_namespace_unlock, NULL);
|
||||
thr_ret = _wapi_namespace_lock ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
/* Need to blow away any old errors here, because code tests
|
||||
@@ -469,7 +467,7 @@ static gpointer namedmutex_create (WapiSecurityAttributes *security G_GNUC_UNUSE
|
||||
/* Set the initial state, as this is a completely new
|
||||
* handle
|
||||
*/
|
||||
thr_ret = _wapi_handle_shared_lock_handle (handle, &locknow);
|
||||
thr_ret = _wapi_handle_lock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
if (owned == TRUE) {
|
||||
@@ -478,7 +476,7 @@ static gpointer namedmutex_create (WapiSecurityAttributes *security G_GNUC_UNUSE
|
||||
_wapi_shared_handle_set_signal_state (handle, TRUE);
|
||||
}
|
||||
|
||||
_wapi_handle_shared_unlock_handle (handle, locknow);
|
||||
_wapi_handle_unlock_shared_handles ();
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -588,7 +586,6 @@ static gboolean namedmutex_release (gpointer handle)
|
||||
pid_t pid=getpid ();
|
||||
int thr_ret;
|
||||
gboolean ret = FALSE;
|
||||
guint32 now;
|
||||
|
||||
ok=_wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX,
|
||||
(gpointer *)&mutex_handle);
|
||||
@@ -598,7 +595,7 @@ static gboolean namedmutex_release (gpointer handle)
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
thr_ret = _wapi_handle_shared_lock_handle (handle, &now);
|
||||
thr_ret = _wapi_handle_lock_shared_handles ();
|
||||
g_assert (thr_ret == 0);
|
||||
|
||||
#ifdef DEBUG
|
||||
@@ -628,7 +625,7 @@ static gboolean namedmutex_release (gpointer handle)
|
||||
}
|
||||
|
||||
cleanup:
|
||||
_wapi_handle_shared_unlock_handle (handle, now);
|
||||
_wapi_handle_unlock_shared_handles ();
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@@ -932,11 +932,13 @@ gboolean GetExitCodeProcess (gpointer process, guint32 *code)
|
||||
return(FALSE);
|
||||
}
|
||||
|
||||
/* A process handle is only signalled if the process has exited */
|
||||
if(_wapi_handle_issignalled (process)==TRUE) {
|
||||
*code=process_handle->exitstatus;
|
||||
/* A process handle is only signalled if the process has exited
|
||||
* and has been waited for */
|
||||
if (_wapi_handle_issignalled (process) == TRUE ||
|
||||
process_wait (process, 0) == WAIT_OBJECT_0) {
|
||||
*code = process_handle->exitstatus;
|
||||
} else {
|
||||
*code=STILL_ACTIVE;
|
||||
*code = STILL_ACTIVE;
|
||||
}
|
||||
|
||||
return(TRUE);
|
||||
|
||||
+222
-118
@@ -7,41 +7,6 @@
|
||||
* (C) 2002 Ximian, Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Code to support inter-process sharing of handles.
|
||||
*
|
||||
* I thought of using an mmap()ed file for this. If linuxthreads
|
||||
* supported PTHREAD_PROCESS_SHARED I would have done; however without
|
||||
* that pthread support the only other inter-process IPC
|
||||
* synchronisation option is a sysV semaphore, and if I'm going to use
|
||||
* that I may as well take advantage of sysV shared memory too.
|
||||
* Actually, semaphores seem to be buggy, or I was using them
|
||||
* incorrectly :-). I've replaced the sysV semaphore with a shared
|
||||
* integer controlled with Interlocked functions. And I've since
|
||||
* replaced that with a separate process to serialise access to the
|
||||
* shared memory, to avoid the possibility of DOS by leaving the
|
||||
* shared memory locked, and also to allow the shared memory to be
|
||||
* cleaned up.
|
||||
*
|
||||
* mmap() files have the advantage of avoiding namespace collisions,
|
||||
* but have the disadvantage of needing cleaning up, and also msync().
|
||||
* sysV shared memory has a really stupid way of getting random key
|
||||
* IDs, which can lead to collisions.
|
||||
*
|
||||
* Having tried sysv shm, I tested mmap() and found that MAP_SHARED
|
||||
* makes msync() irrelevent, and both types need cleaning up. Seeing
|
||||
* as mmap() doesn't suffer from the bonkers method of allocating
|
||||
* segments, it seems to be the best method.
|
||||
*
|
||||
* This shared memory is needed because w32 processes do not have the
|
||||
* POSIX parent-child relationship, so a process handle is available
|
||||
* to any other process to find out exit status. Handles are
|
||||
* destroyed when the last reference to them is closed. New handles
|
||||
* can be created for long lasting items such as processes or threads,
|
||||
* and also for named synchronisation objects so long as these haven't
|
||||
* been deleted by having the last referencing handle closed.
|
||||
*/
|
||||
|
||||
|
||||
#include <config.h>
|
||||
#include <glib.h>
|
||||
@@ -53,14 +18,17 @@
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <sys/ipc.h>
|
||||
#include <sys/sem.h>
|
||||
|
||||
#include <mono/io-layer/wapi.h>
|
||||
#include <mono/io-layer/wapi-private.h>
|
||||
#include <mono/io-layer/shared.h>
|
||||
#include <mono/io-layer/handles-private.h>
|
||||
|
||||
#undef DEBUG
|
||||
|
||||
static guchar *_wapi_shm_file (void)
|
||||
static guchar *_wapi_shm_file (_wapi_shm_t type)
|
||||
{
|
||||
static guchar file[_POSIX_PATH_MAX];
|
||||
guchar *name = NULL, *filename, *dir, *wapi_dir;
|
||||
@@ -69,53 +37,17 @@ static guchar *_wapi_shm_file (void)
|
||||
if (gethostname(machine_name, sizeof(machine_name)) != 0)
|
||||
machine_name[0] = '\0';
|
||||
|
||||
/* Change the filename whenever the format of the contents
|
||||
* changes
|
||||
*/
|
||||
name = g_strdup_printf ("shared_data-%s-%d-%d",
|
||||
machine_name, _WAPI_HANDLE_VERSION, 0);
|
||||
|
||||
/* I don't know how nfs affects mmap. If mmap() of files on
|
||||
* nfs mounts breaks, then there should be an option to set
|
||||
* the directory.
|
||||
*/
|
||||
wapi_dir = getenv ("MONO_SHARED_DIR");
|
||||
if (wapi_dir == NULL) {
|
||||
filename = g_build_filename (g_get_home_dir (), ".wapi", name,
|
||||
NULL);
|
||||
} else {
|
||||
filename = g_build_filename (wapi_dir, ".wapi", name, NULL);
|
||||
}
|
||||
g_free (name);
|
||||
|
||||
g_snprintf (file, _POSIX_PATH_MAX, "%s", filename);
|
||||
g_free (filename);
|
||||
switch (type) {
|
||||
case WAPI_SHM_DATA:
|
||||
name = g_strdup_printf ("shared_data-%s-%d-%d",
|
||||
machine_name, _WAPI_HANDLE_VERSION, 0);
|
||||
break;
|
||||
|
||||
/* No need to check if the dir already exists or check
|
||||
* mkdir() errors, because on any error the open() call will
|
||||
* report the problem.
|
||||
*/
|
||||
dir = g_path_get_dirname (file);
|
||||
mkdir (dir, 0755);
|
||||
g_free (dir);
|
||||
|
||||
return(file);
|
||||
}
|
||||
|
||||
static guchar *_wapi_fileshare_shm_file (void)
|
||||
{
|
||||
static guchar file[_POSIX_PATH_MAX];
|
||||
guchar *name = NULL, *filename, *dir, *wapi_dir;
|
||||
gchar machine_name[256];
|
||||
|
||||
if (gethostname(machine_name, sizeof(machine_name)) != 0)
|
||||
machine_name[0] = '\0';
|
||||
|
||||
/* Change the filename whenever the format of the contents
|
||||
* changes
|
||||
*/
|
||||
name = g_strdup_printf ("shared_fileshare-%s-%d-%d",
|
||||
machine_name, _WAPI_HANDLE_VERSION, 0);
|
||||
case WAPI_SHM_FILESHARE:
|
||||
name = g_strdup_printf ("shared_fileshare-%s-%d-%d",
|
||||
machine_name, _WAPI_HANDLE_VERSION, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
/* I don't know how nfs affects mmap. If mmap() of files on
|
||||
* nfs mounts breaks, then there should be an option to set
|
||||
@@ -253,31 +185,41 @@ try_again:
|
||||
* Attach to the shared memory file or create it if it did not exist.
|
||||
* Returns the memory area the file was mmapped to.
|
||||
*/
|
||||
gpointer _wapi_shm_attach (void)
|
||||
gpointer _wapi_shm_attach (_wapi_shm_t type)
|
||||
{
|
||||
gpointer shm_seg;
|
||||
int fd;
|
||||
struct stat statbuf;
|
||||
guchar *filename=_wapi_shm_file ();
|
||||
guchar *filename=_wapi_shm_file (type);
|
||||
guint32 size;
|
||||
|
||||
fd=_wapi_shm_file_open (filename,
|
||||
sizeof(struct _WapiHandleSharedLayout));
|
||||
if(fd==-1) {
|
||||
switch(type) {
|
||||
case WAPI_SHM_DATA:
|
||||
size = sizeof(struct _WapiHandleSharedLayout);
|
||||
break;
|
||||
|
||||
case WAPI_SHM_FILESHARE:
|
||||
size = sizeof(struct _WapiFileShareLayout);
|
||||
break;
|
||||
}
|
||||
|
||||
fd = _wapi_shm_file_open (filename, size);
|
||||
if (fd == -1) {
|
||||
g_critical ("%s: shared file [%s] open error", __func__,
|
||||
filename);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
if(fstat (fd, &statbuf)==-1) {
|
||||
if (fstat (fd, &statbuf)==-1) {
|
||||
g_critical ("%s: fstat error: %s", __func__,
|
||||
g_strerror (errno));
|
||||
close (fd);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
shm_seg=mmap (NULL, statbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
|
||||
fd, 0);
|
||||
if(shm_seg==MAP_FAILED) {
|
||||
shm_seg = mmap (NULL, statbuf.st_size, PROT_READ|PROT_WRITE,
|
||||
MAP_SHARED, fd, 0);
|
||||
if (shm_seg == MAP_FAILED) {
|
||||
g_critical ("%s: mmap error: %s", __func__,
|
||||
g_strerror (errno));
|
||||
close (fd);
|
||||
@@ -288,36 +230,198 @@ gpointer _wapi_shm_attach (void)
|
||||
return(shm_seg);
|
||||
}
|
||||
|
||||
gpointer _wapi_fileshare_shm_attach (void)
|
||||
void _wapi_shm_semaphores_init ()
|
||||
{
|
||||
gpointer shm_seg;
|
||||
int fd;
|
||||
struct stat statbuf;
|
||||
guchar *filename=_wapi_fileshare_shm_file ();
|
||||
key_t key = ftok (_wapi_shm_file (WAPI_SHM_DATA), 'M');
|
||||
key_t oldkey;
|
||||
|
||||
/* Yet more barmy API - this union is a well-defined parameter
|
||||
* in a syscall, yet I still have to define it here as it
|
||||
* doesn't appear in a header
|
||||
*/
|
||||
union semun {
|
||||
int val;
|
||||
struct semid_ds *buf;
|
||||
ushort *array;
|
||||
} defs;
|
||||
ushort def_vals[_WAPI_SHARED_SEM_COUNT];
|
||||
int i;
|
||||
int retries = 0;
|
||||
|
||||
fd=_wapi_shm_file_open (filename, sizeof(struct _WapiFileShareLayout));
|
||||
if(fd==-1) {
|
||||
g_critical ("%s: shared file [%s] open error", __func__,
|
||||
filename);
|
||||
return(NULL);
|
||||
for (i = 0; i < _WAPI_SHARED_SEM_COUNT; i++) {
|
||||
def_vals[i] = 1;
|
||||
}
|
||||
defs.array = def_vals;
|
||||
|
||||
if(fstat (fd, &statbuf)==-1) {
|
||||
g_critical ("%s: fstat error: %s", __func__,
|
||||
g_strerror (errno));
|
||||
close (fd);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
shm_seg=mmap (NULL, statbuf.st_size, PROT_READ|PROT_WRITE, MAP_SHARED,
|
||||
fd, 0);
|
||||
if(shm_seg==MAP_FAILED) {
|
||||
g_critical ("%s: mmap error: %s", __func__,
|
||||
g_strerror (errno));
|
||||
close (fd);
|
||||
return(NULL);
|
||||
}
|
||||
again:
|
||||
retries++;
|
||||
oldkey = _wapi_shared_layout->sem_key;
|
||||
|
||||
if (oldkey == 0) {
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: Creating with new key (0x%x)", __func__, key);
|
||||
#endif
|
||||
|
||||
/* The while loop attempts to make some sense of the
|
||||
* bonkers 'think of a random number' method of
|
||||
* picking a key without collision with other
|
||||
* applications
|
||||
*/
|
||||
while ((_wapi_sem_id = semget (key, _WAPI_SHARED_SEM_COUNT,
|
||||
IPC_CREAT | IPC_EXCL | 0600)) == -1) {
|
||||
if (errno != EEXIST) {
|
||||
if (retries > 3)
|
||||
g_warning ("%s: semget error: %s key 0x%x - trying again", __func__,
|
||||
g_strerror (errno), key);
|
||||
}
|
||||
|
||||
key++;
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: Got (%s), trying with new key (0x%x)",
|
||||
__func__, g_strerror (errno), key);
|
||||
#endif
|
||||
}
|
||||
/* Got a semaphore array, so initialise it and install
|
||||
* the key into the shared memory
|
||||
*/
|
||||
|
||||
close (fd);
|
||||
return(shm_seg);
|
||||
if (semctl (_wapi_sem_id, 0, SETALL, defs) == -1) {
|
||||
if (retries > 3)
|
||||
g_warning ("%s: semctl init error: %s - trying again", __func__, g_strerror (errno));
|
||||
|
||||
/* Something went horribly wrong, so try
|
||||
* getting a new set from scratch
|
||||
*/
|
||||
semctl (_wapi_sem_id, 0, IPC_RMID);
|
||||
goto again;
|
||||
}
|
||||
|
||||
if (InterlockedCompareExchange (&_wapi_shared_layout->sem_key,
|
||||
key, 0) != 0) {
|
||||
/* Someone else created one and installed the
|
||||
* key while we were working, so delete the
|
||||
* array we created and fall through to the
|
||||
* 'key already known' case.
|
||||
*/
|
||||
semctl (_wapi_sem_id, 0, IPC_RMID);
|
||||
oldkey = _wapi_shared_layout->sem_key;
|
||||
} else {
|
||||
/* We've installed this semaphore set's key into
|
||||
* the shared memory
|
||||
*/
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: Trying with old key 0x%x", __func__, oldkey);
|
||||
#endif
|
||||
|
||||
_wapi_sem_id = semget (oldkey, _WAPI_SHARED_SEM_COUNT, 0600);
|
||||
if (_wapi_sem_id == -1) {
|
||||
if (retries > 3)
|
||||
g_warning ("%s: semget error opening old key 0x%x (%s) - trying again",
|
||||
__func__, oldkey,g_strerror (errno));
|
||||
|
||||
/* Someone must have deleted the semaphore set, so
|
||||
* blow away the bad key and try again
|
||||
*/
|
||||
InterlockedCompareExchange (&_wapi_shared_layout->sem_key, 0,
|
||||
oldkey);
|
||||
|
||||
goto again;
|
||||
}
|
||||
}
|
||||
|
||||
int _wapi_shm_sem_lock (int sem)
|
||||
{
|
||||
struct sembuf ops;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: locking sem %d", __func__, sem);
|
||||
#endif
|
||||
|
||||
ops.sem_num = sem;
|
||||
ops.sem_op = -1;
|
||||
ops.sem_flg = SEM_UNDO;
|
||||
|
||||
do {
|
||||
ret = semop (_wapi_sem_id, &ops, 1);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
if (ret == -1) {
|
||||
/* Turn this into a pthreads-style return value */
|
||||
ret = errno;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning %d (%s)", __func__, ret, g_strerror (ret));
|
||||
#endif
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int _wapi_shm_sem_trylock (int sem)
|
||||
{
|
||||
struct sembuf ops;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: trying to lock sem %d", __func__, sem);
|
||||
#endif
|
||||
|
||||
ops.sem_num = sem;
|
||||
ops.sem_op = -1;
|
||||
ops.sem_flg = IPC_NOWAIT | SEM_UNDO;
|
||||
|
||||
do {
|
||||
ret = semop (_wapi_sem_id, &ops, 1);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
if (ret == -1) {
|
||||
/* Turn this into a pthreads-style return value */
|
||||
ret = errno;
|
||||
}
|
||||
|
||||
if (ret == EAGAIN) {
|
||||
/* But pthreads uses this code instead */
|
||||
ret = EBUSY;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning %d (%s)", __func__, ret, g_strerror (ret));
|
||||
#endif
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
int _wapi_shm_sem_unlock (int sem)
|
||||
{
|
||||
struct sembuf ops;
|
||||
int ret;
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: unlocking sem %d", __func__, sem);
|
||||
#endif
|
||||
|
||||
ops.sem_num = sem;
|
||||
ops.sem_op = 1;
|
||||
ops.sem_flg = SEM_UNDO;
|
||||
|
||||
do {
|
||||
ret = semop (_wapi_sem_id, &ops, 1);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
if (ret == -1) {
|
||||
/* Turn this into a pthreads-style return value */
|
||||
ret = errno;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
g_message ("%s: returning %d (%s)", __func__, ret, g_strerror (ret));
|
||||
#endif
|
||||
|
||||
return(ret);
|
||||
}
|
||||
|
||||
+10
-2
@@ -12,7 +12,15 @@
|
||||
|
||||
#include <mono/io-layer/wapi-private.h>
|
||||
|
||||
extern gpointer _wapi_shm_attach (void);
|
||||
extern gpointer _wapi_fileshare_shm_attach (void);
|
||||
typedef enum {
|
||||
WAPI_SHM_DATA,
|
||||
WAPI_SHM_FILESHARE
|
||||
} _wapi_shm_t;
|
||||
|
||||
extern gpointer _wapi_shm_attach (_wapi_shm_t type);
|
||||
extern void _wapi_shm_semaphores_init (void);
|
||||
extern int _wapi_shm_sem_lock (int sem);
|
||||
extern int _wapi_shm_sem_trylock (int sem);
|
||||
extern int _wapi_shm_sem_unlock (int sem);
|
||||
|
||||
#endif /* _WAPI_SHARED_H_ */
|
||||
+29
-5
@@ -392,7 +392,9 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
|
||||
{
|
||||
gpointer handle = GUINT_TO_POINTER (fd);
|
||||
int ret;
|
||||
|
||||
struct timeval tv;
|
||||
void *tmp_val;
|
||||
|
||||
if (startup_count == 0) {
|
||||
WSASetLastError (WSANOTINITIALISED);
|
||||
return(SOCKET_ERROR);
|
||||
@@ -402,8 +404,14 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
|
||||
WSASetLastError (WSAENOTSOCK);
|
||||
return(SOCKET_ERROR);
|
||||
}
|
||||
|
||||
ret = getsockopt (fd, level, optname, optval, optlen);
|
||||
|
||||
tmp_val = optval;
|
||||
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
|
||||
tmp_val = &tv;
|
||||
*optlen = sizeof (tv);
|
||||
}
|
||||
|
||||
ret = getsockopt (fd, level, optname, tmp_val, optlen);
|
||||
if (ret == -1) {
|
||||
gint errnum = errno;
|
||||
#ifdef DEBUG
|
||||
@@ -416,6 +424,11 @@ int _wapi_getsockopt(guint32 fd, int level, int optname, void *optval,
|
||||
|
||||
return(SOCKET_ERROR);
|
||||
}
|
||||
|
||||
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
|
||||
*((int *) optval) = tv.tv_sec * 1000 + tv.tv_usec;
|
||||
*optlen = sizeof (int);
|
||||
}
|
||||
|
||||
return(ret);
|
||||
}
|
||||
@@ -601,6 +614,8 @@ int _wapi_setsockopt(guint32 fd, int level, int optname,
|
||||
{
|
||||
gpointer handle = GUINT_TO_POINTER (fd);
|
||||
int ret;
|
||||
const void *tmp_val;
|
||||
struct timeval tv;
|
||||
|
||||
if (startup_count == 0) {
|
||||
WSASetLastError (WSANOTINITIALISED);
|
||||
@@ -611,8 +626,17 @@ int _wapi_setsockopt(guint32 fd, int level, int optname,
|
||||
WSASetLastError (WSAENOTSOCK);
|
||||
return(SOCKET_ERROR);
|
||||
}
|
||||
|
||||
ret = setsockopt (fd, level, optname, optval, optlen);
|
||||
|
||||
tmp_val = optval;
|
||||
if (optname == SO_RCVTIMEO || optname == SO_SNDTIMEO) {
|
||||
int ms = *((int *) optval);
|
||||
tv.tv_sec = ms / 1000;
|
||||
tv.tv_usec = ms % 1000;
|
||||
tmp_val = &tv;
|
||||
optlen = sizeof (tv);
|
||||
}
|
||||
|
||||
ret = setsockopt (fd, level, optname, tmp_val, optlen);
|
||||
if (ret == -1) {
|
||||
gint errnum = errno;
|
||||
#ifdef DEBUG
|
||||
|
||||
+6
-11
@@ -25,10 +25,9 @@
|
||||
static gboolean own_if_signalled(gpointer handle)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint32 now = (guint32)(time (NULL) & 0xFFFFFFFF);
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
if (_wapi_handle_shared_trylock_handle (handle, now) == EBUSY) {
|
||||
if (_wapi_handle_trylock_shared_handles () == EBUSY) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@@ -39,7 +38,7 @@ static gboolean own_if_signalled(gpointer handle)
|
||||
}
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
_wapi_handle_shared_unlock_handle (handle, now);
|
||||
_wapi_handle_unlock_shared_handles ();
|
||||
}
|
||||
|
||||
return(ret);
|
||||
@@ -48,10 +47,9 @@ static gboolean own_if_signalled(gpointer handle)
|
||||
static gboolean own_if_owned(gpointer handle)
|
||||
{
|
||||
gboolean ret = FALSE;
|
||||
guint32 now = (guint32)(time (NULL) & 0xFFFFFFFF);
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
if (_wapi_handle_shared_trylock_handle (handle, now) == EBUSY) {
|
||||
if (_wapi_handle_trylock_shared_handles () == EBUSY) {
|
||||
return (FALSE);
|
||||
}
|
||||
}
|
||||
@@ -62,7 +60,7 @@ static gboolean own_if_owned(gpointer handle)
|
||||
}
|
||||
|
||||
if (_WAPI_SHARED_HANDLE (_wapi_handle_type (handle))) {
|
||||
_wapi_handle_shared_unlock_handle (handle, now);
|
||||
_wapi_handle_unlock_shared_handles ();
|
||||
}
|
||||
|
||||
return(ret);
|
||||
@@ -412,15 +410,13 @@ struct handle_cleanup_data
|
||||
{
|
||||
guint32 numobjects;
|
||||
gpointer *handles;
|
||||
guint32 now;
|
||||
};
|
||||
|
||||
static void handle_cleanup (void *data)
|
||||
{
|
||||
struct handle_cleanup_data *handles = (struct handle_cleanup_data *)data;
|
||||
|
||||
_wapi_handle_unlock_handles (handles->numobjects, handles->handles,
|
||||
handles->now);
|
||||
_wapi_handle_unlock_handles (handles->numobjects, handles->handles);
|
||||
}
|
||||
|
||||
static gboolean test_and_own (guint32 numobjects, gpointer *handles,
|
||||
@@ -439,8 +435,7 @@ static gboolean test_and_own (guint32 numobjects, gpointer *handles,
|
||||
|
||||
pthread_cleanup_push (handle_cleanup, (void *)&cleanup_data);
|
||||
done = _wapi_handle_count_signalled_handles (numobjects, handles,
|
||||
waitall, count, lowest,
|
||||
&cleanup_data.now);
|
||||
waitall, count, lowest);
|
||||
if (done == TRUE) {
|
||||
if (waitall == TRUE) {
|
||||
for (i = 0; i < numobjects; i++) {
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
/* Increment this whenever an incompatible change is made to the
|
||||
* shared handle structure.
|
||||
*/
|
||||
#define _WAPI_HANDLE_VERSION 5
|
||||
#define _WAPI_HANDLE_VERSION 6
|
||||
|
||||
typedef enum {
|
||||
WAPI_HANDLE_UNUSED=0,
|
||||
@@ -142,7 +142,6 @@ struct _WapiHandleSharedMetadata
|
||||
volatile guint32 offset;
|
||||
guint32 timestamp;
|
||||
volatile gboolean signalled;
|
||||
volatile guint32 checking;
|
||||
};
|
||||
|
||||
struct _WapiHandleShared
|
||||
@@ -161,13 +160,17 @@ struct _WapiHandleShared
|
||||
} u;
|
||||
};
|
||||
|
||||
#define _WAPI_SHARED_SEM_NAMESPACE 0
|
||||
#define _WAPI_SHARED_SEM_COLLECTION 1
|
||||
#define _WAPI_SHARED_SEM_SHARE 2
|
||||
#define _WAPI_SHARED_SEM_HANDLE 3
|
||||
#define _WAPI_SHARED_SEM_COUNT 8 /* Leave some future expansion space */
|
||||
|
||||
struct _WapiHandleSharedLayout
|
||||
{
|
||||
guint32 namespace_check;
|
||||
volatile guint32 signal_count;
|
||||
|
||||
guint32 master_timestamp;
|
||||
volatile guint32 collection_count;
|
||||
volatile key_t sem_key;
|
||||
|
||||
struct _WapiHandleSharedMetadata metadata[_WAPI_HANDLE_INITIAL_COUNT];
|
||||
struct _WapiHandleShared handles[_WAPI_HANDLE_INITIAL_COUNT];
|
||||
@@ -188,7 +191,6 @@ struct _WapiFileShare
|
||||
|
||||
struct _WapiFileShareLayout
|
||||
{
|
||||
guint32 share_check;
|
||||
guint32 hwm;
|
||||
|
||||
struct _WapiFileShare share_info[_WAPI_FILESHARE_SIZE];
|
||||
|
||||
@@ -1,3 +1,62 @@
|
||||
2005-06-20 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* domain.c:
|
||||
* appdomain.c:
|
||||
* domain-internals.h:
|
||||
* reflection.c: 'domain_assemblies' field is now protected by its own
|
||||
lock. Don't call into managed code to run the AssemblyLoad event if we
|
||||
now there are no registered delegates for it.
|
||||
|
||||
Wed Jun 8 19:26:38 CEST 2005 Paolo Molaro <[email protected]>
|
||||
|
||||
* object.c: add proper locking in mono_remote_class_vtable(),
|
||||
fixes possible memory corruption.
|
||||
|
||||
2005-06-06 Michael Meeks <[email protected]>
|
||||
|
||||
* object.c (extend_interface_array): fix really silly
|
||||
memory corrupting / comparison bug.
|
||||
|
||||
2005-05-12 Martin Baulig <[email protected]>
|
||||
|
||||
* mono-debug-debugger.cs (mono_debugger_lock/unlock): Always lock
|
||||
here and use the loader lock.
|
||||
|
||||
* mono-debug.c: Properly lock when the debugger is not attached.
|
||||
(mono_debug_init): Release the initial lock if we're not running
|
||||
in the debugger.
|
||||
|
||||
2005-05-11 Martin Baulig <[email protected]>
|
||||
|
||||
* mono-debug.h (MonoSymbolTable, MonoDebugMethodAddress): Changed
|
||||
to order of some fields to get proper alignment on 64-bit machines.
|
||||
|
||||
2005-05-11 Martin Baulig <[email protected]>
|
||||
|
||||
* mono-debug.c, mono-debug-debugger.c: Revert Paolo's locking
|
||||
changes as they're broken and completely fuck up the debugger.
|
||||
|
||||
* mono-debug.c (mono_debug_add_method): Properly unlock on error.
|
||||
|
||||
2005-05-07 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* metadata/socket-io.c: on windows, getsockopt/setsockopt for
|
||||
send/receive timeout use an integer in milliseconds. We were using a
|
||||
struct timeval.
|
||||
|
||||
2005-05-05 Zoltan Varga <[email protected]>
|
||||
|
||||
* assembly.c (mono_assembly_load_reference): Fix warning.
|
||||
|
||||
2005-05-04 Gonzalo Paniagua Javier <[email protected]>
|
||||
|
||||
* threadpool.c: changed the default number of threads per cpu. From now
|
||||
on, the default will be 20 + (5 * number of cpus) instead of 50.
|
||||
|
||||
2005-05-04 Zoltan Varga <[email protected]>
|
||||
|
||||
* loader.c (mono_method_get_signature_full): Add locking here.
|
||||
|
||||
2005-05-03 Lluis Sanchez Gual <[email protected]>
|
||||
|
||||
* appdomain.c: Moved methods for parsing and freeing assembly
|
||||
|
||||
+29
-17
@@ -440,11 +440,11 @@ ves_icall_System_AppDomain_createDomain (MonoString *friendly_name, MonoAppDomai
|
||||
mono_context_init (data);
|
||||
|
||||
/* The new appdomain should have all assemblies loaded */
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
/*g_print ("copy assemblies from domain %p (%s)\n", domain, domain->friendly_name);*/
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next)
|
||||
add_assemblies_to_domain (data, tmp->data, NULL);
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return ad;
|
||||
}
|
||||
@@ -467,7 +467,7 @@ ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad, MonoBoolean refonly
|
||||
|
||||
count = 0;
|
||||
/* Need to skip internal assembly builders created by remoting */
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
if (refonly && !ass->ref_only)
|
||||
@@ -486,7 +486,7 @@ ves_icall_System_AppDomain_GetAssemblies (MonoAppDomain *ad, MonoBoolean refonly
|
||||
mono_array_set (res, gpointer, i, mono_assembly_get_object (domain, ass));
|
||||
++i;
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return res;
|
||||
}
|
||||
@@ -517,7 +517,7 @@ try_assembly_resolve (MonoDomain *domain, MonoString *fname, gboolean refonly)
|
||||
}
|
||||
|
||||
/*
|
||||
* LOCKING: assumes domain is already locked.
|
||||
* LOCKING: assumes assemblies_lock in the domain is already locked.
|
||||
*/
|
||||
static void
|
||||
add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
|
||||
@@ -558,10 +558,12 @@ add_assemblies_to_domain (MonoDomain *domain, MonoAssembly *ass, GHashTable *ht)
|
||||
static void
|
||||
mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
|
||||
{
|
||||
static MonoClassField *assembly_load_field;
|
||||
static MonoMethod *assembly_load_method;
|
||||
MonoDomain *domain = mono_domain_get ();
|
||||
MonoReflectionAssembly *ref_assembly;
|
||||
MonoClass *klass;
|
||||
MonoMethod *method;
|
||||
gpointer load_value;
|
||||
void *params [1];
|
||||
|
||||
if (!domain->domain)
|
||||
@@ -570,21 +572,31 @@ mono_domain_fire_assembly_load (MonoAssembly *assembly, gpointer user_data)
|
||||
|
||||
klass = domain->domain->mbr.obj.vtable->klass;
|
||||
|
||||
method = mono_class_get_method_from_name (klass, "DoAssemblyLoad", -1);
|
||||
if (method == NULL) {
|
||||
g_warning ("Method AppDomain.DoAssemblyLoad not found.\n");
|
||||
return;
|
||||
mono_domain_assemblies_lock (domain);
|
||||
add_assemblies_to_domain (domain, assembly, NULL);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
if (assembly_load_field == NULL) {
|
||||
assembly_load_field = mono_class_get_field_from_name (klass, "AssemblyLoad");
|
||||
g_assert (assembly_load_field);
|
||||
}
|
||||
|
||||
mono_domain_lock (domain);
|
||||
add_assemblies_to_domain (domain, assembly, NULL);
|
||||
mono_domain_unlock (domain);
|
||||
mono_field_get_value (domain->domain, assembly_load_field, &load_value);
|
||||
if (load_value == NULL) {
|
||||
/* No events waiting to be triggered */
|
||||
return;
|
||||
}
|
||||
|
||||
ref_assembly = mono_assembly_get_object (domain, assembly);
|
||||
g_assert (ref_assembly);
|
||||
|
||||
if (assembly_load_method == NULL) {
|
||||
assembly_load_method = mono_class_get_method_from_name (klass, "DoAssemblyLoad", -1);
|
||||
g_assert (assembly_load_method);
|
||||
}
|
||||
|
||||
*params = ref_assembly;
|
||||
mono_runtime_invoke (method, domain->domain, params, NULL);
|
||||
mono_runtime_invoke (assembly_load_method, domain->domain, params, NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
@@ -852,17 +864,17 @@ mono_domain_assembly_search (MonoAssemblyName *aname,
|
||||
MonoAssembly *ass;
|
||||
gboolean refonly = GPOINTER_TO_UINT (user_data);
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
/* Dynamic assemblies can't match here in MS.NET */
|
||||
if (ass->dynamic || refonly != ass->ref_only || !mono_assembly_names_equal (aname, &ass->aname))
|
||||
continue;
|
||||
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
return ass;
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -128,6 +128,8 @@ struct _MonoDomain {
|
||||
* if the hashtable contains a GC visible reference to them.
|
||||
*/
|
||||
GHashTable *finalizable_objects_hash;
|
||||
/* Used when accessing 'domain_assemblies' */
|
||||
CRITICAL_SECTION assemblies_lock;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
@@ -143,6 +145,8 @@ typedef struct {
|
||||
|
||||
#define mono_domain_lock(domain) EnterCriticalSection(&(domain)->lock)
|
||||
#define mono_domain_unlock(domain) LeaveCriticalSection(&(domain)->lock)
|
||||
#define mono_domain_assemblies_lock(domain) EnterCriticalSection(&(domain)->assemblies_lock)
|
||||
#define mono_domain_assemblies_unlock(domain) LeaveCriticalSection(&(domain)->assemblies_lock)
|
||||
|
||||
void
|
||||
mono_jit_info_table_add (MonoDomain *domain, MonoJitInfo *ji);
|
||||
|
||||
@@ -312,6 +312,7 @@ mono_domain_create (void)
|
||||
domain->jit_trampoline_hash = g_hash_table_new (mono_aligned_addr_hash, NULL);
|
||||
|
||||
InitializeCriticalSection (&domain->lock);
|
||||
InitializeCriticalSection (&domain->assemblies_lock);
|
||||
|
||||
EnterCriticalSection (&appdomains_mutex);
|
||||
domain_id_alloc (domain);
|
||||
@@ -738,15 +739,15 @@ mono_domain_assembly_open (MonoDomain *domain, const char *name)
|
||||
MonoAssembly *ass;
|
||||
GSList *tmp;
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
for (tmp = domain->domain_assemblies; tmp; tmp = tmp->next) {
|
||||
ass = tmp->data;
|
||||
if (strcmp (name, ass->aname.name) == 0) {
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
return ass;
|
||||
}
|
||||
}
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
if (!(ass = mono_assembly_open (name, NULL)))
|
||||
return NULL;
|
||||
@@ -856,6 +857,7 @@ mono_domain_free (MonoDomain *domain, gboolean force)
|
||||
g_hash_table_destroy (domain->special_static_fields);
|
||||
domain->special_static_fields = NULL;
|
||||
}
|
||||
DeleteCriticalSection (&domain->assemblies_lock);
|
||||
DeleteCriticalSection (&domain->lock);
|
||||
domain->setup = NULL;
|
||||
|
||||
|
||||
+16
-3
@@ -247,7 +247,7 @@ mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 to
|
||||
int table = mono_metadata_token_table (token);
|
||||
int idx = mono_metadata_token_index (token);
|
||||
guint32 cols [MONO_MEMBERREF_SIZE];
|
||||
MonoMethodSignature *sig;
|
||||
MonoMethodSignature *sig, *prev_sig;
|
||||
const char *ptr;
|
||||
|
||||
/* !table is for wrappers: we should really assign their own token to them */
|
||||
@@ -270,13 +270,26 @@ mono_method_get_signature_full (MonoMethod *method, MonoImage *image, guint32 to
|
||||
/* FIXME: This might be incorrect for vararg methods */
|
||||
return mono_method_signature (method);
|
||||
|
||||
if (!(sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (token)))) {
|
||||
mono_loader_lock ();
|
||||
sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (token));
|
||||
mono_loader_unlock ();
|
||||
if (!sig) {
|
||||
mono_metadata_decode_row (&image->tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
|
||||
|
||||
ptr = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
|
||||
mono_metadata_decode_blob_size (ptr, &ptr);
|
||||
sig = mono_metadata_parse_method_signature_full (image, context, 0, ptr, NULL);
|
||||
g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (token), sig);
|
||||
|
||||
mono_loader_lock ();
|
||||
prev_sig = g_hash_table_lookup (image->memberref_signatures, GUINT_TO_POINTER (token));
|
||||
if (prev_sig) {
|
||||
/* Somebody got in before us */
|
||||
/* FIXME: Free sig */
|
||||
sig = prev_sig;
|
||||
}
|
||||
else
|
||||
g_hash_table_insert (image->memberref_signatures, GUINT_TO_POINTER (token), sig);
|
||||
mono_loader_unlock ();
|
||||
}
|
||||
|
||||
sig = mono_class_inflate_generic_signature (image, sig, context);
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
static guint32 debugger_lock_level = 0;
|
||||
static CRITICAL_SECTION debugger_lock_mutex;
|
||||
static gboolean must_reload_symtabs = FALSE;
|
||||
static gboolean mono_debugger_initialized = FALSE;
|
||||
static gboolean mono_debugger_use_debugger = FALSE;
|
||||
static MonoObject *last_exception = NULL;
|
||||
|
||||
struct _MonoDebuggerMetadataInfo {
|
||||
@@ -68,11 +68,6 @@ MonoDebuggerIOLayer mono_debugger_io_layer = {
|
||||
void
|
||||
mono_debugger_lock (void)
|
||||
{
|
||||
if (!mono_debugger_initialized) {
|
||||
debugger_lock_level++;
|
||||
return;
|
||||
}
|
||||
|
||||
EnterCriticalSection (&debugger_lock_mutex);
|
||||
debugger_lock_level++;
|
||||
}
|
||||
@@ -80,15 +75,8 @@ mono_debugger_lock (void)
|
||||
void
|
||||
mono_debugger_unlock (void)
|
||||
{
|
||||
g_assert (debugger_lock_level > 0);
|
||||
|
||||
if (!mono_debugger_initialized) {
|
||||
debugger_lock_level--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (debugger_lock_level == 1) {
|
||||
if (must_reload_symtabs) {
|
||||
if (must_reload_symtabs && mono_debugger_use_debugger) {
|
||||
mono_debugger_event (MONO_DEBUGGER_EVENT_RELOAD_SYMTABS, 0, 0);
|
||||
must_reload_symtabs = FALSE;
|
||||
}
|
||||
@@ -99,20 +87,20 @@ mono_debugger_unlock (void)
|
||||
}
|
||||
|
||||
void
|
||||
mono_debugger_initialize (void)
|
||||
mono_debugger_initialize (gboolean use_debugger)
|
||||
{
|
||||
MONO_GC_REGISTER_ROOT (last_exception);
|
||||
|
||||
g_assert (!mono_debugger_initialized);
|
||||
g_assert (!mono_debugger_use_debugger);
|
||||
|
||||
InitializeCriticalSection (&debugger_lock_mutex);
|
||||
mono_debugger_initialized = TRUE;
|
||||
mono_debugger_use_debugger = use_debugger;
|
||||
}
|
||||
|
||||
void
|
||||
mono_debugger_add_symbol_file (MonoDebugHandle *handle)
|
||||
{
|
||||
g_assert (mono_debugger_initialized);
|
||||
g_assert (mono_debugger_use_debugger);
|
||||
|
||||
mono_debugger_lock ();
|
||||
mono_debugger_event (MONO_DEBUGGER_EVENT_ADD_MODULE, GPOINTER_TO_UINT (handle), 0);
|
||||
@@ -313,7 +301,7 @@ mono_debugger_breakpoint_callback (MonoMethod *method, guint32 index)
|
||||
gboolean
|
||||
mono_debugger_unhandled_exception (gpointer addr, gpointer stack, MonoObject *exc)
|
||||
{
|
||||
if (!mono_debugger_initialized)
|
||||
if (!mono_debugger_use_debugger)
|
||||
return FALSE;
|
||||
|
||||
// Prevent the object from being finalized.
|
||||
@@ -328,7 +316,7 @@ mono_debugger_handle_exception (gpointer addr, gpointer stack, MonoObject *exc)
|
||||
{
|
||||
MonoDebuggerExceptionInfo info;
|
||||
|
||||
if (!mono_debugger_initialized)
|
||||
if (!mono_debugger_use_debugger)
|
||||
return;
|
||||
|
||||
// Prevent the object from being finalized.
|
||||
@@ -347,7 +335,7 @@ mono_debugger_throw_exception (gpointer addr, gpointer stack, MonoObject *exc)
|
||||
{
|
||||
MonoDebuggerExceptionInfo info;
|
||||
|
||||
if (!mono_debugger_initialized)
|
||||
if (!mono_debugger_use_debugger)
|
||||
return FALSE;
|
||||
|
||||
// Prevent the object from being finalized.
|
||||
@@ -406,9 +394,6 @@ mono_debugger_runtime_invoke (MonoMethod *method, void *obj, void **params, Mono
|
||||
MonoObject *retval;
|
||||
gchar *message;
|
||||
|
||||
// g_message (G_STRLOC ": %p - %p - %p - %p", method, obj, params, exc);
|
||||
// g_message (G_STRLOC ": %s.%s", method->klass->name, method->name);
|
||||
|
||||
if (!strcmp (method->name, ".ctor")) {
|
||||
retval = obj = mono_object_new (mono_domain_get (), method->klass);
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ extern MonoDebuggerIOLayer mono_debugger_io_layer;
|
||||
|
||||
extern void (*mono_debugger_event_handler) (MonoDebuggerEvent event, guint64 data, guint64 arg);
|
||||
|
||||
void mono_debugger_initialize (void);
|
||||
void mono_debugger_initialize (gboolean use_debugger);
|
||||
void mono_debugger_cleanup (void);
|
||||
|
||||
void mono_debugger_lock (void);
|
||||
|
||||
@@ -74,8 +74,7 @@ mono_debug_init (MonoDebugFormat format)
|
||||
mono_debug_format = format;
|
||||
in_the_mono_debugger = format == MONO_DEBUG_FORMAT_DEBUGGER;
|
||||
|
||||
if (in_the_mono_debugger)
|
||||
mono_debugger_initialize ();
|
||||
mono_debugger_initialize (in_the_mono_debugger);
|
||||
|
||||
mono_debugger_lock ();
|
||||
|
||||
@@ -91,6 +90,9 @@ mono_debug_init (MonoDebugFormat format)
|
||||
mono_debugger_start_class_init_func = mono_debug_start_add_type;
|
||||
mono_debugger_class_init_func = mono_debug_add_type;
|
||||
mono_install_assembly_load_hook (mono_debug_add_assembly, NULL);
|
||||
|
||||
if (!in_the_mono_debugger)
|
||||
mono_debugger_unlock ();
|
||||
}
|
||||
|
||||
void
|
||||
@@ -450,6 +452,7 @@ mono_debug_add_method (MonoMethod *method, MonoDebugMethodJitInfo *jit, MonoDoma
|
||||
// This should only happen for very big methods, for instance
|
||||
// with more than 40.000 line numbers and more than 5.000
|
||||
// local variables.
|
||||
mono_debugger_unlock ();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ struct _MonoSymbolTable {
|
||||
/*
|
||||
* The symbol files.
|
||||
*/
|
||||
guint32 num_symbol_files;
|
||||
MonoDebugHandle **symbol_files;
|
||||
guint32 num_symbol_files;
|
||||
|
||||
/*
|
||||
* Data table.
|
||||
@@ -129,8 +129,9 @@ struct _MonoDebugMethodAddress {
|
||||
guint32 symfile_id;
|
||||
guint32 domain_id;
|
||||
guint32 method_id;
|
||||
const guint8 *code_start;
|
||||
guint32 code_size;
|
||||
guint32 dummy;
|
||||
const guint8 *code_start;
|
||||
const guint8 *wrapper_addr;
|
||||
MonoDebugMethodJitInfo *jit;
|
||||
guint8 data [MONO_ZERO_LEN_ARRAY];
|
||||
@@ -167,7 +168,7 @@ struct _MonoDebugVarInfo {
|
||||
guint32 end_scope;
|
||||
};
|
||||
|
||||
#define MONO_DEBUGGER_VERSION 49
|
||||
#define MONO_DEBUGGER_VERSION 50
|
||||
#define MONO_DEBUGGER_MAGIC 0x7aff65af4253d427ULL
|
||||
|
||||
extern MonoSymbolTable *mono_symbol_table;
|
||||
|
||||
@@ -1026,11 +1026,13 @@ extend_interface_array (MonoDomain *domain, MonoRemoteClass *remote_class, int a
|
||||
/* Extends the array of interfaces. Memory is extended using blocks of 5 pointers */
|
||||
|
||||
int current_size = ((remote_class->interface_count / 5) + 1) * 5;
|
||||
remote_class->interface_count += amount;
|
||||
int new_size;
|
||||
|
||||
if (remote_class->interface_count > current_size || remote_class->interfaces == NULL)
|
||||
remote_class->interface_count += amount;
|
||||
new_size = ((remote_class->interface_count / 5) + 1) * 5;
|
||||
|
||||
if (new_size > current_size || remote_class->interfaces == NULL)
|
||||
{
|
||||
int new_size = ((remote_class->interface_count / 5) + 1) * 5;
|
||||
MonoClass **new_array = mono_mempool_alloc (domain->mp, new_size * sizeof (MonoClass*));
|
||||
|
||||
if (remote_class->interfaces != NULL)
|
||||
@@ -1043,14 +1045,17 @@ extend_interface_array (MonoDomain *domain, MonoRemoteClass *remote_class, int a
|
||||
gpointer
|
||||
mono_remote_class_vtable (MonoDomain *domain, MonoRemoteClass *remote_class, MonoRealProxy *rp)
|
||||
{
|
||||
mono_domain_lock (domain);
|
||||
if (rp->target_domain_id != -1) {
|
||||
if (remote_class->xdomain_vtable == NULL)
|
||||
remote_class->xdomain_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_APPDOMAIN);
|
||||
mono_domain_unlock (domain);
|
||||
return remote_class->xdomain_vtable;
|
||||
}
|
||||
if (remote_class->default_vtable == NULL)
|
||||
remote_class->default_vtable = mono_class_proxy_vtable (domain, remote_class, MONO_REMOTING_TARGET_UNKNOWN);
|
||||
|
||||
mono_domain_unlock (domain);
|
||||
return remote_class->default_vtable;
|
||||
}
|
||||
|
||||
|
||||
@@ -4338,9 +4338,9 @@ mono_image_basic_init (MonoReflectionAssemblyBuilder *assemblyb)
|
||||
assembly->assembly.aname.name = image->image.name;
|
||||
assembly->assembly.image = &image->image;
|
||||
|
||||
mono_domain_lock (domain);
|
||||
mono_domain_assemblies_lock (domain);
|
||||
domain->domain_assemblies = g_slist_prepend (domain->domain_assemblies, assembly);
|
||||
mono_domain_unlock (domain);
|
||||
mono_domain_assemblies_unlock (domain);
|
||||
|
||||
register_assembly (mono_object_domain (assemblyb), &assemblyb->assembly, &assembly->assembly);
|
||||
mono_assembly_invoke_load_hook ((MonoAssembly*)assembly);
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <mono/metadata/threads.h>
|
||||
/* FIXME change this code to not mess so much with the internals */
|
||||
#include <mono/metadata/class-internals.h>
|
||||
#include <mono/metadata/threadpool-internals.h>
|
||||
|
||||
#include <sys/time.h>
|
||||
|
||||
@@ -1442,8 +1443,8 @@ void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET soc
|
||||
int valsize=sizeof(val);
|
||||
struct linger linger;
|
||||
int lingersize=sizeof(linger);
|
||||
struct timeval tv;
|
||||
int tvsize=sizeof(tv);
|
||||
int time_ms = 0;
|
||||
int time_ms_size = sizeof (time_ms);
|
||||
#ifdef SO_PEERCRED
|
||||
struct ucred cred;
|
||||
int credsize = sizeof(cred);
|
||||
@@ -1477,8 +1478,7 @@ void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET soc
|
||||
|
||||
case SocketOptionName_SendTimeout:
|
||||
case SocketOptionName_ReceiveTimeout:
|
||||
ret = _wapi_getsockopt (sock, system_level, system_name, &tv,
|
||||
&tvsize);
|
||||
ret = _wapi_getsockopt (sock, system_level, system_name, (char *) &time_ms, &time_ms_size);
|
||||
break;
|
||||
|
||||
#ifdef SO_PEERCRED
|
||||
@@ -1524,7 +1524,7 @@ void ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal(SOCKET soc
|
||||
|
||||
case SocketOptionName_SendTimeout:
|
||||
case SocketOptionName_ReceiveTimeout:
|
||||
obj = int_to_object (domain, (tv.tv_sec * 1000) + (tv.tv_usec / 1000));
|
||||
obj = int_to_object (domain, time_ms);
|
||||
break;
|
||||
|
||||
#ifdef SO_PEERCRED
|
||||
@@ -1793,19 +1793,8 @@ void ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal(SOCKET sock, g
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
switch(name) {
|
||||
case SocketOptionName_SendTimeout:
|
||||
case SocketOptionName_ReceiveTimeout: {
|
||||
struct timeval tv;
|
||||
tv.tv_sec = int_val / 1000;
|
||||
tv.tv_usec = (int_val % 1000) * 1000;
|
||||
ret = _wapi_setsockopt (sock, system_level, system_name, &tv, sizeof (tv));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ret = _wapi_setsockopt (sock, system_level, system_name, &int_val,
|
||||
sizeof(int_val));
|
||||
}
|
||||
/* ReceiveTimeout/SendTimeout get here */
|
||||
ret = _wapi_setsockopt (sock, system_level, system_name, (char *) &int_val, sizeof (int_val));
|
||||
}
|
||||
|
||||
if(ret==SOCKET_ERROR) {
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
#ifdef PLATFORM_WIN32
|
||||
#define WINVER 0x0500
|
||||
#define _WIN32_WINNT 0x0500
|
||||
#define THREADS_PER_CPU 25
|
||||
#else
|
||||
#define THREADS_PER_CPU 50
|
||||
#endif
|
||||
|
||||
#define THREADS_PER_CPU 5 /* 20 + THREADS_PER_CPU * number of CPUs */
|
||||
|
||||
#include <mono/metadata/domain-internals.h>
|
||||
#include <mono/metadata/tabledefs.h>
|
||||
#include <mono/metadata/threads.h>
|
||||
@@ -54,9 +53,9 @@
|
||||
#undef EPOLL_DEBUG
|
||||
|
||||
/* maximum number of worker threads */
|
||||
static int mono_max_worker_threads = THREADS_PER_CPU;
|
||||
static int mono_min_worker_threads = 0;
|
||||
static int mono_io_max_worker_threads = THREADS_PER_CPU * 2;
|
||||
static int mono_max_worker_threads;
|
||||
static int mono_min_worker_threads;
|
||||
static int mono_io_max_worker_threads;
|
||||
|
||||
/* current number of worker threads */
|
||||
static int mono_worker_threads = 0;
|
||||
@@ -732,6 +731,9 @@ socket_io_init (SocketIOData *data)
|
||||
g_assert (data->pipe [0] != INVALID_SOCKET);
|
||||
closesocket (srv);
|
||||
#endif
|
||||
mono_io_max_worker_threads = mono_max_worker_threads / 2;
|
||||
if (mono_io_max_worker_threads < 10)
|
||||
mono_io_max_worker_threads = 10;
|
||||
|
||||
data->sock_to_state = g_hash_table_new (g_direct_hash, g_direct_equal);
|
||||
|
||||
@@ -929,13 +931,13 @@ mono_thread_pool_init ()
|
||||
ares_htable = mono_g_hash_table_new (NULL, NULL);
|
||||
job_added = CreateSemaphore (NULL, 0, 0x7fffffff, NULL);
|
||||
GetSystemInfo (&info);
|
||||
if (getenv ("MONO_THREADS_PER_CPU") != NULL) {
|
||||
threads_per_cpu = atoi (getenv ("MONO_THREADS_PER_CPU"));
|
||||
if (g_getenv ("MONO_THREADS_PER_CPU") != NULL) {
|
||||
threads_per_cpu = atoi (g_getenv ("MONO_THREADS_PER_CPU"));
|
||||
if (threads_per_cpu <= 0)
|
||||
threads_per_cpu = THREADS_PER_CPU;
|
||||
}
|
||||
|
||||
mono_max_worker_threads = threads_per_cpu * info.dwNumberOfProcessors;
|
||||
mono_max_worker_threads = 20 + threads_per_cpu * info.dwNumberOfProcessors;
|
||||
}
|
||||
|
||||
MonoAsyncResult *
|
||||
|
||||
@@ -1,5 +1,16 @@
|
||||
2005-06-03 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini-amd64.c (emit_call): Fix yet another bug in the near call
|
||||
optimization.
|
||||
|
||||
* mini-amd64.c (amd64_patch): Add an assert to check that the
|
||||
destination of a call is callable by a near call.
|
||||
|
||||
2005-04-28 Zoltan Varga <[email protected]>
|
||||
|
||||
* mini.c (mono_jit_free_method): Remove the method from the JitInfo table
|
||||
before freeing the code memory. Fixes #74990.
|
||||
|
||||
* mini-amd64.c (emit_call): Fix calls to native functions when the
|
||||
runtime is compiled as a shared library. Fixes #74756.
|
||||
|
||||
|
||||
@@ -139,6 +139,12 @@ amd64_patch (unsigned char* code, gpointer target)
|
||||
/* call *<OFFSET>(%rip) */
|
||||
*(guint32*)(code + 2) = ((guint32)(guint64)target) - 7;
|
||||
}
|
||||
else if ((code [0] == 0xe8)) {
|
||||
/* call <DISP> */
|
||||
gint64 disp = (guint8*)target - (guint8*)code;
|
||||
g_assert (amd64_is_imm32 (disp));
|
||||
x86_patch (code, (unsigned char*)target);
|
||||
}
|
||||
else
|
||||
x86_patch (code, (unsigned char*)target);
|
||||
}
|
||||
@@ -1319,6 +1325,10 @@ emit_call (MonoCompile *cfg, guint8 *code, guint32 patch_type, gconstpointer dat
|
||||
}
|
||||
}
|
||||
|
||||
if (cfg->method->dynamic)
|
||||
/* These methods are allocated using malloc */
|
||||
near_call = FALSE;
|
||||
|
||||
if (near_call) {
|
||||
amd64_call_code (code, 0);
|
||||
}
|
||||
|
||||
+7
-1
@@ -9465,9 +9465,15 @@ mono_jit_free_method (MonoDomain *domain, MonoMethod *method)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This needs to be done before freeing code_mp, since the code address is the
|
||||
* key in the table, so if we the code_mp first, another thread can grab the
|
||||
* same code address and replace our entry in the table.
|
||||
*/
|
||||
mono_jit_info_table_remove (domain, ji->ji);
|
||||
|
||||
if (destroy)
|
||||
mono_code_manager_destroy (ji->code_mp);
|
||||
mono_jit_info_table_remove (domain, ji->ji);
|
||||
g_free (ji->ji);
|
||||
g_free (ji);
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
2005-05-03 Geoff Norton <[email protected]>
|
||||
|
||||
* sys-xattr.c: Mac OS/X Tiger supports xattr but has a different API for supporting
|
||||
resource forks. Allow mono to build on Tiger.
|
||||
|
||||
2005-04-30 Jonathan Pryor <[email protected]>
|
||||
|
||||
* stdio.c: Add Mono_Posix_Stdlib_DumpFilePosition, which create a hex string
|
||||
|
||||
@@ -31,9 +31,14 @@ Mono_Posix_Syscall_setxattr (const char *path, const char *name, char *value, mp
|
||||
if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
|
||||
return -1;
|
||||
|
||||
#if __APPLE__
|
||||
return setxattr (path, name, value, size, 0, _flags);
|
||||
#else
|
||||
return setxattr (path, name, value, size, _flags);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !__APPLE__
|
||||
gint32
|
||||
Mono_Posix_Syscall_lsetxattr (const char *path, const char *name, char *value, mph_size_t size, gint32 flags)
|
||||
{
|
||||
@@ -45,6 +50,7 @@ Mono_Posix_Syscall_lsetxattr (const char *path, const char *name, char *value, m
|
||||
|
||||
return lsetxattr (path, name, value, size, _flags);
|
||||
}
|
||||
#endif
|
||||
|
||||
gint32
|
||||
Mono_Posix_Syscall_fsetxattr (int fd, const char *name, char *value, mph_size_t size, gint32 flags)
|
||||
@@ -55,49 +61,74 @@ Mono_Posix_Syscall_fsetxattr (int fd, const char *name, char *value, mph_size_t
|
||||
if (Mono_Posix_FromXattrFlags (flags, &_flags) == -1)
|
||||
return -1;
|
||||
|
||||
#if __APPLE__
|
||||
return fsetxattr (fd, name, value, (size_t) size, 0, _flags);
|
||||
#else
|
||||
return lsetxattr (fd, name, value, (size_t) size, _flags);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_getxattr (const char *path, const char *name, void *value, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
#if __APPLE__
|
||||
return getxattr (path, name, value, (size_t) size, 0, 0);
|
||||
#else
|
||||
return getxattr (path, name, value, (size_t) size);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !__APPLE__
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_lgetxattr (const char *path, const char *name, void *value, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
return lgetxattr (path, name, value, (size_t) size);
|
||||
}
|
||||
#endif
|
||||
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_fgetxattr (int fd, const char *name, void *value, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
#if __APPLE__
|
||||
return fgetxattr (fd, name, value, (size_t) size, 0, 0);
|
||||
#else
|
||||
return fgetxattr (fd, name, value, (size_t) size);
|
||||
#endif
|
||||
}
|
||||
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_listxattr (const char *path, char *list, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
#if __APPLE__
|
||||
return listxattr (path, list, (size_t) size, 0);
|
||||
#else
|
||||
return listxattr (path, list, (size_t) size);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !__APPLE__
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_llistxattr (const char *path, char *list, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
return llistxattr (path, list, (size_t) size);
|
||||
}
|
||||
#endif
|
||||
|
||||
mph_ssize_t
|
||||
Mono_Posix_Syscall_flistxattr (int fd, char *list, mph_size_t size)
|
||||
{
|
||||
mph_return_if_size_t_overflow (size);
|
||||
#if __APPLE__
|
||||
return flistxattr (fd, list, (size_t) size, 0);
|
||||
#else
|
||||
return flistxattr (fd, list, (size_t) size);
|
||||
#endif
|
||||
}
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
Reference in new issue
Block a user