Compare commits

...
21 Commits
Author SHA1 Message Date
Ben Maurer ce91af0332 bump
svn path=/branches/mono-1-1-7/mono/; revision=44454
2005-05-12 17:38:46 +00:00
Gonzalo Paniagua Javier 6706112e8b 2005-05-11 Gonzalo Paniagua Javier <[email protected]>
* shared.c: forgot to ignore a warning.


svn path=/branches/mono-1-1-7/mono/; revision=44425
2005-05-12 04:31:14 +00:00
Miguel de Icaza d9162c6073 Backport the Obsolete fix from Marek
svn path=/branches/mono-1-1-7/mcs/; revision=44401
2005-05-11 18:01:45 +00:00
Miguel de Icaza 5bd902eb2f Backport
svn path=/branches/mono-1-1-7/mcs/; revision=44353
2005-05-10 20:48:00 +00:00
Gonzalo Paniagua Javier 899c06b166 2005-05-10 Gonzalo Paniagua Javier <[email protected]>
* SslClientStream.cs: check for the dispose in NetworkReadCallback.
	Patch by Sebastien "Cryptoman" Pouliot.


svn path=/branches/mono-1-1-7/mcs/; revision=44342
2005-05-10 18:36:09 +00:00
Gonzalo Paniagua Javier 98b125bc4e 2005-05-10 Gonzalo Paniagua Javier <[email protected]>
* shared.c: don't display warnings after reboots.


svn path=/branches/mono-1-1-7/mono/; revision=44340
2005-05-10 18:27:18 +00:00
Gonzalo Paniagua Javier 0304982471 r44204 from HEAD. fixes set/getsockopt on windows
svn path=/branches/mono-1-1-7/mono/; revision=44308
2005-05-10 00:50:22 +00:00
Ben Maurer 0e3bb5c75d 2005-05-09 Ben Maurer <[email protected]>
* configure.in: 1.1.7.1


svn path=/branches/mono-1-1-7/mono/; revision=44293
2005-05-09 19:10:54 +00:00
Miguel de Icaza 01e00f43cf 2005-05-05 Gonzalo Paniagua Javier <[email protected]>
* ProcessStringDictionary.cs: on non-windows system, don't make the
	hashtable case-insensitive. Fixes bug #74796.

svn path=/branches/mono-1-1-7/mcs/; revision=44291
2005-05-09 18:05:51 +00:00
Gonzalo Paniagua Javier a04f30944b Last patches on io-layer from Lluis and Dick in HEAD
svn path=/branches/mono-1-1-7/mono/; revision=44210
2005-05-07 22:22:47 +00:00
Miguel de Icaza 85d8b97aa5 From trunk, fixes VB build on Windows 2005-05-06 Zoltan Varga <[email protected]>
* main.c: Respect MONO_PATH when loading assemblies.

svn path=/branches/mono-1-1-7/mono/; revision=44152
2005-05-06 17:43:34 +00:00
Ben Maurer 84c0ba0211 Thu May 5 17:14:27 CEST 2005 Paolo Molaro <[email protected]>
* mono-debug.c: unlock properly: the interface with the debugger will likely
	need to change.

Thu May 5 16:24:43 CEST 2005 Paolo Molaro <[email protected]>

	* mono-debug-debugger.c, mono-debug-debugger.h, mono-debug.c: remove thread
	unsafe code in the debugger lock/unlock functions and always init the debugger
	lock since it's use also when the debugger is not connected.

2005-05-05  Zoltan Varga  <[email protected]>

	* assembly.c (mono_assembly_load_reference): Fix warning.


svn path=/branches/mono-1-1-7/mono/; revision=44089
2005-05-05 15:50:38 +00:00
Miguel de Icaza 7ef2afa6a8 Apply r44061, r44062 from trunk
svn path=/branches/mono-1-1-7/mono/; revision=44063
2005-05-05 05:25:11 +00:00
Miguel de Icaza f7f844aa64 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.

svn path=/branches/mono-1-1-7/mcs/; revision=44059
2005-05-05 02:28:20 +00:00
Miguel de Icaza ea0d5e5a7e Apply r44048 and r4405 which fix a multi-app-domain remoting app that might be jitting the same method at the same time
svn path=/branches/mono-1-1-7/mono/; revision=44051
2005-05-04 21:47:19 +00:00
Miguel de Icaza aae51015d3 Apply patch from r44043 to 1-1-7 branch
svn path=/branches/mono-1-1-7/mcs/; revision=44045
2005-05-04 20:32:53 +00:00
Miguel de Icaza 999eedbde2 Apply patch from r44008 fixes, 74817
svn path=/branches/mono-1-1-7/mcs/; revision=44025
2005-05-04 13:40:39 +00:00
Miguel de Icaza 22812f2442 Update
svn path=/branches/mono-1-1-7/mcs/; revision=43998
2005-05-04 03:22:23 +00:00
Miguel de Icaza 40c96c75f8 Update
svn path=/branches/mono-1-1-7/mcs/; revision=43997
2005-05-04 03:22:19 +00:00
Miguel de Icaza 5467fae98f Commit to the branch
svn path=/branches/mono-1-1-7/mono/; revision=43996
2005-05-04 03:21:50 +00:00
Miguel de Icaza 0b70115dbf Backport OSX fix
svn path=/branches/mono-1-1-7/mono/; revision=43988
2005-05-03 22:28:11 +00:00
40 changed files with 706 additions and 655 deletions

No files matched your search

+4
View File
@@ -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
View File
@@ -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.2)
AM_MAINTAINER_MODE
AC_PROG_LN_S
+1
View File
@@ -57,6 +57,7 @@
}
#else
#include <gmodule.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "jni.h"
+3 -2
View File
@@ -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 {
+6
View File
@@ -1,3 +1,9 @@
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.
+8 -5
View File
@@ -245,6 +245,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
@@ -809,18 +810,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);
}
}
+8 -3
View File
@@ -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.
+5 -2
View File
@@ -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];
+1 -1
View File
@@ -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 -1
View File
@@ -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.")]
+3 -82
View File
@@ -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)
+1 -1
View File
@@ -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;
+4
View File
@@ -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.
+86
View File
@@ -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
View File
@@ -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;
+33
View File
@@ -1,3 +1,36 @@
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
View File
@@ -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
View File
@@ -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
View File
@@ -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;
}
+8 -11
View File
@@ -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);
}
+222 -118
View File
@@ -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
View File
@@ -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
View File
@@ -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
View File
@@ -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++) {
+8 -6
View File
@@ -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];
+30
View File
@@ -1,3 +1,33 @@
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.
Thu May 5 17:14:27 CEST 2005 Paolo Molaro <[email protected]>
* mono-debug.c: unlock properly: the interface with the debugger will likely
need to change.
Thu May 5 16:24:43 CEST 2005 Paolo Molaro <[email protected]>
* mono-debug-debugger.c, mono-debug-debugger.h, mono-debug.c: remove thread
unsafe code in the debugger lock/unlock functions and always init the debugger
lock since it's use also when the debugger is not connected.
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
+16 -3
View File
@@ -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);
+9 -19
View File
@@ -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++;
}
@@ -82,13 +77,8 @@ 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 +89,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 +303,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 +318,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 +337,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.
+1 -1
View File
@@ -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);
+3 -2
View File
@@ -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,8 @@ 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);
mono_debugger_unlock ();
}
void
+7 -18
View File
@@ -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) {
+11 -9
View File
@@ -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 *
+5
View File
@@ -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
View File
@@ -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