Merge branch 'master' into vehicles

0.6.8-post-fixes
Melanie 2009-10-06 17:44:59 +01:00
commit 0374f1b144
22 changed files with 256 additions and 140 deletions

View File

@ -55,39 +55,41 @@ namespace OpenSim.Data.MySQL
AuthenticationData ret = new AuthenticationData();
ret.Data = new Dictionary<string, object>();
using (MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID"))
MySqlCommand cmd = new MySqlCommand("select * from `" + m_Realm + "` where UUID = ?principalID");
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
IDataReader result = ExecuteReader(cmd);
if (result.Read())
{
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
ret.PrincipalID = principalID;
using (IDataReader result = ExecuteReader(cmd))
if (m_ColumnNames == null)
{
if (result.Read())
{
ret.PrincipalID = principalID;
m_ColumnNames = new List<string>();
if (m_ColumnNames == null)
{
m_ColumnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
foreach (string s in m_ColumnNames)
{
if (s == "UUID")
continue;
ret.Data[s] = result[s].ToString();
}
return ret;
}
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
}
return null;
foreach (string s in m_ColumnNames)
{
if (s == "UUID")
continue;
ret.Data[s] = result[s].ToString();
}
CloseDBConnection(result, cmd);
return ret;
}
else
{
CloseDBConnection(result, cmd);
return null;
}
}
public bool Store(AuthenticationData data)

View File

@ -40,14 +40,15 @@ namespace OpenSim.Data.MySQL
/// </summary>
public class MySqlFramework
{
private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog m_log =
log4net.LogManager.GetLogger(
System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
protected MySqlConnection m_Connection;
protected MySqlFramework(string connectionString)
{
m_Connection = new MySqlConnection(connectionString);
m_Connection.Open();
}
@ -82,8 +83,8 @@ namespace OpenSim.Data.MySQL
errorSeen = true;
m_Connection.Close();
MySqlConnection newConnection = (MySqlConnection)
((ICloneable)m_Connection).Clone();
MySqlConnection newConnection =
(MySqlConnection)((ICloneable)m_Connection).Clone();
m_Connection.Dispose();
m_Connection = newConnection;
m_Connection.Open();
@ -104,14 +105,19 @@ namespace OpenSim.Data.MySQL
protected IDataReader ExecuteReader(MySqlCommand cmd)
{
MySqlConnection newConnection = (MySqlConnection)
((ICloneable)m_Connection).Clone();
MySqlConnection newConnection =
(MySqlConnection)((ICloneable)m_Connection).Clone();
newConnection.Open();
cmd.Connection = newConnection;
return cmd.ExecuteReader();
}
protected void CloseDBConnection(IDataReader reader, MySqlCommand cmd)
{
reader.Close();
cmd.Connection.Close();
cmd.Connection.Dispose();
}
}
}

View File

@ -172,6 +172,8 @@ namespace OpenSim.Data.MySQL
retList.Add(ret);
}
CloseDBConnection(result, cmd);
}
return retList;

View File

@ -64,45 +64,47 @@ namespace OpenSim.Data.MySQL
if (scopeID != UUID.Zero)
command += " and ScopeID = ?scopeID";
using (MySqlCommand cmd = new MySqlCommand(command))
MySqlCommand cmd = new MySqlCommand(command);
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
IDataReader result = ExecuteReader(cmd);
if (result.Read())
{
cmd.Parameters.AddWithValue("?principalID", principalID.ToString());
cmd.Parameters.AddWithValue("?scopeID", scopeID.ToString());
ret.PrincipalID = principalID;
UUID scope;
UUID.TryParse(result["ScopeID"].ToString(), out scope);
ret.ScopeID = scope;
using (IDataReader result = ExecuteReader(cmd))
if (m_ColumnNames == null)
{
if (result.Read())
{
ret.PrincipalID = principalID;
UUID scope;
UUID.TryParse(result["ScopeID"].ToString(), out scope);
ret.ScopeID = scope;
m_ColumnNames = new List<string>();
if (m_ColumnNames == null)
{
m_ColumnNames = new List<string>();
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
foreach (string s in m_ColumnNames)
{
if (s == "UUID")
continue;
if (s == "ScopeID")
continue;
ret.Data[s] = result[s].ToString();
}
return ret;
}
DataTable schemaTable = result.GetSchemaTable();
foreach (DataRow row in schemaTable.Rows)
m_ColumnNames.Add(row["ColumnName"].ToString());
}
}
return null;
foreach (string s in m_ColumnNames)
{
if (s == "UUID")
continue;
if (s == "ScopeID")
continue;
ret.Data[s] = result[s].ToString();
}
CloseDBConnection(result, cmd);
return ret;
}
else
{
CloseDBConnection(result, cmd);
return null;
}
}
public bool Store(UserAccountData data)

View File

@ -318,11 +318,11 @@ namespace OpenSim.Framework.Communications
HttpWebResponse errorResponse = e.Response as HttpWebResponse;
if (null != errorResponse && HttpStatusCode.NotFound == errorResponse.StatusCode)
{
m_log.Warn("[ASSET] Asset not found (404)");
m_log.Warn("[REST CLIENT] Resource not found (404)");
}
else
{
m_log.Error("[ASSET] Error fetching asset from asset server");
m_log.Error("[REST CLIENT] Error fetching resource from server " + _request.Address.ToString());
m_log.Debug(e.ToString());
}

View File

@ -238,7 +238,7 @@ namespace OpenSim.Framework.Servers
List<Thread> threads = ThreadTracker.GetThreads();
if (threads == null)
{
sb.Append("Thread tracking is only enabled in DEBUG mode.");
sb.Append("OpenSim thread tracking is only enabled in DEBUG mode.");
}
else
{
@ -264,6 +264,12 @@ namespace OpenSim.Framework.Servers
}
}
}
int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0;
ThreadPool.GetAvailableThreads(out workers, out ports);
ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts);
sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine);
sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine);
return sb.ToString();
}

View File

@ -28,14 +28,21 @@
using System;
using System.IO;
using System.Net;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using log4net;
namespace OpenSim.Framework.Servers.HttpServer
{
public class SynchronousRestFormsRequester
{
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
/// <summary>
/// Perform a synchronous REST request.
/// </summary>
@ -72,8 +79,9 @@ namespace OpenSim.Framework.Servers.HttpServer
requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length);
}
catch
catch (Exception e)
{
m_log.DebugFormat("[FORMS]: exception occured on sending request {0}", e.Message);
}
finally
{
@ -102,7 +110,10 @@ namespace OpenSim.Framework.Servers.HttpServer
respstring = reader.ReadToEnd();
}
}
catch { }
catch (Exception e)
{
m_log.DebugFormat("[FORMS]: exception occured on receiving reply {0}", e.Message);
}
finally
{
if (respStream != null)
@ -114,6 +125,7 @@ namespace OpenSim.Framework.Servers.HttpServer
catch (System.InvalidOperationException)
{
// This is what happens when there is invalid XML
m_log.DebugFormat("[FORMS]: InvalidOperationException on receiving request");
}
return respstring;
}

View File

