Use an integer when specifying the XWorkItem wait rather than a TimeSpan to avoid a Windows casting issue in SmartThreadPool for large TimeSpans.
TimeSpan.Milliseconds is an int64. However, STP casts this to an int (32-bit). If TimeSpan.MaxValue is given then the casting results in an invalid value for the SDK WaitHandle.WaitAll() call. This was causing the co-op script termination regression tests to fail on Windows but not Mono 2.10.8 (which is perhaps not strict in the negative values that it accepts). Solution here is to use the int millisecondsTimeout STP call rather than the TimeSpan one. This also allows us to more clearly specify Timeout.Infinite rather than TimeSpan.MaxValue Thanks to Teravus for this spot.0.7.4-extended
parent
b1740e11de
commit
7cacf5f8a0
|
@ -52,7 +52,12 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
|
||||||
{
|
{
|
||||||
bool Cancel();
|
bool Cancel();
|
||||||
void Abort();
|
void Abort();
|
||||||
bool Wait(TimeSpan t);
|
|
||||||
|
/// <summary>
|
||||||
|
/// Wait for the work item to complete.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name='t'>The number of milliseconds to wait. Must be >= -1 (Timeout.Infinite).</param>
|
||||||
|
bool Wait(int t);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -595,7 +595,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
if (!m_coopTermination)
|
if (!m_coopTermination)
|
||||||
{
|
{
|
||||||
// If we're not co-operative terminating then try and wait for the event to complete before stopping
|
// If we're not co-operative terminating then try and wait for the event to complete before stopping
|
||||||
if (workItem.Wait(new TimeSpan((long)timeout * 100000)))
|
if (workItem.Wait(timeout))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -610,7 +610,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
|
||||||
|
|
||||||
// For now, we will wait forever since the event should always cleanly terminate once LSL loop
|
// For now, we will wait forever since the event should always cleanly terminate once LSL loop
|
||||||
// checking is implemented. May want to allow a shorter timeout option later.
|
// checking is implemented. May want to allow a shorter timeout option later.
|
||||||
if (workItem.Wait(TimeSpan.MaxValue))
|
if (workItem.Wait(Timeout.Infinite))
|
||||||
{
|
{
|
||||||
if (DebugLevel >= 1)
|
if (DebugLevel >= 1)
|
||||||
m_log.DebugFormat(
|
m_log.DebugFormat(
|
||||||
|
|
|
@ -57,8 +57,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
||||||
wr.Abort();
|
wr.Abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Wait(TimeSpan t)
|
public bool Wait(int t)
|
||||||
{
|
{
|
||||||
|
// We use the integer version of WaitAll because the current version of SmartThreadPool has a bug with the
|
||||||
|
// TimeSpan version. The number of milliseconds in TimeSpan is an int64 so when STP casts it down to an
|
||||||
|
// int (32-bit) we can end up with bad values. This occurs on Windows though curious not on Mono 2.10.8
|
||||||
|
// (or very likely other versions of Mono at least up until 3.0.3).
|
||||||
return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false);
|
return SmartThreadPool.WaitAll(new IWorkItemResult[] {wr}, t, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue