Changing Scene.ForEachClient to use the synchronous for loop instead of Parallel. This is quite possibly the source of some deadlocking, and at the very least the synchronous version gives better stack traces

* Lock the LLUDPClient RTO math * Add a helper function for backing off the RTO, and follow the optional advice in RFC 2988 to clear existing SRTT and RTTVAR values during a backoff

* Removing the unused PrimitiveBaseShape.SculptImage parameter * Improved performance of SceneObjectPart instantiation * ZeroMesher now drops SculptData bytes like Meshmerizer, to allow the texture data to be GCed * Improved typecasting speed in MySQLLegacyRegionData.BuildShape()

* Improved the instantiation of PrimitiveBaseShape
0.6.8-post-fixes
John Hurliman 2009-10-25 00:40:21 -07:00
parent 2c34619aea
commit 730930955a
10 changed files with 160 additions and 152 deletions

View File

@ -167,9 +167,6 @@ namespace OpenSim.Data.MySQL
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]);
}
}
if (asset != null)
UpdateAccessTime(asset);
}
catch (Exception e)
{

View File

@ -1430,37 +1430,36 @@ namespace OpenSim.Data.MySQL
{
PrimitiveBaseShape s = new PrimitiveBaseShape();
s.Scale = new Vector3(
Convert.ToSingle(row["ScaleX"]),
Convert.ToSingle(row["ScaleY"]),
Convert.ToSingle(row["ScaleZ"])
);
(float)(double)row["ScaleX"],
(float)(double)row["ScaleY"],
(float)(double)row["ScaleZ"]
);
// paths
s.PCode = Convert.ToByte(row["PCode"]);
s.PathBegin = Convert.ToUInt16(row["PathBegin"]);
s.PathEnd = Convert.ToUInt16(row["PathEnd"]);
s.PathScaleX = Convert.ToByte(row["PathScaleX"]);
s.PathScaleY = Convert.ToByte(row["PathScaleY"]);
s.PathShearX = Convert.ToByte(row["PathShearX"]);
s.PathShearY = Convert.ToByte(row["PathShearY"]);
s.PathSkew = Convert.ToSByte(row["PathSkew"]);
s.PathCurve = Convert.ToByte(row["PathCurve"]);
s.PathRadiusOffset = Convert.ToSByte(row["PathRadiusOffset"]);
s.PathRevolutions = Convert.ToByte(row["PathRevolutions"]);
s.PathTaperX = Convert.ToSByte(row["PathTaperX"]);
s.PathTaperY = Convert.ToSByte(row["PathTaperY"]);
s.PathTwist = Convert.ToSByte(row["PathTwist"]);
s.PathTwistBegin = Convert.ToSByte(row["PathTwistBegin"]);
s.PCode = (byte)(int)row["PCode"];
s.PathBegin = (ushort)(int)row["PathBegin"];
s.PathEnd = (ushort)(int)row["PathEnd"];
s.PathScaleX = (byte)(int)row["PathScaleX"];
s.PathScaleY = (byte)(int)row["PathScaleY"];
s.PathShearX = (byte)(int)row["PathShearX"];
s.PathShearY = (byte)(int)row["PathShearY"];
s.PathSkew = (sbyte)(int)row["PathSkew"];
s.PathCurve = (byte)(int)row["PathCurve"];
s.PathRadiusOffset = (sbyte)(int)row["PathRadiusOffset"];
s.PathRevolutions = (byte)(int)row["PathRevolutions"];
s.PathTaperX = (sbyte)(int)row["PathTaperX"];
s.PathTaperY = (sbyte)(int)row["PathTaperY"];
s.PathTwist = (sbyte)(int)row["PathTwist"];
s.PathTwistBegin = (sbyte)(int)row["PathTwistBegin"];
// profile
s.ProfileBegin = Convert.ToUInt16(row["ProfileBegin"]);
s.ProfileEnd = Convert.ToUInt16(row["ProfileEnd"]);
s.ProfileCurve = Convert.ToByte(row["ProfileCurve"]);
s.ProfileHollow = Convert.ToUInt16(row["ProfileHollow"]);
byte[] textureEntry = (byte[]) row["Texture"];
s.TextureEntry = textureEntry;
s.ProfileBegin = (ushort)(int)row["ProfileBegin"];
s.ProfileEnd = (ushort)(int)row["ProfileEnd"];
s.ProfileCurve = (byte)(int)row["ProfileCurve"];
s.ProfileHollow = (ushort)(int)row["ProfileHollow"];
s.TextureEntry = (byte[])row["Texture"];
s.ExtraParams = (byte[]) row["ExtraParams"];
s.ExtraParams = (byte[])row["ExtraParams"];
s.State = Convert.ToByte(row["State"]);
s.State = (byte)(int)row["State"];
return s;
}

