Compare commits

..
26 Commits
Author SHA1 Message Date
Geoff Norton 3b5c655c05 Fix the build on windows 2010-10-05 15:59:29 -04:00
Michael Hutchinson 3b6f5c3308 [io-layer] Cope with pids > 16 bits
Fixes an issue in Process where "pseudo-handles" for processes with
pids > 16 bits would overflow and start getting treated as normal
handles. This would frequently segfault MonoDevelop on MacOS.
2010-10-05 13:38:52 -04:00
Geoff Norton 579a0ca72b Its possible that we're calling Process_free_internal on a pseudo-handle.
When we are not using SHM we use psuedo handles to return processes from pids,
however we dont guard against pseudo-handles in CloseProcess, which could lead to
calling unref on a fake handle.
2010-10-05 13:02:07 -04:00
Marek Habersack 577dfd5d78 [asp.net] Fix for bug #643298. A typo prevented the EnableViewStateMac from being recognized in the Page directive. 2010-10-05 08:04:46 +02:00
Miguel de Icaza 57dae7a311 Retval is not a reserved keyword, fixes 643345 2010-10-03 12:31:14 -04:00
Zoltan Varga a21c08a924 Check the debugger_thread_exited condition in a loop to guard against spurious wakeups. Fixes #642780. 2010-10-01 23:53:09 +02:00
Zoltan Varga e763cd5010 Fix code buffer reallocation check for OP_SWITCH on arm. 2010-10-01 16:27:51 +02:00
Zoltan Varga 964d3433d8 Fix a deadlock introduced by 5c2e3bf7 by using a separate low level lock to procect access to the file_share_hash hash table. Fixes #642985. 2010-10-01 10:03:27 +02:00
Gonzalo Paniagua Javier 89f92560a1 Invoke the callback in separate threads
The callbacks need to be invoked in different threads to avoid clogging
	the IO pool.

	Fixes bug #639656.
2010-09-30 01:41:22 -04:00
Marek Safar b1752875e8 [642437] Nested types have to check type arguments only and not full class 2010-09-29 09:06:09 -06:00
Alan McGovern 2a308efd0a [System.ServiceModel] Fix a few potential exceptions in background threads
Pass the listener as it's own async state so that we avoid potential null derefs in the callback. Also wrap the BeginAccept and EndAccept calls in their own try/catches in case they throw an exception.
2010-09-29 08:46:52 -06:00
Jérémie Laval bff2b8d6c4 [ReaderWriterLockSlim] Fix state corruption and race in a special interleaving.
Fix possible state corruption in the case where Upgradeable wasn't reactivating its read bit after a downgrade and set events accordingly. Fix possible race where a write process wannabe could step in the middle of Upgradeable actually upgrading to write mode.

Conflicts:

	mcs/class/System.Core/System.Threading/ReaderWriterLockSlim.cs
2010-09-29 15:45:21 +01:00
Marek Habersack 9f2d34d689 [asp.net] Remove lock recursion in Cache.ExpireItems 2010-09-28 22:36:04 +02:00
Atsushi Eno 37edaa18f7 TCP channel listener: remove extra complication (threads) in the previous change. 2010-09-28 10:57:39 -06:00
Atsushi Eno 77d12442c4 Rework TCP listening model, and fix AcceptTcpClient() to not drop timed out requests that actually steals next requests in the air. 2010-09-28 10:57:38 -06:00
Jérémie Laval 3ad4bb8e3d Turn Is*LockHeld properties into thread-specific values in ReaderWriterLockSlim. Add corresponding unit tests. 2010-09-28 13:24:25 +01:00
Marek Habersack 67c7faf279 [asp.net] Get rid of a possible (although unlikely) race condition when acquiring locks
The patch removes a small race condition where a boolean flag is set after acquiring a lock to
indicate to code executing in the finally {} block that it should release the lock. The boolean
variable is now removed and the lock is released unconditionally. It carries a potential to
throw an exception when the lock is not held, but it's better than to fail to release it and
lead the application to a deadlock.
2010-09-28 13:32:15 +02:00
Jackson Harper 7757931e8e On 64bit this is turning into a 16 byte struct, this works around the issue. 2010-09-24 00:26:29 -04:00
Andrew Jorgensen 5a55034e93 move DynamicData to mvc because it depends on Extensions 2010-09-23 14:18:16 -06:00
Gonzalo Paniagua Javier bab18ab6d2 epoll_ctl takes an int, not IntPtr
Ditto.
2010-09-23 15:02:32 -04:00
Gonzalo Paniagua Javier 4c601b8522 EpollEvent size adjustment
EpollEvent has to be one uint32 plus one int64, i.e. 12 bytes long.
	Manos libres now.
2010-09-22 18:15:57 -04:00
Jérémie Laval 36e827b0be Also set readerDoneEvent when exiting an upgradeable lock and reader condition is correct.
It could cause a deadlock when a writer tested the rwlock value before RwRead was removed and another Upgradeable operation happened at the same time.
2010-09-22 11:10:56 +01:00
Marek Safar e137468dc6 [640722] Consider delegate parameters when checking member hiding 2010-09-21 10:22:11 -06:00
Marek Safar aa92238b98 [640709] Don't reuse method parameters for base proxy, they can be hoisted 2010-09-21 10:21:46 -06:00
Marek Safar 093a537205 [640699] Reduced compound expressions need explicit conversion too. 2010-09-21 10:09:36 -06:00
Andrew Jorgensen fe1653eae0 put the x11 devel package back in buildrequires and a couple other spec fixes 2010-09-20 17:25:14 -06:00
26 changed files with 410 additions and 213 deletions

No files matched your search