@ -88,7 +88,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
J2KImage imgrequest;
// Do a linear search for this texture download
lock (m_priorityQueue)
lock (m_syncRoot)
m_priorityQueue.Find(delegate(J2KImage img) { return img.TextureID == newRequest.RequestedAssetID; }, out imgrequest);
if (imgrequest != null)
@ -99,7 +99,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
try
{
lock (m_priorityQueue)
lock (m_syncRoot)
m_priorityQueue.Delete(imgrequest.PriorityQueueHandle);
}
catch (Exception) { }
@ -211,7 +211,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
J2KImage image = null;
lock (m_priorityQueue)
lock (m_syncRoot)
{
if (m_priorityQueue.Count > 0)
@ -230,23 +230,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
image.PriorityQueueHandle = null;
lock (m_priorityQueue)
m_priorityQueue.Add(ref image.PriorityQueueHandle, image);
lock (m_syncRoot)
try
{
m_priorityQueue.Add(ref image.PriorityQueueHandle, image);
}
catch (Exception) { }
}
void RemoveImageFromQueue(J2KImage image)
{
try
{
lock (m_priorityQueue)
lock (m_syncRoot)
try
{
m_priorityQueue.Delete(image.PriorityQueueHandle);
}
catch (Exception) { }
}
catch (Exception) { }
}
void UpdateImageInQueue(J2KImage image)
{
lock (m_priorityQueue)
lock (m_syncRoot)
{
try { m_priorityQueue.Replace(image.PriorityQueueHandle, image); }
catch (Exception)

View File

@ -178,7 +178,7 @@ namespace OpenSim.Region.CoreModules.Asset
{
if (maximalSize <= 0 || maximalCount <= 0)
{
Log.Info("[ASSET CACHE]: Cenome asset cache is not enabled.");
//Log.Debug("[ASSET CACHE]: Cenome asset cache is not enabled.");
m_enabled = false;
return;
}
@ -194,7 +194,7 @@ namespace OpenSim.Region.CoreModules.Asset
CnmSynchronizedCache<string, AssetBase>.Synchronized(new CnmMemoryCache<string, AssetBase>(
maximalSize, maximalCount, expirationTime));
m_enabled = true;
Log.InfoFormat(
Log.DebugFormat(
"[ASSET CACHE]: Cenome asset cache enabled (MaxSize = {0} bytes, MaxCount = {1}, ExpirationTime = {2})",
maximalSize,
maximalCount,
@ -263,7 +263,7 @@ namespace OpenSim.Region.CoreModules.Asset
if (m_getCount == m_debugEpoch)
{
Log.InfoFormat(
Log.DebugFormat(
"[ASSET CACHE]: Cached = {0}, Get = {1}, Hits = {2}%, Size = {3} bytes, Avg. A. Size = {4} bytes",
m_cachedCount,
m_getCount,
@ -333,7 +333,7 @@ namespace OpenSim.Region.CoreModules.Asset
return;
string name = moduleConfig.GetString("AssetCaching");
Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
//Log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
if (name != Name)
return;
@ -343,14 +343,14 @@ namespace OpenSim.Region.CoreModules.Asset
int maxCount = DefaultMaxCount;
TimeSpan expirationTime = DefaultExpirationTime;
IConfig assetConfig = source.Configs[ "AssetCache" ];
IConfig assetConfig = source.Configs["AssetCache"];
if (assetConfig != null)
{
// Get optional configurations
maxSize = assetConfig.GetLong("MaxSize", DefaultMaxSize);
maxCount = assetConfig.GetInt("MaxCount", DefaultMaxCount);
expirationTime =
TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int) DefaultExpirationTime.TotalMinutes));
TimeSpan.FromMinutes(assetConfig.GetInt("ExpirationTime", (int)DefaultExpirationTime.TotalMinutes));
// Debugging purposes only
m_debugEpoch = assetConfig.GetInt("DebugEpoch", 0);

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.Asset
if (moduleConfig != null)
{
string name = moduleConfig.GetString("AssetCaching");
m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
//m_log.DebugFormat("[XXX] name = {0} (this module's name: {1}", name, Name);
if (name == Name)
{

View File

@ -636,11 +636,8 @@ namespace Flotsam.RegionModules.AssetCache
m_log.InfoFormat("[FLOTSAM ASSET CACHE] flotsamcache clearfile - Remove all assets cached on disk");
}
}
#endregion
}
}
}

View File

@ -68,7 +68,7 @@ namespace OpenSim.Region.CoreModules.Asset
if (moduleConfig != null)
{
string name = moduleConfig.GetString("AssetCaching");
m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized);
//m_log.DebugFormat("[ASSET CACHE] name = {0} (this module's name: {1}). Sync? ", name, Name, m_Cache.IsSynchronized);
if (name == Name)
{

View File

@ -206,6 +206,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
public GridRegion GetRegionByPosition(UUID scopeID, int x, int y)
{
GridRegion region = null;
// First see if it's a neighbour, even if it isn't on this sim.
// Neighbour data is cached in memory, so this is fast
foreach (RegionCache rcache in m_LocalCache.Values)
{
region = rcache.GetRegionByPosition(x, y);
if (region != null)
{
return region;
}
}
// Then try on this sim (may be a lookup in DB if this is using MySql).
return m_GridService.GetRegionByPosition(scopeID, x, y);
}

View File

@ -29,10 +29,12 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
using OpenMetaverse;
using log4net;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
@ -75,5 +77,17 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
return new List<GridRegion>(m_neighbours.Values);
}
public GridRegion GetRegionByPosition(int x, int y)
{
uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize;
ulong handle = Utils.UIntsToLong(xsnap, ysnap);
if (m_neighbours.ContainsKey(handle))
return m_neighbours[handle];
return null;
}
}
}

View File

@ -137,6 +137,8 @@ namespace OpenSim.Region.Framework.Scenes
protected IAssetService m_AssetService = null;
protected IAuthorizationService m_AuthorizationService = null;
private Object m_heartbeatLock = new Object();
public IAssetService AssetService
{
get
@ -942,6 +944,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="e"></param>
private void Heartbeat(object sender)
{
if (!Monitor.TryEnter(m_heartbeatLock))
return;
try
{
Update();
@ -952,6 +957,11 @@ namespace OpenSim.Region.Framework.Scenes
catch (ThreadAbortException)
{
}
finally
{
Monitor.Pulse(m_heartbeatLock);
Monitor.Exit(m_heartbeatLock);
}
}
/// <summary>
@ -962,6 +972,12 @@ namespace OpenSim.Region.Framework.Scenes
int maintc = 0;
while (!shuttingdown)
{
//#if DEBUG
// int w = 0, io = 0;
// ThreadPool.GetAvailableThreads(out w, out io);
// if ((w < 10) || (io < 10))
// m_log.DebugFormat("[WARNING]: ThreadPool reaching exhaustion. workers = {0}; io = {1}", w, io);
//#endif
maintc = Environment.TickCount;
TimeSpan SinceLastFrame = DateTime.Now - m_lastupdate;

View File

@ -3488,7 +3488,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public override void UnCombine(PhysicsScene pScene)
{
IntPtr localGround = IntPtr.Zero;
float[] localHeightfield;
//float[] localHeightfield;
bool proceed = false;
List<IntPtr> geomDestroyList = new List<IntPtr>();
@ -3785,16 +3785,13 @@ namespace OpenSim.Region.Physics.OdePlugin
sides.Z = 0.5f;
ds.DrawBox(ref pos, ref R, ref sides);
}
}
}
}
public void start(int unused)
{
{
ds.SetViewpoint(ref xyz, ref hpr);
}
#endif

View File

@ -260,7 +260,7 @@ namespace OpenSim.Server.Base
public static Dictionary<string, object> ParseXmlResponse(string data)
{
//m_log.DebugFormat("[XXX]: received xml string: {0}", data);
m_log.DebugFormat("[XXX]: received xml string: {0}", data);
Dictionary<string, object> ret = new Dictionary<string, object>();

View File

@ -67,43 +67,50 @@ namespace OpenSim.Server.Handlers.Grid
//m_log.DebugFormat("[XXX]: query String: {0}", body);
Dictionary<string, string> request =
ServerUtils.ParseQueryString(body);
if (!request.ContainsKey("METHOD"))
return FailureResult();
string method = request["METHOD"];
switch (method)
try
{
case "register":
return Register(request);
Dictionary<string, string> request =
ServerUtils.ParseQueryString(body);
case "deregister":
return Deregister(request);
if (!request.ContainsKey("METHOD"))
return FailureResult();
case "get_neighbours":
return GetNeighbours(request);
string method = request["METHOD"];
case "get_region_by_uuid":
return GetRegionByUUID(request);
switch (method)
{
case "register":
return Register(request);
case "get_region_by_position":
return GetRegionByPosition(request);
case "deregister":
return Deregister(request);
case "get_region_by_name":
return GetRegionByName(request);
case "get_neighbours":
return GetNeighbours(request);
case "get_regions_by_name":
return GetRegionsByName(request);
case "get_region_by_uuid":
return GetRegionByUUID(request);
case "get_region_range":
return GetRegionRange(request);
case "get_region_by_position":
return GetRegionByPosition(request);
case "get_region_by_name":
return GetRegionByName(request);
case "get_regions_by_name":
return GetRegionsByName(request);
case "get_region_range":
return GetRegionRange(request);
}
m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID HANDLER]: Exception {0}", e);
}
m_log.DebugFormat("[GRID HANDLER]: unknown method {0} request {1}", method.Length, method);
return FailureResult();
}
@ -113,7 +120,7 @@ namespace OpenSim.Server.Handlers.Grid
byte[] Register(Dictionary<string, string> request)
{
UUID scopeID = UUID.Zero;
if (request["SCOPEID"] != null)
if (request.ContainsKey("SCOPEID"))
UUID.TryParse(request["SCOPEID"], out scopeID);
else
m_log.WarnFormat("[GRID HANDLER]: no scopeID in request to register region");
@ -137,11 +144,21 @@ namespace OpenSim.Server.Handlers.Grid
}
Dictionary<string, object> rinfoData = new Dictionary<string, object>();
foreach (KeyValuePair<string, string> kvp in request)
rinfoData[kvp.Key] = kvp.Value;
GridRegion rinfo = new GridRegion(rinfoData);
GridRegion rinfo = null;
try
{
foreach (KeyValuePair<string, string> kvp in request)
rinfoData[kvp.Key] = kvp.Value;
rinfo = new GridRegion(rinfoData);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e);
}
bool result = m_GridService.RegisterRegion(scopeID, rinfo);
bool result = false;
if (rinfo != null)
result = m_GridService.RegisterRegion(scopeID, rinfo);
if (result)
return SuccessResult();

