summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cs/src/Ice/Assert.cs9
-rwxr-xr-xcs/test/Ice/faultTolerance/TestI.cs45
2 files changed, 39 insertions, 15 deletions
diff --git a/cs/src/Ice/Assert.cs b/cs/src/Ice/Assert.cs
index d443c394efc..1fedc044cfa 100644
--- a/cs/src/Ice/Assert.cs
+++ b/cs/src/Ice/Assert.cs
@@ -7,6 +7,8 @@
//
// **********************************************************************
+using IceInternal;
+
namespace IceUtil
{
@@ -16,12 +18,15 @@ namespace IceUtil
// In C#, it's not safe to call *anything* from within a finalizer
// because the finalizer may run as part of process shutdown, and
// order of finalization is undefined. So, we don't run assertions
- // once shutdown has started.
+ // once shutdown has started. Under Mono, this doesn't work:
+ // HasShutdownStarted becomes true eventually, but not until far too
+ // late. Sor, under Mono, assertions in finalizers are not checked
+ // at all :-(
//
public static void
FinalizerAssert(bool b)
{
- if(!b && !System.Environment.HasShutdownStarted)
+ if(!b && AssemblyUtil._platform == AssemblyUtil.Platform.Windows && !System.Environment.HasShutdownStarted)
{
System.Console.Error.WriteLine("Assertion failure:");
diff --git a/cs/test/Ice/faultTolerance/TestI.cs b/cs/test/Ice/faultTolerance/TestI.cs
index da74232a64c..76d96902a31 100755
--- a/cs/test/Ice/faultTolerance/TestI.cs
+++ b/cs/test/Ice/faultTolerance/TestI.cs
@@ -7,44 +7,62 @@
//
// **********************************************************************
+using System;
+using System.Diagnostics;
+using System.Threading;
+using IceInternal;
using Test;
public sealed class TestI : _TestIntfDisp
{
public TestI(Ice.ObjectAdapter adapter)
{
- _adapter = adapter;
- _pid = 0;
+ lock(this)
+ {
+ _adapter = adapter;
+ _p = Process.GetCurrentProcess();
+ _pid = _p.Id;
+ }
}
+ private void commitSuicide()
+ {
+ if(AssemblyUtil._platform == AssemblyUtil.Platform.NonWindows
+ && AssemblyUtil._runtime == AssemblyUtil.Runtime.Mono)
+ {
+ ProcessStartInfo info = new ProcessStartInfo("/usr/bin/kill");
+ info.CreateNoWindow = true;
+ info.Arguments = "-s 9 " + _pid;
+ Process.Start(info);
+ }
+ else
+ {
+ _p.Kill();
+ }
+ Thread.Sleep(5000); // Give other threads time to die.
+ }
+
public override void abort(Ice.Current current)
{
- System.Diagnostics.Process.GetCurrentProcess().Kill();
- System.Threading.Thread.Sleep(2000); // Sleep needed for Mono with RedHat 8 (no NPTL).
+ commitSuicide();
}
public override void idempotentAbort(Ice.Current current)
{
- System.Diagnostics.Process.GetCurrentProcess().Kill();
- System.Threading.Thread.Sleep(2000); // Sleep needed for Mono with RedHat 8 (no NPTL).
+ commitSuicide();
}
public override void nonmutatingAbort(Ice.Current current)
{
- System.Diagnostics.Process.GetCurrentProcess().Kill();
- System.Threading.Thread.Sleep(2000); // Sleep needed for Mono with RedHat 8 (no NPTL).
+ commitSuicide();
}
public override int pid(Ice.Current current)
{
lock(this)
{
- if(_pid == 0)
- {
- _pid = System.Diagnostics.Process.GetCurrentProcess().Id; // Very slow call, so we cache it
- }
+ return _pid;
}
- return _pid;
}
public override void shutdown(Ice.Current current)
@@ -53,5 +71,6 @@ public sealed class TestI : _TestIntfDisp
}
private Ice.ObjectAdapter _adapter;
+ private Process _p;
private int _pid;
}