@@ -1165,10 +1165,18 @@ namespace Mono.Unix.Native {
EPOLL_CTL_MOD = 3,
}
[StructLayout (LayoutKind.Sequential, Pack = 1)]
[StructLayout (LayoutKind.Explicit, Size=12, Pack=1)]
public struct EpollEvent {
[FieldOffset (0)]
public EpollEvents events;
public IntPtr fd;
[FieldOffset (4)]
public int fd;
[FieldOffset (4)]
public IntPtr ptr;
[FieldOffset (4)]
public uint u32;
[FieldOffset (4)]
public ulong u64;
}
#endregion
@@ -2669,7 +2677,7 @@ namespace Mono.Unix.Native {
return sys_epoll_create1 (flags);
}
public static int epoll_ctl (int epfd, EpollOp op, IntPtr fd, EpollEvents events)
public static int epoll_ctl (int epfd, EpollOp op, int fd, EpollEvents events)
{
EpollEvent ee = new EpollEvent ();
ee.events = events;
@@ -2693,7 +2701,7 @@ namespace Mono.Unix.Native {
private static extern int sys_epoll_create1 (EpollFlags flags);
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_ctl")]
private static extern int sys_epoll_ctl (int epfd, EpollOp op, IntPtr fd, ref EpollEvent ee);
private static extern int sys_epoll_ctl (int epfd, EpollOp op, int fd, ref EpollEvent ee);
[DllImport (LIBC, SetLastError=true, EntryPoint="epoll_wait")]
private static extern int sys_epoll_wait (int epfd, EpollEvent [] ee, int maxevents, int timeout);
@@ -112,6 +112,7 @@ namespace System.Threading {
Stopwatch sw = Stopwatch.StartNew ();
Interlocked.Increment (ref numReadWaiters);
int val = 0;
while (millisecondsTimeout == -1 || sw.ElapsedMilliseconds < millisecondsTimeout) {
if ((rwlock & 0x7) > 0) {
@@ -119,12 +120,20 @@ namespace System.Threading {
continue;
}
if ((Interlocked.Add (ref rwlock, RwRead) & 0x7) == 0) {
/* Optimistically try to add ourselves to the reader value
* if the adding was too late and another writer came in between
* we revert the operation.
*/
if (((val = Interlocked.Add (ref rwlock, RwRead)) & 0x7) == 0) {
/* If we are the first reader, reset the event to let other threads
* sleep correctly if they try to acquire write lock
*/
if (val >> RwReadBit == 1)
readerDoneEvent.Reset ();
ctstate.LockState ^= LockState.Read;
ctstate.ReaderRecursiveCount++;
Interlocked.Decrement (ref numReadWaiters);
if (readerDoneEvent.IsSet ())
readerDoneEvent.Reset ();
return true;
}
@@ -173,33 +182,43 @@ namespace System.Threading {
Interlocked.Increment (ref numWriteWaiters);
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
// If the code goes there that means we had a read lock beforehand
/* If the code goes there that means we had a read lock beforehand
* that need to be suppressed, we also take the opportunity to register
* our interest in the write lock to avoid other write wannabe process
* coming in the middle
*/
if (isUpgradable && rwlock >= RwRead)
Interlocked.Add (ref rwlock, -RwRead);
if (Interlocked.Add (ref rwlock, RwWaitUpgrade - RwRead) >> RwReadBit == 0)
readerDoneEvent.Set ();
int stateCheck = isUpgradable ? RwWaitUpgrade : RwWait;
int appendValue = RwWait | (isUpgradable ? RwWaitUpgrade : 0);
while (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout) {
int state = rwlock;
if (state <= stateCheck) {
if (Interlocked.CompareExchange (ref rwlock, RwWrite, state) == state) {
writerDoneEvent.Reset ();
ctstate.LockState ^= LockState.Write;
ctstate.WriterRecursiveCount++;
Interlocked.Decrement (ref numWriteWaiters);
if (writerDoneEvent.IsSet ())
writerDoneEvent.Reset ();
return true;
}
state = rwlock;
}
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | appendValue, state) == state)
state = rwlock;
// We register our interest in taking the Write lock (if upgradeable it's already done)
if (!isUpgradable)
while ((state & RwWait) == 0 && Interlocked.CompareExchange (ref rwlock, state | RwWait, state) == state)
state = rwlock;
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout))
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
// Before falling to sleep
while (rwlock > stateCheck && (millisecondsTimeout < 0 || sw.ElapsedMilliseconds < millisecondsTimeout)) {
if ((rwlock & RwWrite) != 0)
writerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
else if ((rwlock >> RwReadBit) > 0)
readerDoneEvent.Wait (ComputeTimeout (millisecondsTimeout, sw));
}
}
Interlocked.Decrement (ref numWriteWaiters);
@@ -218,10 +237,14 @@ namespace System.Threading {
if (!ctstate.LockState.Has (LockState.Write))
throw new SynchronizationLockException ("The current thread has not entered the lock in write mode");
bool isUpgradable = ctstate.LockState.Has (LockState.Upgradable);
ctstate.LockState ^= LockState.Write;
ctstate.WriterRecursiveCount--;
Interlocked.Add (ref rwlock, -RwWrite);
int value = Interlocked.Add (ref rwlock, isUpgradable ? RwRead - RwWrite : -RwWrite);
writerDoneEvent.Set ();
if (isUpgradable && value >> RwReadBit == 1)
readerDoneEvent.Reset ();
}
public void EnterUpgradeableReadLock ()
@@ -292,7 +315,8 @@ namespace System.Threading {
ctstate.LockState ^= LockState.Upgradable;
ctstate.UpgradeableRecursiveCount--;
Interlocked.Add (ref rwlock, -RwRead);
if (Interlocked.Add (ref rwlock, -RwRead) >> RwReadBit == 0)
readerDoneEvent.Set ();
}
public void Dispose ()
@@ -302,25 +326,25 @@ namespace System.Threading {
public bool IsReadLockHeld {
get {
return rwlock >= RwRead;
return rwlock >= RwRead && CurrentThreadState.LockState.Has (LockState.Read);
}
}
public bool IsWriteLockHeld {
get {
return (rwlock & RwWrite) > 0;
return (rwlock & RwWrite) > 0 && CurrentThreadState.LockState.Has (LockState.Write);
}
}
public bool IsUpgradeableReadLockHeld {
get {
return upgradableTaken.Value;
return upgradableTaken.Value && CurrentThreadState.LockState.Has (LockState.Upgradable);
}
}
public int CurrentReadCount {
get {
return (rwlock >> RwReadBit) - (IsUpgradeableReadLockHeld ? 1 : 0);
return (rwlock >> RwReadBit) - (upgradableTaken.Value ? 1 : 0);
}
}
@@ -483,5 +483,92 @@ namespace MonoTests.System.Threading
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#2");
Assert.IsTrue (v.TryEnterUpgradeableReadLock (100), "#3");
}
[Test]
public void RecursiveReadPropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterReadLock ();
v.EnterReadLock ();
Assert.AreEqual (true, v.IsReadLockHeld, "#1a");
Assert.AreEqual (1, v.CurrentReadCount, "#2a");
Assert.AreEqual (2, v.RecursiveReadCount, "#3a");
bool rLock = true;
int cReadCount = -1, rReadCount = -1;
Thread t = new Thread ((_) => {
rLock = v.IsReadLockHeld;
cReadCount = v.CurrentReadCount;
rReadCount = v.RecursiveReadCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, rLock, "#1b");
Assert.AreEqual (1, cReadCount, "#2b");
Assert.AreEqual (0, rReadCount, "#3b");
}
[Test]
public void RecursiveUpgradePropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterUpgradeableReadLock ();
v.EnterUpgradeableReadLock ();
Assert.AreEqual (true, v.IsUpgradeableReadLockHeld, "#1a");
Assert.AreEqual (false, v.IsReadLockHeld, "#11a");
Assert.AreEqual (0, v.CurrentReadCount, "#2a");
Assert.AreEqual (2, v.RecursiveUpgradeCount, "#3a");
bool upLock = false, rLock = false;
int rCount = -1, rUCount = -1;
Thread t = new Thread ((_) => {
upLock = v.IsUpgradeableReadLockHeld;
rLock = v.IsReadLockHeld;
rCount = v.CurrentReadCount;
rUCount = v.RecursiveUpgradeCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, upLock, "#1b");
Assert.AreEqual (false, rLock, "#11b");
Assert.AreEqual (0, rCount, "#2b");
Assert.AreEqual (0, rUCount, "#3b");
}
[Test]
public void RecursiveWritePropertiesTest ()
{
var v = new ReaderWriterLockSlim (LockRecursionPolicy.SupportsRecursion);
v.EnterWriteLock ();
v.EnterWriteLock ();
Assert.AreEqual (true, v.IsWriteLockHeld, "#1a");
Assert.AreEqual (2, v.RecursiveWriteCount, "#3a");
bool wLock = false;
int rWrite = -1;
Thread t = new Thread ((_) => {
wLock = v.IsWriteLockHeld;
rWrite = v.RecursiveWriteCount;
});
t.Start ();
t.Join ();
Assert.AreEqual (false, wLock, "#1b");
Assert.AreEqual (0, rWrite, "#3b");
}
}
}
@@ -3,9 +3,30 @@
//
// Author:
// Marcos Cobena ([email protected])
// Atsushi Enomoto ([email protected])
//
// Copyright 2007 Marcos Cobena (http://www.youcannoteatbits.org/)
// Copyright 2009-2010 Novell, Inc (http://www.novell.com/)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections.Generic;
@@ -46,8 +67,9 @@ namespace System.ServiceModel.Channels
info = new TcpChannelInfo (source, MessageEncoder, quotas);
}
List<ManualResetEvent> accept_handles = new List<ManualResetEvent> ();
List<TChannel> accepted_channels = new List<TChannel> ();
SynchronizedCollection<ManualResetEvent> accept_handles = new SynchronizedCollection<ManualResetEvent> ();
Queue<TcpClient> accepted_clients = new Queue<TcpClient> ();
SynchronizedCollection<TChannel> accepted_channels = new SynchronizedCollection<TChannel> ();
protected override TChannel OnAcceptChannel (TimeSpan timeout)
{
@@ -89,32 +111,28 @@ namespace System.ServiceModel.Channels
{
DateTime start = DateTime.Now;
TcpClient client = null;
if (tcp_listener.Pending ()) {
client = tcp_listener.AcceptTcpClient ();
} else {
TcpClient client = accepted_clients.Count == 0 ? null : accepted_clients.Dequeue ();
if (client == null) {
var wait = new ManualResetEvent (false);
tcp_listener.BeginAcceptTcpClient (delegate (IAsyncResult result) {
client = tcp_listener.EndAcceptTcpClient (result);
wait.Set ();
accept_handles.Remove (wait);
}, null);
if (State == CommunicationState.Closing)
return null;
accept_handles.Add (wait);
wait.WaitOne (timeout);
if (!wait.WaitOne (timeout)) {
accept_handles.Remove (wait);
return null;
}
accept_handles.Remove (wait);
// recurse with new timeout, or return null if it's either being closed or timed out.
timeout -= (DateTime.Now - start);
return State == CommunicationState.Opened && timeout > TimeSpan.Zero ? AcceptTcpClient (timeout) : null;
}
// This may be optional though ...
if (client != null) {
foreach (var ch in accepted_channels) {
var dch = ch as TcpDuplexSessionChannel;
if (dch == null || dch.TcpClient == null && !dch.TcpClient.Connected)
continue;
if (((IPEndPoint) dch.TcpClient.Client.RemoteEndPoint).Equals (client.Client.RemoteEndPoint))
// ... then it should be handled in another BeginTryReceive/EndTryReceive loop in ChannelDispatcher.
return AcceptTcpClient (timeout - (DateTime.Now - start));
}
// There might be bettwe way to exclude those TCP clients though ...
foreach (var ch in accepted_channels) {
var dch = ch as TcpDuplexSessionChannel;
if (dch == null || dch.TcpClient == null && !dch.TcpClient.Connected)
continue;
if (((IPEndPoint) dch.TcpClient.Client.RemoteEndPoint).Equals (client.Client.RemoteEndPoint))
// ... then it should be handled in another BeginTryReceive/EndTryReceive loop in ChannelDispatcher.
return AcceptTcpClient (timeout - (DateTime.Now - start));
}
return client;
@@ -132,25 +150,25 @@ namespace System.ServiceModel.Channels
{
if (State == CommunicationState.Closed)
return;
ProcessClose ();
ProcessClose (TimeSpan.Zero);
}
protected override void OnClose (TimeSpan timeout)
{
if (State == CommunicationState.Closed)
return;
ProcessClose ();
ProcessClose (timeout);
}
void ProcessClose ()
void ProcessClose (TimeSpan timeout)
{
if (tcp_listener == null)
throw new InvalidOperationException ("Current state is " + State);
lock (accept_handles) {
foreach (var wait in accept_handles)
wait.Set ();
}
//tcp_listener.Client.Close (Math.Max (50, (int) timeout.TotalMilliseconds));
tcp_listener.Stop ();
var l = new List<ManualResetEvent> (accept_handles);
foreach (var wait in l) // those handles will disappear from accepted_handles
wait.Set ();
tcp_listener = null;
}
@@ -164,6 +182,31 @@ namespace System.ServiceModel.Channels
int explicitPort = Uri.Port;
tcp_listener = new TcpListener (entry.AddressList [0], explicitPort <= 0 ? TcpTransportBindingElement.DefaultPort : explicitPort);
tcp_listener.Start ();
tcp_listener.BeginAcceptTcpClient (TcpListenerAcceptedClient, tcp_listener);
}
void TcpListenerAcceptedClient (IAsyncResult result)
{
var listener = (TcpListener) result.AsyncState;
try {
var client = listener.EndAcceptTcpClient (result);
if (client != null) {
accepted_clients.Enqueue (client);
if (accept_handles.Count > 0)
accept_handles [0].Set ();
}
} catch {
/* If an accept fails, just ignore it. Maybe the remote peer disconnected already */
} finally {
if (State == CommunicationState.Opened) {
try {
listener.BeginAcceptTcpClient (TcpListenerAcceptedClient, listener);
} catch {
/* If this fails, we must have disposed the listener */
}
}
}
}
}
}
@@ -42,6 +42,21 @@ namespace System.Web.Caching
{
public static readonly DateTime NoAbsoluteExpiration = DateTime.MaxValue;
public static readonly TimeSpan NoSlidingExpiration = TimeSpan.Zero;
// cacheLock will be released in the code below without checking whether it was
// actually acquired. The API doesn't offer a reliable way to check whether the lock
// is being held by the current thread and since Mono does't implement CER
// (Constrained Execution Regions -
// http://msdn.microsoft.com/en-us/library/ms228973.aspx) currently, we have no
// reliable way of recording the information that the lock has been successfully
// acquired.
// It can happen that a Thread.Abort occurs while acquiring the lock and the lock
// isn't actually held. In this case the attempt to release a lock will throw an
// exception. It's better than a race of setting a boolean flag after acquiring the
// lock and then relying upon it here to release it - that may cause a deadlock
// should we fail to release the lock which was successfully acquired but
// Thread.Abort happened right after that during the stloc instruction to set the
// boolean flag. Once CERs are supported we can use the boolean flag reliably.
ReaderWriterLockSlim cacheLock;
Dictionary <string, CacheItem> cache;
CacheItemPriorityQueue timedItems;
@@ -153,19 +168,17 @@ namespace System.Web.Caching
{
if (key == null)
throw new ArgumentNullException ("key");
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it != null)
return it.Value;
Insert (key, value, dependencies, absoluteExpiration, slidingExpiration, priority, onRemoveCallback, null, false);
} finally {
if (locked)
cacheLock.ExitWriteLock ();
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
return null;
@@ -173,10 +186,8 @@ namespace System.Web.Caching
public object Get (string key)
{
bool locked = false;
try {
cacheLock.EnterUpgradeableReadLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it == null)
return null;
@@ -187,6 +198,7 @@ namespace System.Web.Caching
if (!NeedsUpdate (it, CacheItemUpdateReason.DependencyChanged, false))
Remove (it.Key, CacheItemRemovedReason.DependencyChanged, false, true);
} finally {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
@@ -212,6 +224,7 @@ namespace System.Web.Caching
if (!NeedsUpdate (it, CacheItemUpdateReason.Expired, false))
Remove (key, CacheItemRemovedReason.Expired, false, true);
} finally {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
@@ -221,9 +234,8 @@ namespace System.Web.Caching
return it.Value;
} finally {
if (locked) {
cacheLock.ExitUpgradeableReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitUpgradeableReadLock ();
}
}
@@ -282,20 +294,17 @@ namespace System.Web.Caching
internal void SetItemTimeout (string key, DateTime absoluteExpiration, TimeSpan slidingExpiration, bool doLock)
{
CacheItem ci = null;
bool locked = false;
CacheItem ci = null;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
ci = GetCacheItem (key);
if (ci != null)
SetItemTimeout (ci, absoluteExpiration, slidingExpiration, ci.OnRemoveCallback, null, key, false);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -317,12 +326,9 @@ namespace System.Web.Caching
ci.OnRemoveCallback = onRemoveCallback;
ci.OnUpdateCallback = onUpdateCallback;
bool locked = false;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
if (ci.Timer != null) {
ci.Timer.Dispose ();
@@ -336,7 +342,8 @@ namespace System.Web.Caching
if (!disableExpiration && ci.AbsoluteExpiration != NoAbsoluteExpiration)
EnqueueTimedItem (ci);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -376,16 +383,14 @@ namespace System.Web.Caching
object Remove (string key, CacheItemRemovedReason reason, bool doLock, bool invokeCallback)
{
CacheItem it = null;
bool locked = false;
try {
if (doLock) {
if (doLock)
cacheLock.EnterWriteLock ();
locked = true;
}
it = RemoveCacheItem (key);
} finally {
if (locked) {
if (doLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
@@ -424,10 +429,8 @@ namespace System.Web.Caching
internal void InvokePrivateCallbacks ()
{
CacheItemRemovedReason reason = CacheItemRemovedReason.Removed;
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
foreach (string key in cache.Keys) {
CacheItem item = GetCacheItem (key);
if (item.Disabled)
@@ -442,25 +445,21 @@ namespace System.Web.Caching
}
}
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
}
public IDictionaryEnumerator GetEnumerator ()
{
ArrayList list = new ArrayList ();
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
foreach (CacheItem it in cache.Values)
list.Add (it);
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
return new CacheItemEnumerator (list);
@@ -478,13 +477,9 @@ namespace System.Web.Caching
bool NeedsUpdate (CacheItem item, CacheItemUpdateReason reason, bool needLock)
{
bool locked = false;
try {
if (needLock) {
if (needLock)
cacheLock.EnterWriteLock ();
locked = true;
}
if (item == null || item.OnUpdateCallback == null)
return false;
@@ -525,8 +520,10 @@ namespace System.Web.Caching
} catch (Exception) {
return false;
} finally {
if (locked)
if (needLock) {
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
}
@@ -534,11 +531,9 @@ namespace System.Web.Caching
{
DateTime now = DateTime.Now;
CacheItem item = timedItems.Peek ();
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
while (item != null) {
if (!item.Disabled && item.ExpiresAt > now.Ticks)
@@ -549,13 +544,13 @@ namespace System.Web.Caching
}
item = timedItems.Dequeue ();
if (!NeedsUpdate (item, CacheItemUpdateReason.Expired, true))
if (!NeedsUpdate (item, CacheItemUpdateReason.Expired, false))
Remove (item.Key, CacheItemRemovedReason.Expired, false, true);
item = timedItems.Peek ();
}
} finally {
if (locked)
cacheLock.ExitWriteLock ();
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
if (item != null) {
@@ -574,10 +569,8 @@ namespace System.Web.Caching
internal void CheckDependencies ()
{
IList list;
bool locked = false;
try {
cacheLock.EnterWriteLock ();
locked = true;
list = new List <CacheItem> ();
foreach (CacheItem it in cache.Values)
list.Add (it);
@@ -587,18 +580,15 @@ namespace System.Web.Caching
Remove (it.Key, CacheItemRemovedReason.DependencyChanged, false, true);
}
} finally {
if (locked) {
cacheLock.ExitWriteLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitWriteLock ();
}
}
internal DateTime GetKeyLastChange (string key)
{
bool locked = false;
try {
cacheLock.EnterReadLock ();
locked = true;
CacheItem it = GetCacheItem (key);
if (it == null)
@@ -606,9 +596,8 @@ namespace System.Web.Caching
return it.LastChange;
} finally {
if (locked) {
cacheLock.ExitReadLock ();
}
// See comment at the top of the file, above cacheLock declaration
cacheLock.ExitReadLock ();
}
}
@@ -41,6 +41,8 @@ namespace System.Web.Caching
CacheItem[] heap;
int heapSize = 0;
int heapCount = 0;
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
ReaderWriterLockSlim queueLock;
public int Count {
@@ -94,20 +96,18 @@ namespace System.Web.Caching
if (item == null)
return;
bool locked = false;
CacheItem[] heap;
try {
queueLock.EnterWriteLock ();
locked = true;
heap = GetHeapWithGrow ();
heap [heapCount++] = item;
BubbleUp (heap);
AddSequenceEntry (item, EDSequenceEntryType.Enqueue);
} finally {
if (locked)
queueLock.ExitWriteLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitWriteLock ();
}
}
@@ -115,12 +115,10 @@ namespace System.Web.Caching
{
CacheItem ret = null;
CacheItem[] heap;
bool locked = false;
int index;
try {
queueLock.EnterWriteLock ();
locked = true;
heap = GetHeapWithShrink ();
if (heap == null || heapCount == 0)
return null;
@@ -136,19 +134,17 @@ namespace System.Web.Caching
AddSequenceEntry (ret, EDSequenceEntryType.Dequeue);
return ret;
} finally {
if (locked)
queueLock.ExitWriteLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitWriteLock ();
}
}
public CacheItem Peek ()
{
bool locked = false;
CacheItem ret;
try {
queueLock.EnterReadLock ();
locked = true;
if (heap == null || heapCount == 0)
return null;
@@ -157,8 +153,8 @@ namespace System.Web.Caching
return ret;
} finally {
if (locked)
queueLock.ExitReadLock ();
// See comment at the top of the file, above queueLock declaration
queueLock.ExitReadLock ();
}
}
@@ -94,6 +94,7 @@ namespace System.Web.Compilation
// This is here _only_ for the purpose of unit tests!
internal static bool suppressDebugModeMessages;
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
#if SYSTEMCORE_DEP
static ReaderWriterLockSlim buildCacheLock;
#else
@@ -817,14 +818,12 @@ namespace System.Web.Compilation
// to the assembly builder and, in effect, no assembly is produced but there are STILL types that need
// to be added to the cache.
Assembly compiledAssembly = results != null ? results.CompiledAssembly : null;
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterWriteLock ();
#else
buildCacheLock.AcquireWriterLock (-1);
#endif
locked = true;
if (compiledAssembly != null)
referencedAssemblies.Add (compiledAssembly);
@@ -835,13 +834,11 @@ namespace System.Web.Compilation
StoreInCache (bp, compiledAssembly, results);
}
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitWriteLock ();
buildCacheLock.ExitWriteLock ();
#else
buildCacheLock.ReleaseWriterLock ();
buildCacheLock.ReleaseWriterLock ();
#endif
}
}
}
@@ -883,24 +880,19 @@ namespace System.Web.Compilation
#endif
static BuildManagerCacheItem GetCachedItem (string vp)
{
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterReadLock ();
#else
buildCacheLock.AcquireReaderLock (-1);
#endif
locked = true;
return GetCachedItemNoLock (vp);
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitReadLock ();
buildCacheLock.ExitReadLock ();
#else
buildCacheLock.ReleaseReaderLock ();
buildCacheLock.ReleaseReaderLock ();
#endif
}
}
}
@@ -1290,27 +1282,22 @@ namespace System.Web.Compilation
else
return;
bool locked = false;
try {
#if SYSTEMCORE_DEP
buildCacheLock.EnterWriteLock ();
#else
buildCacheLock.AcquireWriterLock (-1);
#endif
locked = true;
if (HasCachedItemNoLock (virtualPath)) {
buildCache [virtualPath] = null;
OnEntryRemoved (virtualPath);
}
} finally {
if (locked) {
#if SYSTEMCORE_DEP
buildCacheLock.ExitWriteLock ();
buildCacheLock.ExitWriteLock ();
#else
buildCacheLock.ReleaseWriterLock ();
buildCacheLock.ReleaseWriterLock ();
#endif
}
}
}
@@ -67,6 +67,8 @@ namespace System.Web.Configuration {
static readonly char[] pathTrimChars = { '/' };
static readonly object suppressAppReloadLock = new object ();
static readonly object saveLocationsCacheLock = new object ();
// See comment for the cacheLock field at top of System.Web.Caching/Cache.cs
static readonly ReaderWriterLockSlim sectionCacheLock;
#if !TARGET_J2EE
@@ -225,14 +227,11 @@ namespace System.Web.Configuration {
static void ConfigurationSaveHandler (_Configuration sender, ConfigurationSaveEventArgs args)
{
bool locked = false;
try {
sectionCacheLock.EnterWriteLock ();
locked = true;
sectionCache.Clear ();
} finally {
if (locked)
sectionCacheLock.ExitWriteLock ();
sectionCacheLock.ExitWriteLock ();
}
lock (suppressAppReloadLock) {
@@ -442,7 +441,6 @@ namespace System.Web.Configuration {
int cacheKey;
bool pathPresent = !String.IsNullOrEmpty (path);
string locationPath = null;
bool locked = false;
if (pathPresent)
locationPath = "location_" + path;
@@ -453,7 +451,6 @@ namespace System.Web.Configuration {
try {
sectionCacheLock.EnterReadLock ();
locked = true;
object o;
if (pathPresent) {
@@ -469,8 +466,7 @@ namespace System.Web.Configuration {
if (sectionCache.TryGetValue (baseCacheKey, out o))
return o;
} finally {
if (locked)
sectionCacheLock.ExitReadLock ();
sectionCacheLock.ExitReadLock ();
}
string cachePath = null;
@@ -687,27 +683,21 @@ namespace System.Web.Configuration {
static void AddSectionToCache (int key, object section)
{
object cachedSection;
bool locked = false;
try {
sectionCacheLock.EnterUpgradeableReadLock ();
locked = true;
if (sectionCache.TryGetValue (key, out cachedSection) && cachedSection != null)
return;
bool innerLocked = false;
try {
sectionCacheLock.EnterWriteLock ();
innerLocked = true;
sectionCache.Add (key, section);
} finally {
if (innerLocked)
sectionCacheLock.ExitWriteLock ();
sectionCacheLock.ExitWriteLock ();
}
} finally {
if (locked)
sectionCacheLock.ExitUpgradeableReadLock ();
sectionCacheLock.ExitUpgradeableReadLock ();
}
}
@@ -432,7 +432,7 @@ namespace System.Web.UI
enable_event_validation = GetBool (atts, "EnableEventValidation", enable_event_validation);
maintainScrollPositionOnPostBack = GetBool (atts, "MaintainScrollPositionOnPostBack", maintainScrollPositionOnPostBack);
if (atts.Contains ("EnableViewState")) {
if (atts.Contains ("EnableViewStateMac")) {
enableViewStateMac = GetBool (atts, "EnableViewStateMac", enableViewStateMac);
enableViewStateMacSet = true;
}
@@ -201,10 +201,15 @@ namespace System.Net.Sockets
}
if (callback != null)
callback (this);
ThreadPool.QueueUserWorkItem (CB, null);
Buffer = null;
}
void CB (object unused)
{
callback (this);
}
SocketAsyncCall GetDelegate (Worker worker, SocketOperation op)
{
switch (op) {
@@ -139,9 +139,14 @@ namespace System.Net
{
if (!callbackDone && cb != null) {
callbackDone = true;
cb (this);
ThreadPool.QueueUserWorkItem (CB, null);
}
}
void CB (object unused)
{
cb (this);
}
internal void WaitUntilComplete ()
{
+1 -1
View File
@@ -305,7 +305,7 @@ namespace Mono.ILASM {
%token K_OUT
%token K_OPT
// %token K_LCID
%token K_RETVAL
//%token K_RETVAL
%token K_STATIC
%token K_PUBLIC
%token K_PRIVATE
+1 -1
View File
@@ -143,7 +143,7 @@ namespace Mono.ILASM {
keywords ["opt"] = new ILToken (Token.K_OPT, "opt");
// Not a keyword according to ilasm 1.1
// keywords ["lcid"] = new ILToken (Token.K_LCID, "lcid");
keywords ["retval"] = new ILToken (Token.K_RETVAL, "retval");
//keywords ["retval"] = new ILToken (Token.K_RETVAL, "retval");
keywords ["static"] = new ILToken (Token.K_STATIC, "static");
keywords ["public"] = new ILToken (Token.K_PUBLIC, "public");
keywords ["private"] = new ILToken (Token.K_PRIVATE, "private");
+3
View File
@@ -654,6 +654,9 @@ namespace Mono.CSharp {
// Otherwise, if the selected operator is a predefined operator
//
Binary b = source as Binary;
if (b == null && source is ReducedExpression)
b = ((ReducedExpression) source).OriginalExpression as Binary;
if (b != null) {
//
// 2a. the operator is a shift operator
+9 -16
View File
@@ -1053,14 +1053,12 @@ namespace Mono.CSharp {
if (proxy_method == null) {
string name = CompilerGeneratedClass.MakeName (method.Name, null, "BaseCallProxy", hoisted_base_call_proxies.Count);
var base_parameters = method.Parameters.FixedParameters as Parameter[];
if (base_parameters == null) {
base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
base_param.Name, base_param.ModFlags, null, Location);
}
var base_parameters = new Parameter[method.Parameters.Count];
for (int i = 0; i < base_parameters.Length; ++i) {
var base_param = method.Parameters.FixedParameters[i];
base_parameters[i] = new Parameter (new TypeExpression (method.Parameters.Types[i], Location),
base_param.Name, base_param.ModFlags, null, Location);
base_parameters[i].Resolve (this, i);
}
var cloned_params = ParametersCompiled.CreateFullyResolved (base_parameters, method.Parameters.Types);
@@ -2634,14 +2632,9 @@ namespace Mono.CSharp {
while (mt.IsPointer)
mt = TypeManager.GetElementType (mt);
if (mt.MemberDefinition == this) {
for (var p = Parent; p != null; p = p.Parent) {
if (p.Kind == MemberKind.Class) {
has_unmanaged_check_done = true;
return false;
}
}
continue;
if (mt.IsGenericOrParentIsGeneric || mt.IsGenericParameter) {
has_unmanaged_check_done = true;
return false;
}
if (TypeManager.IsUnmanagedType (mt))
+22 -8
View File
@@ -22,10 +22,10 @@ namespace Mono.CSharp {
//
// Delegate container implementation
//
public class Delegate : TypeContainer
public class Delegate : TypeContainer, IParametersMember
{
FullNamedExpression ReturnType;
public readonly ParametersCompiled Parameters;
readonly ParametersCompiled parameters;
Constructor Constructor;
Method InvokeBuilder;
@@ -59,10 +59,24 @@ namespace Mono.CSharp {
ModFlags = ModifiersExtensions.Check (AllowedModifiers, mod_flags,
IsTopLevel ? Modifiers.INTERNAL :
Modifiers.PRIVATE, name.Location, Report);
Parameters = param_list;
parameters = param_list;
spec = new TypeSpec (Kind, null, this, null, ModFlags | Modifiers.SEALED);
}
#region Properties
public TypeSpec MemberType {
get {
return ReturnType.Type;
}
}
public AParametersCollection Parameters {
get {
return parameters;
}
}
#endregion
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Target == AttributeTargets.ReturnValue) {
@@ -105,7 +119,7 @@ namespace Mono.CSharp {
// First, call the `out of band' special method for
// defining recursively any types we need:
//
var p = Parameters;
var p = parameters;
if (!p.Resolve (this))
return false;
@@ -217,7 +231,7 @@ namespace Mono.CSharp {
int param = 0;
for (int i = 0; i < Parameters.FixedParameters.Length; ++i) {
Parameter p = Parameters [i];
Parameter p = parameters [i];
if ((p.ModFlags & Parameter.Modifier.ISBYREF) == 0)
continue;
@@ -246,7 +260,7 @@ namespace Mono.CSharp {
public override void DefineConstants ()
{
if (!Parameters.IsEmpty) {
Parameters.ResolveDefaultValues (this);
parameters.ResolveDefaultValues (this);
}
}
@@ -267,7 +281,7 @@ namespace Mono.CSharp {
}
}
Parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
parameters.ApplyAttributes (this, InvokeBuilder.MethodBuilder);
Constructor.ConstructorBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
InvokeBuilder.MethodBuilder.SetImplementationFlags (MethodImplAttributes.Runtime);
@@ -314,7 +328,7 @@ namespace Mono.CSharp {
return false;
}
Parameters.VerifyClsCompliance (this);
parameters.VerifyClsCompliance (this);
if (!ReturnType.Type.IsCLSCompliant ()) {
Report.Warning (3002, 1, Location, "Return type of `{0}' is not CLS-compliant",
+10
View File
@@ -1873,6 +1873,16 @@ namespace Mono.CSharp {
this.loc = orig_expr.Location;
}
#region Properties
public Expression OriginalExpression {
get {
return orig_expr;
}
}
#endregion
//
// Creates fully resolved expression switcher
//
+22 -6
View File
@@ -510,10 +510,18 @@ namespace Mono.CSharp {
}
//
// Is the member of the correct type ?
// Destructors are ignored as they cannot be overridden by user
// Is the member of same type ?
//
if ((entry.Kind & ~MemberKind.Destructor & mkind & MemberKind.MaskType) == 0) {
if ((entry.Kind & MemberKind.Destructor) == 0 && (member_param == null || !(entry is IParametersMember))) {
// Destructors are ignored as they cannot be overridden by user
if ((entry.Kind & MemberKind.Destructor) != 0)
continue;
// Only different arity methods hide
if (mkind != MemberKind.Method && member.MemberName.Arity != entry.Arity)
continue;
if ((member_param == null || !(entry is IParametersMember))) {
bestCandidate = entry;
return null;
}
@@ -535,13 +543,21 @@ namespace Mono.CSharp {
continue;
var pm = entry as IParametersMember;
if (pm == null)
continue;
AParametersCollection entry_parameters;
if (pm == null) {
if (entry.Kind != MemberKind.Delegate)
continue;
// TODO: I don't have DelegateSpec
entry_parameters = Delegate.GetParameters (member.Compiler, (TypeSpec) entry);
} else {
entry_parameters = pm.Parameters;
}
if (entry.IsAccessor != member is AbstractPropertyEventMethod)
continue;
if (!TypeSpecComparer.Override.IsEqual (pm.Parameters, member_param))
if (!TypeSpecComparer.Override.IsEqual (entry_parameters, member_param))
continue;
}
+8 -4
View File
@@ -16,9 +16,10 @@ Version: @VERSION@
Release: 0
Source0: mono-%{version}.tar.bz2
BuildRequires: bison
BuildRequires: gcc-c++
BuildRequires: fdupes
BuildRequires: gcc-c++
BuildRequires: pkgconfig
BuildRequires: xorg-x11-libX11-devel
BuildRequires: zlib-devel
%ifnarch ia64
BuildRequires: valgrind-devel
@@ -96,6 +97,9 @@ export PATH=/opt/novell/llvm-mono/bin:$PATH
%if %llvm == yes
--enable-loadedllvm \
--disable-system-aot \
%endif
%ifnarch %ix86 x86_64
--disable-system-aot \
%endif
--with-ikvm=yes \
--with-moonlight=no
@@ -755,7 +759,6 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/2.0/System.Runtime.Remoting.dll
%_prefix/lib/mono/2.0/System.Runtime.Serialization.Formatters.Soap.dll
%_prefix/lib/mono/2.0/System.Web.Abstractions.dll
%_prefix/lib/mono/2.0/System.Web.DynamicData.dll
%_prefix/lib/mono/2.0/System.Web.Routing.dll
%_prefix/lib/mono/2.0/System.Web.Services.dll
%_prefix/lib/mono/2.0/System.Web.dll
@@ -769,7 +772,6 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/4.0/System.Runtime.Serialization.Formatters.Soap.dll
%_prefix/lib/mono/4.0/System.Web.Abstractions.dll
%_prefix/lib/mono/4.0/System.Web.ApplicationServices.dll
%_prefix/lib/mono/4.0/System.Web.DynamicData.dll
%_prefix/lib/mono/4.0/System.Web.Routing.dll
%_prefix/lib/mono/4.0/System.Web.Services.dll
%_prefix/lib/mono/4.0/System.Web.dll
@@ -787,7 +789,6 @@ Mono implementation of ASP.NET, Remoting and Web Services.
%_prefix/lib/mono/gac/System.Web
%_prefix/lib/mono/gac/System.Web.Abstractions
%_prefix/lib/mono/gac/System.Web.ApplicationServices
%_prefix/lib/mono/gac/System.Web.DynamicData
%_prefix/lib/mono/gac/System.Web.Routing
%_prefix/lib/mono/gac/System.Web.Services
@@ -812,15 +813,18 @@ Mono implementation of ASP.NET MVC.
%_libdir/pkgconfig/system.web.extensions_1.0.pc
%_libdir/pkgconfig/system.web.mvc.pc
%_libdir/pkgconfig/system.web.mvc2.pc
%_prefix/lib/mono/2.0/System.Web.DynamicData.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/2.0/System.Web.Extensions.dll
%_prefix/lib/mono/2.0/System.Web.Mvc.dll
%_prefix/lib/mono/3.5/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/System.Web.DynamicData.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/4.0/System.Web.Extensions.dll
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.Design.dll
%_prefix/lib/mono/compat-2.0/System.Web.Extensions.dll
%_prefix/lib/mono/compat-2.0/System.Web.Mvc.dll
%_prefix/lib/mono/gac/System.Web.DynamicData
%_prefix/lib/mono/gac/System.Web.Extensions
%_prefix/lib/mono/gac/System.Web.Extensions.Design
%_prefix/lib/mono/gac/System.Web.Mvc
+17 -4
View File
@@ -124,6 +124,10 @@ struct _WapiFileShareLayout *_wapi_fileshare_layout = NULL;
* 4MB array.
*/
static GHashTable *file_share_hash;
static CRITICAL_SECTION file_share_hash_mutex;
#define file_share_hash_lock() EnterCriticalSection (&file_share_hash_mutex)
#define file_share_hash_unlock() LeaveCriticalSection (&file_share_hash_mutex)
guint32 _wapi_fd_reserve;
@@ -220,8 +224,10 @@ static void handle_cleanup (void)
_wapi_shm_detach (WAPI_SHM_DATA);
_wapi_shm_detach (WAPI_SHM_FILESHARE);
if (file_share_hash)
if (file_share_hash) {
g_hash_table_destroy (file_share_hash);
DeleteCriticalSection (&file_share_hash_mutex);
}
for (i = 0; i < _WAPI_PRIVATE_MAX_SLOTS; ++i)
g_free (_wapi_private_handles [i]);
@@ -1643,9 +1649,9 @@ void
_wapi_free_share_info (_WapiFileShare *share_info)
{
if (!_wapi_shm_enabled ()) {
_wapi_handle_lock_shared_handles ();
file_share_hash_lock ();
g_hash_table_remove (file_share_hash, share_info);
_wapi_handle_unlock_shared_handles ();
file_share_hash_unlock ();
} else {
memset (share_info, '\0', sizeof(struct _WapiFileShare));
}
@@ -1697,11 +1703,16 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
* info. This is needed even if SHM is disabled, to track sharing inside
* the current process.
*/
if (!file_share_hash)
if (!file_share_hash) {
file_share_hash = g_hash_table_new_full (wapi_share_info_hash, wapi_share_info_equal, NULL, g_free);
InitializeCriticalSection (&file_share_hash_mutex);
}
tmp.device = device;
tmp.inode = inode;
file_share_hash_lock ();
file_share = g_hash_table_lookup (file_share_hash, &tmp);
if (file_share) {
*old_sharemode = file_share->sharemode;
@@ -1723,6 +1734,8 @@ gboolean _wapi_handle_get_or_set_share (dev_t device, ino_t inode,
g_hash_table_insert (file_share_hash, file_share, file_share);
}
file_share_hash_unlock ();
} else {
/* If a linear scan gets too slow we'll have to fit a hash
* table onto the shared mem backing store
+1 -5
View File
@@ -17,12 +17,8 @@
#define _WAPI_PROCESS_CURRENT (gpointer)0xFFFFFFFF
/* This marks a system process that we don't have a handle on */
/* FIXME: cope with pids > 16bit */
#if defined(__HAIKU__)
/* FIXME: cope with pids > 31bit? */
#define _WAPI_PROCESS_UNHANDLED_PID_MASK 0x7FFFFFFF
#else
#define _WAPI_PROCESS_UNHANDLED_PID_MASK 0x7FFF
#endif
#define _WAPI_PROCESS_UNHANDLED (-1 & ~_WAPI_PROCESS_UNHANDLED_PID_MASK)
extern gpointer _wapi_process_duplicate (void);
+13 -4
View File
@@ -1690,6 +1690,16 @@ static gboolean process_open_compare (gpointer handle, gpointer user_data)
}
}
gboolean CloseProcess(gpointer handle)
{
if ((GPOINTER_TO_UINT (handle) & _WAPI_PROCESS_UNHANDLED) == _WAPI_PROCESS_UNHANDLED) {
/* This is a pseudo handle */
return(TRUE);
}
return CloseHandle (handle);
}
gpointer OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_UNUSED, guint32 pid)
{
/* Find the process handle that corresponds to pid */
@@ -1701,10 +1711,9 @@ gpointer OpenProcess (guint32 req_access G_GNUC_UNUSED, gboolean inherit G_GNUC_
g_message ("%s: looking for process %d", __func__, pid);
#endif
if (_wapi_shm_enabled ())
handle = _wapi_search_handle (WAPI_HANDLE_PROCESS,
process_open_compare,
GUINT_TO_POINTER (pid), NULL, TRUE);
handle = _wapi_search_handle (WAPI_HANDLE_PROCESS,
process_open_compare,
GUINT_TO_POINTER (pid), NULL, TRUE);
if (handle == 0) {
#if defined(PLATFORM_MACOSX) || defined(__OpenBSD__)
if ((kill(pid, 0) == 0) || (errno == EPERM)) {
+1
View File
@@ -190,6 +190,7 @@ extern gpointer GetCurrentProcess (void);
extern guint32 GetProcessId (gpointer handle);
extern guint32 GetCurrentProcessId (void);
extern gboolean EnumProcesses (guint32 *pids, guint32 len, guint32 *needed);
extern gboolean CloseProcess (gpointer handle);
extern gpointer OpenProcess (guint32 access, gboolean inherit, guint32 pid);
extern gboolean GetExitCodeProcess (gpointer process, guint32 *code);
extern gboolean GetProcessTimes (gpointer process, WapiFileTime *create_time,
+4
View File
@@ -65,7 +65,11 @@ void ves_icall_System_Diagnostics_Process_Process_free_internal (MonoObject *thi
g_message ("%s: Closing process %p, handle %p", __func__, this, process);
#endif
#if TARGET_WIN32
CloseHandle (process);
#else
CloseProcess (process);
#endif
}
#define STASH_SYS_ASS(this) \
+1 -1
View File
@@ -906,7 +906,7 @@ mono_debugger_agent_cleanup (void)
//WaitForSingleObject (debugger_thread_handle, INFINITE);
if (GetCurrentThreadId () != debugger_thread_id) {
mono_mutex_lock (&debugger_thread_exited_mutex);
if (!debugger_thread_exited) {
while (!debugger_thread_exited) {
#ifdef HOST_WIN32
if (WAIT_TIMEOUT == WaitForSingleObject(debugger_thread_exited_cond, 0)) {
mono_mutex_unlock (&debugger_thread_exited_mutex);
+1 -1
View File
@@ -3792,7 +3792,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb)
*/
mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_SWITCH, ins->inst_p0);
max_len += 4 * GPOINTER_TO_INT (ins->klass);
if (offset > (cfg->code_size - max_len - 16)) {
if (offset + max_len > (cfg->code_size - 16)) {
cfg->code_size += max_len;
cfg->code_size *= 2;
cfg->native_code = g_realloc (cfg->native_code, cfg->code_size);