View File

@ -109,8 +109,13 @@ namespace OpenSim.Services.Connectors
{
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if ((replyData["Result"] != null) && (replyData["Result"].ToString().ToLower() == "success"))
if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
return true;
else if (!replyData.ContainsKey("Result"))
m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
else
m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
}
else
m_log.DebugFormat("[GRID CONNECTOR]: RegisterRegion received null reply");

View File

@ -69,18 +69,40 @@ namespace OpenSim.Services.GridService
((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
{
// Region reregistering in other coordinates. Delete the old entry
m_Database.Delete(regionInfos.RegionID);
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) was previously registered at {2}-{3}. Deleting old entry.",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
try
{
m_Database.Delete(regionInfos.RegionID);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
}
}
// Everything is ok, let's register
RegionData rdata = RegionInfo2RegionData(regionInfos);
rdata.ScopeID = scopeID;
m_Database.Store(rdata);
try
{
m_Database.Store(rdata);
}
catch (Exception e)
{
m_log.DebugFormat("[GRID SERVICE]: Database exception: {0}", e);
}
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
return true;
}
public bool DeregisterRegion(UUID regionID)
{
m_log.DebugFormat("[GRID SERVICE]: Region {0} deregistered", regionID);
return m_Database.Delete(regionID);
}

View File

@ -312,7 +312,7 @@
; Uncomment below to enable llRemoteData/remote channels
; remoteDataPort = 20800
grid_server_url = "http://127.0.0.1:8001"
grid_server_url = "http://127.0.0.1:8003"
grid_send_key = "null"
grid_recv_key = "null"
@ -322,7 +322,7 @@
asset_server_url = "http://127.0.0.1:8003"
inventory_server_url = "http://127.0.0.1:8004"
inventory_server_url = "http://127.0.0.1:8003"
; The MessagingServer is a companion of the UserServer. It uses
; user_send_key and user_recv_key, too

View File

@ -13,13 +13,13 @@
;
; change this to your grid-wide inventory server
;
InventoryServerURI = "http://myinventoryserver.com:8004"
InventoryServerURI = "http://myinventoryserver.com:8003"
[GridService]
;
; change this to your grid-wide grid server
;
GridServerURI = "http://mygridserver.com:8001"
GridServerURI = "http://mygridserver.com:8003"
[Modules]
;; Choose 0 or 1 cache modules, and the corresponding config file, if it exists.