View File

@ -76,7 +76,7 @@ namespace OpenSim.Framework
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly Primitive.TextureEntry m_defaultTexture;
private static readonly byte[] DEFAULT_TEXTURE = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f")).GetBytes();
private byte[] m_textureEntry;
@ -104,33 +104,32 @@ namespace OpenSim.Framework
private HollowShape _hollowShape;
// Sculpted
[XmlIgnore] private UUID _sculptTexture = UUID.Zero;
[XmlIgnore] private byte _sculptType = (byte)0;
[XmlIgnore] private byte[] _sculptData = new byte[0];
[XmlIgnore] private Image _sculptBitmap = null;
[XmlIgnore] private UUID _sculptTexture;
[XmlIgnore] private byte _sculptType;
[XmlIgnore] private byte[] _sculptData = Utils.EmptyBytes;
// Flexi
[XmlIgnore] private int _flexiSoftness = 0;
[XmlIgnore] private float _flexiTension = 0f;
[XmlIgnore] private float _flexiDrag = 0f;
[XmlIgnore] private float _flexiGravity = 0f;
[XmlIgnore] private float _flexiWind = 0f;
[XmlIgnore] private float _flexiForceX = 0f;
[XmlIgnore] private float _flexiForceY = 0f;
[XmlIgnore] private float _flexiForceZ = 0f;
[XmlIgnore] private int _flexiSoftness;
[XmlIgnore] private float _flexiTension;
[XmlIgnore] private float _flexiDrag;
[XmlIgnore] private float _flexiGravity;
[XmlIgnore] private float _flexiWind;
[XmlIgnore] private float _flexiForceX;
[XmlIgnore] private float _flexiForceY;
[XmlIgnore] private float _flexiForceZ;
//Bright n sparkly
[XmlIgnore] private float _lightColorR = 0f;
[XmlIgnore] private float _lightColorG = 0f;
[XmlIgnore] private float _lightColorB = 0f;
[XmlIgnore] private float _lightColorA = 1f;
[XmlIgnore] private float _lightRadius = 0f;
[XmlIgnore] private float _lightCutoff = 0f;
[XmlIgnore] private float _lightFalloff = 0f;
[XmlIgnore] private float _lightIntensity = 1f;
[XmlIgnore] private bool _flexiEntry = false;
[XmlIgnore] private bool _lightEntry = false;
[XmlIgnore] private bool _sculptEntry = false;
[XmlIgnore] private float _lightColorR;
[XmlIgnore] private float _lightColorG;
[XmlIgnore] private float _lightColorB;
[XmlIgnore] private float _lightColorA = 1.0f;
[XmlIgnore] private float _lightRadius;
[XmlIgnore] private float _lightCutoff;
[XmlIgnore] private float _lightFalloff;
[XmlIgnore] private float _lightIntensity = 1.0f;
[XmlIgnore] private bool _flexiEntry;
[XmlIgnore] private bool _lightEntry;
[XmlIgnore] private bool _sculptEntry;
public byte ProfileCurve
{
@ -172,17 +171,11 @@ namespace OpenSim.Framework
}
}
static PrimitiveBaseShape()
{
m_defaultTexture =
new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
}
public PrimitiveBaseShape()
{
PCode = (byte) PCodeEnum.Primitive;
ExtraParams = new byte[1];
Textures = m_defaultTexture;
m_textureEntry = DEFAULT_TEXTURE;
}
public PrimitiveBaseShape(bool noShape)
@ -192,7 +185,7 @@ namespace OpenSim.Framework
PCode = (byte)PCodeEnum.Primitive;
ExtraParams = new byte[1];
Textures = m_defaultTexture;
m_textureEntry = DEFAULT_TEXTURE;
}
[XmlIgnore]
@ -577,15 +570,6 @@ namespace OpenSim.Framework
}
}
public Image SculptBitmap {
get {
return _sculptBitmap;
}
set {
_sculptBitmap = value;
}
}
public int FlexiSoftness {
get {
return _flexiSoftness;

View File

@ -144,6 +144,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
private readonly OutgoingPacket[] m_nextPackets = new OutgoingPacket[THROTTLE_CATEGORY_COUNT];
/// <summary>A reference to the LLUDPServer that is managing this client</summary>
private readonly LLUDPServer m_udpServer;
/// <summary>Locks access to the variables used while calculating round-trip
/// packet times and the retransmission timeout</summary>
private readonly object m_roundTripCalcLock = new object();
/// <summary>
/// Default constructor
@ -484,28 +487,51 @@ namespace OpenSim.Region.ClientStack.LindenUDP
const float BETA = 0.25f;
const float K = 4.0f;
if (RTTVAR == 0.0f)
lock (m_roundTripCalcLock)
{
// First RTT measurement
SRTT = r;
RTTVAR = r * 0.5f;
}
else
{
// Subsequence RTT measurement
RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
}
if (RTTVAR == 0.0f)
{
// First RTT measurement
SRTT = r;
RTTVAR = r * 0.5f;
}
else
{
// Subsequence RTT measurement
RTTVAR = (1.0f - BETA) * RTTVAR + BETA * Math.Abs(SRTT - r);
SRTT = (1.0f - ALPHA) * SRTT + ALPHA * r;
}
RTO = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
int rto = (int)(SRTT + Math.Max(m_udpServer.TickCountResolution, K * RTTVAR));
// Clamp the retransmission timeout to manageable values
RTO = Utils.Clamp(RTO, 3000, 60000);
// Clamp the retransmission timeout to manageable values
rto = Utils.Clamp(RTO, 3000, 60000);
RTO = rto;
}
//m_log.Debug("[LLUDPCLIENT]: Setting agent " + this.Agent.FullName + "'s RTO to " + RTO + "ms with an RTTVAR of " +
// RTTVAR + " based on new RTT of " + r + "ms");
}
/// <summary>
/// Exponential backoff of the retransmission timeout, per section 5.5
/// of RFC 2988
/// </summary>
public void BackoffRTO()
{
lock (m_roundTripCalcLock)
{
// Reset SRTT and RTTVAR, we assume they are bogus since things
// didn't work out and we're backing off the timeout
SRTT = 0.0f;
RTTVAR = 0.0f;
// Double the retransmission timeout
RTO = Math.Min(RTO * 2, 60000);
}
}
/// <summary>
/// Does an early check to see if this queue empty callback is already
/// running, then asynchronously firing the event

