diff --git a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs index 6b23c74e8f..ac5fb9d9da 100644 --- a/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs +++ b/OpenSim/Framework/Data.MySQL/MySQLDatabaseMapper.cs @@ -3,7 +3,7 @@ using MySql.Data.MySqlClient; namespace OpenSim.Framework.Data.MySQL { - public class MySQLDatabaseMapper : OpenSimDatabaseMapper + public class MySQLDatabaseMapper : OpenSimDatabaseConnector { public MySQLDatabaseMapper(string connectionString) : base(connectionString) diff --git a/OpenSim/Framework/Data/OpenSimDataReader.cs b/OpenSim/Framework/Data/OpenSimDataReader.cs index 11a8b8bd46..518cdc9743 100644 --- a/OpenSim/Framework/Data/OpenSimDataReader.cs +++ b/OpenSim/Framework/Data/OpenSimDataReader.cs @@ -7,7 +7,7 @@ using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data { - public class OpenSimDataReader : DataReader + public class OpenSimDataReader : BaseDataReader { public OpenSimDataReader(IDataReader source) : base(source) { diff --git a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs similarity index 53% rename from OpenSim/Framework/Data/OpenSimDatabaseMapper.cs rename to OpenSim/Framework/Data/OpenSimDatabaseConnector.cs index 4f202bc8c0..ec80488568 100644 --- a/OpenSim/Framework/Data/OpenSimDatabaseMapper.cs +++ b/OpenSim/Framework/Data/OpenSimDatabaseConnector.cs @@ -1,12 +1,12 @@ -using System.Data.Common; +using System.Data; using libsecondlife; using TribalMedia.Framework.Data; namespace OpenSim.Framework.Data { - public abstract class OpenSimDatabaseMapper : BaseDatabaseConnector + public abstract class OpenSimDatabaseConnector : BaseDatabaseConnector { - public OpenSimDatabaseMapper(string connectionString) : base(connectionString) + public OpenSimDatabaseConnector(string connectionString) : base(connectionString) { } @@ -19,5 +19,10 @@ namespace OpenSim.Framework.Data return base.ConvertToDbType(value); } + + public override BaseDataReader CreateReader(IDataReader reader) + { + return new OpenSimDataReader(reader); + } } } diff --git a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs index d8c2ddf337..103de2d616 100644 --- a/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs +++ b/OpenSim/Framework/Data/OpenSimObjectFieldMapper.cs @@ -44,7 +44,7 @@ namespace OpenSim.Framework.Data } } - protected override object GetValue(DataReader reader) + protected override object GetValue(BaseDataReader reader) { object value; diff --git a/OpenSim/Framework/Data/OpenSimTableMapper.cs b/OpenSim/Framework/Data/OpenSimTableMapper.cs index a77936f319..744f0626da 100644 --- a/OpenSim/Framework/Data/OpenSimTableMapper.cs +++ b/OpenSim/Framework/Data/OpenSimTableMapper.cs @@ -8,10 +8,5 @@ namespace OpenSim.Framework.Data public OpenSimTableMapper(BaseDatabaseConnector database, string tableName) : base(database, tableName) { } - - protected override DataReader CreateReader(IDataReader reader) - { - return new OpenSimDataReader(reader); - } } } diff --git a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs index af49376521..c915538453 100644 --- a/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs +++ b/OpenSim/Framework/Data/PrimitiveBaseShapeTableMapper.cs @@ -5,11 +5,11 @@ using libsecondlife; namespace OpenSim.Framework.Data { - public class PrimitiveBaseShapeRowMapper : RowMapper + public class PrimitiveBaseShapeRowMapper : BaseRowMapper { public Guid SceneObjectPartId; - public PrimitiveBaseShapeRowMapper(Schema schema, PrimitiveBaseShape obj) : base(schema, obj) + public PrimitiveBaseShapeRowMapper(BaseSchema schema, PrimitiveBaseShape obj) : base(schema, obj) { } } @@ -19,7 +19,7 @@ namespace OpenSim.Framework.Data public PrimitiveBaseShapeTableMapper(BaseDatabaseConnector connection, string tableName) : base(connection, tableName) { - ObjectSchema rowMapperSchema = new ObjectSchema(this); + BaseSchema rowMapperSchema = new BaseSchema(this); m_schema = rowMapperSchema; m_keyFieldMapper = rowMapperSchema.AddMapping("SceneObjectPartId", @@ -111,7 +111,7 @@ namespace OpenSim.Framework.Data delegate(PrimitiveBaseShapeRowMapper shape, byte[] value) { shape.Object.ExtraParams = value; }); } - public override PrimitiveBaseShapeRowMapper FromReader(DataReader reader) + public override PrimitiveBaseShapeRowMapper FromReader(BaseDataReader reader) { PrimitiveBaseShape shape = new PrimitiveBaseShape(); diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index e74aee771e..d6c9d1d61c 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs @@ -416,7 +416,7 @@ namespace OpenSim.Region.ClientStack { // this will normally trigger at least one packet (ping response) SendStartPingCheck(0); - + } } else @@ -424,7 +424,7 @@ namespace OpenSim.Region.ClientStack // Something received in the meantime - we can reset the counters m_probesWithNoIngressPackets = 0; m_lastPacketsReceived = m_packetsReceived; - + } } @@ -2311,7 +2311,7 @@ namespace OpenSim.Region.ClientStack if (Pack.Header.Reliable) //DIRTY HACK { AddAck(Pack); // this adds the need to ack this packet later - + if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest) { @@ -2355,10 +2355,15 @@ namespace OpenSim.Region.ClientStack { lock (m_needAck) { - foreach (uint ack in NewPack.Header.AckList) + foreach (uint ackedPacketId in NewPack.Header.AckList) { - m_unAckedBytes -= m_needAck[ack].ToBytes().Length; - m_needAck.Remove(ack); + Packet ackedPacket; + + if (m_needAck.TryGetValue(ackedPacketId, out ackedPacket)) + { + m_unAckedBytes -= ackedPacket.ToBytes().Length; + m_needAck.Remove(ackedPacketId); + } } } } @@ -2373,18 +2378,12 @@ namespace OpenSim.Region.ClientStack { foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) { - if (m_needAck.ContainsKey(block.ID)) + uint ackedPackId = block.ID; + Packet ackedPacket; + if (m_needAck.TryGetValue(ackedPackId, out ackedPacket)) { - try - { - m_unAckedBytes -= m_needAck[block.ID].ToBytes().Length; - m_needAck.Remove(block.ID); - } - catch (System.Collections.Generic.KeyNotFoundException) - { - // Did another packet come in with the ack already? - // apparently so! - } + m_unAckedBytes -= ackedPacket.ToBytes().Length; + m_needAck.Remove(ackedPackId); } } } @@ -2500,11 +2499,11 @@ namespace OpenSim.Region.ClientStack protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) { - + SendAcks(); ResendUnacked(); SendPacketStats(); - + } protected void SendPacketStats() diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs index 34f894c6c2..67fb7c191b 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDataReader.cs @@ -30,11 +30,11 @@ using System.IO; namespace TribalMedia.Framework.Data { - public class DataReader + public class BaseDataReader { private readonly IDataReader m_source; - public DataReader(IDataReader source) + public BaseDataReader(IDataReader source) { m_source = source; } diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs index ae70fc1fe3..e5d4d62066 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseDatabaseConnector.cs @@ -135,5 +135,7 @@ namespace TribalMedia.Framework.Data { return value; } + + public abstract BaseDataReader CreateReader(IDataReader reader); } } \ No newline at end of file diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs index 20d8cf1762..20f919a7f5 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseFieldMapper.cs @@ -29,10 +29,7 @@ using System.Collections.Generic; using System.Data.Common; namespace TribalMedia.Framework.Data -{ - //public delegate TField RowMapperGetAccessor(TRowMapper rowMapper); - //public delegate void RowMapperSetAccessor(TRowMapper rowMapper, TField value); - +{ public delegate TField ObjectGetAccessor(TObj obj); public delegate void ObjectSetAccessor(TObj obj, TField value); @@ -62,7 +59,7 @@ namespace TribalMedia.Framework.Data m_tableMapper = tableMapper; } - public abstract void SetPropertyFromReader(object mapper, DataReader reader); + public abstract void SetPropertyFromReader(object mapper, BaseDataReader reader); public void RawAddParam(DbCommand command, List fieldNames, string fieldName, object value) { @@ -84,7 +81,7 @@ namespace TribalMedia.Framework.Data RawAddParam(command, fieldNames, fieldName, m_tableMapper.ConvertToDbType(value)); } - protected virtual object GetValue(DataReader reader) + protected virtual object GetValue(BaseDataReader reader) { object value; @@ -128,43 +125,6 @@ namespace TribalMedia.Framework.Data } } - //public class RowMapperField : FieldMapper - // where TRowMapper : RowMapper - //{ - // private readonly RowMapperGetAccessor m_fieldGetAccessor; - // private readonly RowMapperSetAccessor m_fieldSetAccessor; - - // public override object GetParamValue(object obj) - // { - // return m_fieldGetAccessor((TRowMapper) obj); - // } - - // public override void SetPropertyFromReader(object mapper, DataReader reader) - // { - // object value; - - // value = GetValue(reader); - - // if (value == null) - // { - // m_fieldSetAccessor((TRowMapper) mapper, default(TField)); - // } - // else - // { - // m_fieldSetAccessor((TRowMapper) mapper, (TField) value); - // } - // } - - - // public RowMapperField(TableMapper tableMapper, string fieldName, RowMapperGetAccessor rowMapperGetAccessor, - // RowMapperSetAccessor rowMapperSetAccessor) - // : base(tableMapper, fieldName, typeof(TField)) - // { - // m_fieldGetAccessor = rowMapperGetAccessor; - // m_fieldSetAccessor = rowMapperSetAccessor; - // } - //} - public class ObjectField : BaseFieldMapper { private readonly ObjectGetAccessor m_fieldGetAccessor; @@ -175,7 +135,7 @@ namespace TribalMedia.Framework.Data return m_fieldGetAccessor((TObject)obj); } - public override void SetPropertyFromReader(object obj, DataReader reader) + public override void SetPropertyFromReader(object obj, BaseDataReader reader) { object value; diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs index 2ab8daf6dc..e8292fd1a0 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseRowMapper.cs @@ -28,14 +28,14 @@ using TribalMedia.Framework.Data; namespace TribalMedia.Framework.Data { - public abstract class RowMapper + public abstract class BaseRowMapper { - public abstract void FillObject(DataReader reader); + public abstract void FillObject(BaseDataReader reader); } - public class ObjectMapper : RowMapper + public class BaseRowMapper : BaseRowMapper { - private readonly Schema m_schema; + private readonly BaseSchema m_schema; private readonly TObj m_obj; public TObj Object @@ -43,38 +43,13 @@ namespace TribalMedia.Framework.Data get { return m_obj; } } - public ObjectMapper(Schema schema, TObj obj) + public BaseRowMapper(BaseSchema schema, TObj obj) { m_schema = schema; m_obj = obj; } - public override void FillObject(DataReader reader) - { - foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) - { - fieldMapper.SetPropertyFromReader(m_obj, reader); - } - } - } - - public class RowMapper : RowMapper - { - private readonly Schema m_schema; - private readonly TObj m_obj; - - public TObj Object - { - get { return m_obj; } - } - - public RowMapper(Schema schema, TObj obj) - { - m_schema = schema; - m_obj = obj; - } - - public override void FillObject(DataReader reader) + public override void FillObject(BaseDataReader reader) { foreach (BaseFieldMapper fieldMapper in m_schema.Fields.Values) { diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs index fc59f3b0d5..a6740c2bcd 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseSchema.cs @@ -29,7 +29,7 @@ using TribalMedia.Framework.Data; namespace TribalMedia.Framework.Data { - public class Schema + public class BaseSchema { protected BaseTableMapper m_tableMapper; protected Dictionary m_mappings; @@ -39,16 +39,16 @@ namespace TribalMedia.Framework.Data get { return m_mappings; } } - public Schema(BaseTableMapper tableMapper) + public BaseSchema(BaseTableMapper tableMapper) { m_mappings = new Dictionary(); m_tableMapper = tableMapper; } } - public class ObjectSchema : Schema + public class BaseSchema : BaseSchema { - public ObjectSchema(BaseTableMapper tableMapper) + public BaseSchema(BaseTableMapper tableMapper) : base(tableMapper) { } @@ -65,26 +65,4 @@ namespace TribalMedia.Framework.Data return rowMapperField; } } - - //public class RowMapperSchema : Schema - // where TRowMapper : RowMapper - //{ - // public RowMapperSchema(TableMapper tableMapper) : base(tableMapper) - // { - // } - - // public RowMapperField AddMapping(string fieldName, - // RowMapperGetAccessor - // rowMapperGetAccessor, - // RowMapperSetAccessor - // rowMapperSetAccessor) - // { - // RowMapperField rowMapperField = - // new RowMapperField(m_tableMapper, fieldName, rowMapperGetAccessor, rowMapperSetAccessor); - - // m_mappings.Add(fieldName, rowMapperField); - - // return rowMapperField; - // } - //} } \ No newline at end of file diff --git a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs index e4fe0fdd8d..e4ea055ed3 100644 --- a/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs +++ b/ThirdParty/TribalMedia/TribalMedia.Framework.Data/BaseTableMapper.cs @@ -62,8 +62,8 @@ namespace TribalMedia.Framework.Data get { return m_tableName; } } - protected Schema m_schema; - public Schema Schema + protected BaseSchema m_schema; + public BaseSchema Schema { get { return m_schema; } } @@ -110,9 +110,9 @@ namespace TribalMedia.Framework.Data return m_database.ConvertToDbType(value); } - protected virtual DataReader CreateReader(IDataReader reader) + protected virtual BaseDataReader CreateReader(IDataReader reader) { - return new DataReader(reader); + return m_database.CreateReader(reader); } } @@ -138,7 +138,7 @@ namespace TribalMedia.Framework.Data { if (reader.Read()) { - result = FromReader(CreateReader(reader)); + result = FromReader( CreateReader(reader)); success = true; } else @@ -240,6 +240,6 @@ namespace TribalMedia.Framework.Data } } - public abstract TRowMapper FromReader(DataReader reader); + public abstract TRowMapper FromReader(BaseDataReader reader); } } \ No newline at end of file