View File

@ -431,8 +431,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_log.Debug("[LLUDPSERVER]: Resending " + expiredPackets.Count + " packets to " + udpClient.AgentID + ", RTO=" + udpClient.RTO);
// Backoff the RTO
udpClient.RTO = Math.Min(udpClient.RTO * 2, 60000);
// Exponential backoff of the retransmission timeout
udpClient.BackoffRTO();
// Resend packets
for (int i = 0; i < expiredPackets.Count; i++)

View File

@ -4246,7 +4246,7 @@ namespace OpenSim.Region.Framework.Scenes
public void ForEachClient(Action<IClientAPI> action)
{
ClientManager.ForEach(action);
ClientManager.ForEachSync(action);
}
public void ForEachSOG(Action<SceneObjectGroup> action)

View File

@ -1334,7 +1334,7 @@ namespace OpenSim.Region.Framework.Scenes
(parcel.LandData.GroupID != GroupID ||
parcel.LandData.GroupID == UUID.Zero))
{
if ((DateTime.Now - RootPart.Rezzed).TotalMinutes >
if ((DateTime.UtcNow - RootPart.Rezzed).TotalMinutes >
parcel.LandData.OtherCleanTime)
{
DetachFromBackup();

View File

@ -102,16 +102,16 @@ namespace OpenSim.Region.Framework.Scenes
#region Fields
public bool AllowedDrop = false;
public bool AllowedDrop;
[XmlIgnore]
public bool DIE_AT_EDGE = false;
public bool DIE_AT_EDGE;
// TODO: This needs to be persisted in next XML version update!
[XmlIgnore]
public int[] PayPrice = {-2,-2,-2,-2,-2};
public readonly int[] PayPrice = {-2,-2,-2,-2,-2};
[XmlIgnore]
public PhysicsActor PhysActor = null;
public PhysicsActor PhysActor;
//Xantor 20080528 Sound stuff:
// Note: This isn't persisted in the database right now, as the fields for that aren't just there yet.
@ -130,22 +130,22 @@ namespace OpenSim.Region.Framework.Scenes
public double SoundRadius;
[XmlIgnore]
public uint TimeStampFull = 0;
public uint TimeStampFull;
[XmlIgnore]
public uint TimeStampLastActivity = 0; // Will be used for AutoReturn
public uint TimeStampLastActivity; // Will be used for AutoReturn
[XmlIgnore]
public uint TimeStampTerse = 0;
public uint TimeStampTerse;
[XmlIgnore]
public UUID FromItemID = UUID.Zero;
public UUID FromItemID;
/// <value>
/// The UUID of the user inventory item from which this object was rezzed if this is a root part.
/// If UUID.Zero then either this is not a root part or there is no connection with a user inventory item.
/// </value>
private UUID m_fromUserInventoryItemID = UUID.Zero;
private UUID m_fromUserInventoryItemID;
[XmlIgnore]
public UUID FromUserInventoryItemID
@ -154,31 +154,32 @@ namespace OpenSim.Region.Framework.Scenes
}
[XmlIgnore]
public bool IsAttachment = false;
public bool IsAttachment;
[XmlIgnore]
public scriptEvents AggregateScriptEvents = 0;
public scriptEvents AggregateScriptEvents;
[XmlIgnore]
public UUID AttachedAvatar = UUID.Zero;
public UUID AttachedAvatar;
[XmlIgnore]
public Vector3 AttachedPos = Vector3.Zero;
public Vector3 AttachedPos;
[XmlIgnore]
public uint AttachmentPoint = (byte)0;
public uint AttachmentPoint;
[XmlIgnore]
public PhysicsVector RotationAxis = new PhysicsVector(1f,1f,1f);
public PhysicsVector RotationAxis = new PhysicsVector(1f, 1f, 1f);
[XmlIgnore]
public bool VolumeDetectActive = false; // XmlIgnore set to avoid problems with persistance until I come to care for this
// Certainly this must be a persistant setting finally
public bool VolumeDetectActive; // XmlIgnore set to avoid problems with persistance until I come to care for this
// Certainly this must be a persistant setting finally
[XmlIgnore]
public bool IsWaitingForFirstSpinUpdatePacket = false;
public bool IsWaitingForFirstSpinUpdatePacket;
[XmlIgnore]
public Quaternion SpinOldOrientation = new Quaternion();
public Quaternion SpinOldOrientation = Quaternion.Identity;
/// <summary>
/// This part's inventory
@ -191,34 +192,32 @@ namespace OpenSim.Region.Framework.Scenes
protected SceneObjectPartInventory m_inventory;
[XmlIgnore]
public bool Undoing = false;
public bool Undoing;
[XmlIgnore]
private PrimFlags LocalFlags = 0;
private PrimFlags LocalFlags;
[XmlIgnore]
private float m_damage = -1.0f;
private byte[] m_TextureAnimation;
private byte m_clickAction = 0;
private byte m_clickAction;
private Color m_color = Color.Black;
private string m_description = String.Empty;
private readonly List<uint> m_lastColliders = new List<uint>();
// private PhysicsVector m_lastRotationalVelocity = PhysicsVector.Zero;
private int m_linkNum = 0;
private int m_linkNum;
[XmlIgnore]
private int m_scriptAccessPin = 0;
private int m_scriptAccessPin;
[XmlIgnore]
private readonly Dictionary<UUID, scriptEvents> m_scriptEvents = new Dictionary<UUID, scriptEvents>();
private string m_sitName = String.Empty;
private Quaternion m_sitTargetOrientation = Quaternion.Identity;
private Vector3 m_sitTargetPosition = Vector3.Zero;
private Vector3 m_sitTargetPosition;
private string m_sitAnimation = "SIT";
private string m_text = String.Empty;
private string m_touchName = String.Empty;
private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
private UUID _creatorID;
private bool m_passTouches = false;
private bool m_passTouches;
/// <summary>
/// Only used internally to schedule client updates.
@ -236,28 +235,28 @@ namespace OpenSim.Region.Framework.Scenes
//unkown if this will be kept, added as a way of removing the group position from the group class
protected Vector3 m_groupPosition;
protected uint m_localId;
protected Material m_material = (Material)3; // Wood
protected Material m_material = OpenMetaverse.Material.Wood;
protected string m_name;
protected Vector3 m_offsetPosition;
// FIXME, TODO, ERROR: 'ParentGroup' can't be in here, move it out.
protected SceneObjectGroup m_parentGroup;
protected byte[] m_particleSystem = new byte[0];
protected byte[] m_particleSystem = Utils.EmptyBytes;
protected ulong m_regionHandle;
protected Quaternion m_rotationOffset;
protected PrimitiveBaseShape m_shape = null;
protected PrimitiveBaseShape m_shape;
protected UUID m_uuid;
protected Vector3 m_velocity;
// TODO: Those have to be changed into persistent properties at some later point,
// or sit-camera on vehicles will break on sim-crossing.
private Vector3 m_cameraEyeOffset = new Vector3(0.0f, 0.0f, 0.0f);
private Vector3 m_cameraAtOffset = new Vector3(0.0f, 0.0f, 0.0f);
private bool m_forceMouselook = false;
private Vector3 m_cameraEyeOffset;
private Vector3 m_cameraAtOffset;
private bool m_forceMouselook;
// TODO: Collision sound should have default.
private UUID m_collisionSound = UUID.Zero;
private float m_collisionSoundVolume = 0.0f;
private UUID m_collisionSound;
private float m_collisionSoundVolume;
#endregion Fields
@ -269,9 +268,9 @@ namespace OpenSim.Region.Framework.Scenes
public SceneObjectPart()
{
// It's not necessary to persist this
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
Rezzed = DateTime.Now;
m_TextureAnimation = Utils.EmptyBytes;
m_particleSystem = Utils.EmptyBytes;
Rezzed = DateTime.UtcNow;
m_inventory = new SceneObjectPartInventory(this);
}
@ -290,8 +289,8 @@ namespace OpenSim.Region.Framework.Scenes
{
m_name = "Primitive";
Rezzed = DateTime.Now;
_creationDate = (Int32) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
Rezzed = DateTime.UtcNow;
_creationDate = (int)Utils.DateTimeToUnixTime(Rezzed);
_ownerID = ownerID;
_creatorID = _ownerID;
_lastOwnerID = UUID.Zero;
@ -299,19 +298,19 @@ namespace OpenSim.Region.Framework.Scenes
Shape = shape;
// Todo: Add More Object Parameter from above!
_ownershipCost = 0;
_objectSaleType = (byte) 0;
_objectSaleType = 0;
_salePrice = 0;
_category = (uint) 0;
_category = 0;
_lastOwnerID = _creatorID;
// End Todo: ///
GroupPosition = groupPosition;
OffsetPosition = offsetPosition;
RotationOffset = rotationOffset;
Velocity = new Vector3(0, 0, 0);
AngularVelocity = new Vector3(0, 0, 0);
Acceleration = new Vector3(0, 0, 0);
m_TextureAnimation = new byte[0];
m_particleSystem = new byte[0];
Velocity = Vector3.Zero;
AngularVelocity = Vector3.Zero;
Acceleration = Vector3.Zero;
m_TextureAnimation = Utils.EmptyBytes;
m_particleSystem = Utils.EmptyBytes;
// Prims currently only contain a single folder (Contents). From looking at the Second Life protocol,
// this appears to have the same UUID (!) as the prim. If this isn't the case, one can't drag items from
@ -3548,7 +3547,7 @@ if (m_shape != null) {
// in SL.
//
if (ParentGroup.RootPart != this)
ParentGroup.RootPart.Rezzed = DateTime.Now;
ParentGroup.RootPart.Rezzed = DateTime.UtcNow;
ParentGroup.HasGroupChanged = true;
ScheduleFullUpdate();

View File

@ -67,6 +67,9 @@ namespace OpenSim.Region.Physics.Manager
public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical)
{
// Remove the reference to the encoded JPEG2000 data so it can be GCed
primShape.SculptData = OpenMetaverse.Utils.EmptyBytes;
return null;
}
}

View File

@ -281,7 +281,7 @@ namespace OpenSim.Region.Physics.Meshing
if (idata == null)
{
if (primShape.SculptData.Length == 0)
if (primShape.SculptData == null || primShape.SculptData.Length == 0)
return null;
try