Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim

bulletsim
Melanie 2011-05-13 12:03:16 +01:00
commit 59d8588ae1
9 changed files with 97 additions and 21 deletions

View File

@ -199,14 +199,14 @@ namespace OpenSim.Framework
using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress)) using (GZipStream comp = new GZipStream(ms, CompressionMode.Compress))
{ {
comp.Write(buffer, 0, buffer.Length); comp.Write(buffer, 0, buffer.Length);
comp.Flush(); // We need to close the gzip stream before we write it anywhere
// because apparently something important related to gzip compression
ms.Seek(0, SeekOrigin.Begin); // gets written on the strteam upon Dispose()
request.ContentLength = ms.Length; //Count bytes to send
using (Stream requestStream = request.GetRequestStream())
requestStream.Write(ms.ToArray(), 0, (int)ms.Length);
} }
byte[] buf = ms.ToArray();
request.ContentLength = buf.Length; //Count bytes to send
using (Stream requestStream = request.GetRequestStream())
requestStream.Write(buf, 0, (int)buf.Length);
} }
} }
else else
@ -918,6 +918,10 @@ namespace OpenSim.Framework
public class SynchronousRestObjectRequester public class SynchronousRestObjectRequester
{ {
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
/// <summary> /// <summary>
/// Perform a synchronous REST request. /// Perform a synchronous REST request.
/// </summary> /// </summary>
@ -961,8 +965,9 @@ namespace OpenSim.Framework
requestStream = request.GetRequestStream(); requestStream = request.GetRequestStream();
requestStream.Write(buffer.ToArray(), 0, length); requestStream.Write(buffer.ToArray(), 0, length);
} }
catch (Exception) catch (Exception e)
{ {
m_log.WarnFormat("[SynchronousRestObjectRequester]: exception in sending data to {0}: {1}", requestUrl, e);
return deserial; return deserial;
} }
finally finally
@ -976,19 +981,28 @@ namespace OpenSim.Framework
{ {
using (WebResponse resp = request.GetResponse()) using (WebResponse resp = request.GetResponse())
{ {
if (resp.ContentLength > 0) if (resp.ContentLength != 0)
{ {
Stream respStream = resp.GetResponseStream(); Stream respStream = resp.GetResponseStream();
XmlSerializer deserializer = new XmlSerializer(typeof(TResponse)); XmlSerializer deserializer = new XmlSerializer(typeof(TResponse));
deserial = (TResponse)deserializer.Deserialize(respStream); deserial = (TResponse)deserializer.Deserialize(respStream);
respStream.Close(); respStream.Close();
} }
else
m_log.WarnFormat("[SynchronousRestObjectRequester]: Oops! no content found in response stream from {0} {1}", requestUrl, verb);
} }
} }
catch (System.InvalidOperationException) catch (System.InvalidOperationException)
{ {
// This is what happens when there is invalid XML // This is what happens when there is invalid XML
m_log.WarnFormat("[SynchronousRestObjectRequester]: Invalid XML {0} {1}", requestUrl, typeof(TResponse).ToString());
} }
catch (Exception e)
{
m_log.WarnFormat("[SynchronousRestObjectRequester]: Exception on response from {0} {1}", requestUrl, e);
}
return deserial; return deserial;
} }
} }

View File

@ -1612,15 +1612,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]); currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
else else
{ {
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
currentPacket = null; currentPacket = null;
} }
} }
if (currentPacket != null) if (currentPacket != null)
{
// m_log.DebugFormat(
// "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
OutPacket(currentPacket, ThrottleOutPacketType.Asset, false); OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
} }
}
private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder) private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
{ {

View File

@ -178,6 +178,9 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage
List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>( List<GridInstantMessage> msglist = SynchronousRestObjectPoster.BeginPostObject<UUID, List<GridInstantMessage>>(
"POST", m_RestURL + "/RetrieveMessages/", client.AgentId); "POST", m_RestURL + "/RetrieveMessages/", client.AgentId);
if (msglist == null)
m_log.WarnFormat("[OFFLINE MESSAGING]: WARNING null message list.");
foreach (GridInstantMessage im in msglist) foreach (GridInstantMessage im in msglist)
{ {
// client.SendInstantMessage(im); // client.SendInstantMessage(im);

View File

@ -62,8 +62,8 @@ namespace OpenSim.Region.CoreModules.Hypergrid
{ {
List<MapBlockData> mapBlocks = new List<MapBlockData>(); List<MapBlockData> mapBlocks = new List<MapBlockData>();
List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID, List<GridRegion> regions = m_scene.GridService.GetRegionRange(m_scene.RegionInfo.ScopeID,
(minX - 4) * (int)Constants.RegionSize, (maxX + 4) * (int)Constants.RegionSize, minX * (int)Constants.RegionSize, maxX * (int)Constants.RegionSize,
(minY - 4) * (int)Constants.RegionSize, (maxY + 4) * (int)Constants.RegionSize); minY * (int)Constants.RegionSize, maxY * (int)Constants.RegionSize);
foreach (GridRegion r in regions) foreach (GridRegion r in regions)
{ {
@ -76,7 +76,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
FillInMap(mapBlocks, minX, minY, maxX, maxY); FillInMap(mapBlocks, minX, minY, maxX, maxY);
// //
remoteClient.SendMapBlock(mapBlocks, flag); remoteClient.SendMapBlock(mapBlocks, 0);
} }
@ -93,7 +93,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid
mblock.X = (ushort)x; mblock.X = (ushort)x;
mblock.Y = (ushort)y; mblock.Y = (ushort)y;
mblock.Name = ""; mblock.Name = "";
mblock.Access = 254; // not here??? mblock.Access = 254; // means 'simulator is offline'. We need this because the viewer ignores 255's
mblock.MapImageId = UUID.Zero; mblock.MapImageId = UUID.Zero;
mapBlocks.Add(mblock); mapBlocks.Add(mblock);
} }

View File

@ -820,7 +820,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
block.X = (ushort)minX; block.X = (ushort)minX;
block.Y = (ushort)minY; block.Y = (ushort)minY;
block.Access = 254; // == not there block.Access = 254; // means 'simulator is offline'
response.Add(block); response.Add(block);
} }
remoteClient.SendMapBlock(response, 0); remoteClient.SendMapBlock(response, 0);
@ -846,7 +846,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
MapBlockFromGridRegion(block, r); MapBlockFromGridRegion(block, r);
mapBlocks.Add(block); mapBlocks.Add(block);
} }
remoteClient.SendMapBlock(mapBlocks, flag); remoteClient.SendMapBlock(mapBlocks, 0);
} }
protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r) protected void MapBlockFromGridRegion(MapBlockData block, GridRegion r)

View File

@ -904,11 +904,29 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
/// <summary>
/// Link an inventory item to an existing item.
/// </summary>
/// <remarks>
/// The linkee item id is placed in the asset id slot. This appears to be what the viewer expects when
/// it receives inventory information.
/// </remarks>
/// <param name="remoteClient"></param>
/// <param name="transActionID"></param>
/// <param name="folderID"></param>
/// <param name="callbackID"></param>
/// <param name="description"></param>
/// <param name="name"></param>
/// <param name="invType"></param>
/// <param name="type">/param>
/// <param name="olditemID"></param>
private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, private void HandleLinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID,
uint callbackID, string description, string name, uint callbackID, string description, string name,
sbyte invType, sbyte type, UUID olditemID) sbyte invType, sbyte type, UUID olditemID)
{ {
m_log.DebugFormat("[AGENT INVENTORY]: Received request to create inventory item link {0} in folder {1} pointing to {2}", name, folderID, olditemID); m_log.DebugFormat(
"[AGENT INVENTORY]: Received request from {0} to create inventory item link {1} in folder {2} pointing to {3}",
remoteClient.Name, name, folderID, olditemID);
if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) if (!Permissions.CanCreateUserInventory(invType, remoteClient.AgentId))
return; return;
@ -916,7 +934,20 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence presence; ScenePresence presence;
if (TryGetScenePresence(remoteClient.AgentId, out presence)) if (TryGetScenePresence(remoteClient.AgentId, out presence))
{ {
// byte[] data = null; bool linkAlreadyExists = false;
List<InventoryItemBase> existingItems = InventoryService.GetFolderItems(remoteClient.AgentId, folderID);
foreach (InventoryItemBase item in existingItems)
if (item.AssetID == olditemID)
linkAlreadyExists = true;
if (linkAlreadyExists)
{
m_log.WarnFormat(
"[AGENT INVENTORY]: Ignoring request from {0} to create item link {1} in folder {2} pointing to {3} since a link already exists",
remoteClient.Name, name, folderID, olditemID);
return;
}
AssetBase asset = new AssetBase(); AssetBase asset = new AssetBase();
asset.FullID = olditemID; asset.FullID = olditemID;
@ -1351,12 +1382,29 @@ namespace OpenSim.Region.Framework.Scenes
InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId); InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId);
containingFolder = InventoryService.GetFolder(containingFolder); containingFolder = InventoryService.GetFolder(containingFolder);
//m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", // m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}",
// contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName);
if (containingFolder != null && containingFolder != null) if (containingFolder != null && containingFolder != null)
{
// If the folder requested contains links, then we need to send those folders first, otherwise the links
// will be broken in the viewer.
HashSet<UUID> linkedItemFolderIdsToSend = new HashSet<UUID>();
foreach (InventoryItemBase item in contents.Items)
{
if (item.AssetType == (int)AssetType.Link)
{
InventoryItemBase linkedItem = InventoryService.GetItem(new InventoryItemBase(item.AssetID));
linkedItemFolderIdsToSend.Add(linkedItem.Folder);
}
}
foreach (UUID linkedItemFolderId in linkedItemFolderIdsToSend)
SendInventoryUpdate(client, new InventoryFolderBase(linkedItemFolderId), false, true);
client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems); client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems);
} }
}
/// <summary> /// <summary>
/// Update an item in a prim (task) inventory. /// Update an item in a prim (task) inventory.

View File

@ -499,6 +499,10 @@ namespace OpenSim.Region.Framework.Scenes
public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, public void HandleFetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID,
bool fetchFolders, bool fetchItems, int sortOrder) bool fetchFolders, bool fetchItems, int sortOrder)
{ {
// m_log.DebugFormat(
// "[USER INVENTORY]: HandleFetchInventoryDescendents() for {0}, folder={1}, fetchFolders={2}, fetchItems={3}, sortOrder={4}",
// remoteClient.Name, folderID, fetchFolders, fetchItems, sortOrder);
if (folderID == UUID.Zero) if (folderID == UUID.Zero)
return; return;

View File

@ -283,6 +283,7 @@ namespace OpenSim.Server.Handlers.Simulation
StreamReader reader = new StreamReader(inputStream, encoding); StreamReader reader = new StreamReader(inputStream, encoding);
string requestBody = reader.ReadToEnd(); string requestBody = reader.ReadToEnd();
reader.Close();
keysvals.Add("body", requestBody); keysvals.Add("body", requestBody);
httpResponse.StatusCode = 200; httpResponse.StatusCode = 200;
@ -469,6 +470,7 @@ namespace OpenSim.Server.Handlers.Simulation
StreamReader reader = new StreamReader(inputStream, encoding); StreamReader reader = new StreamReader(inputStream, encoding);
string requestBody = reader.ReadToEnd(); string requestBody = reader.ReadToEnd();
reader.Close();
keysvals.Add("body", requestBody); keysvals.Add("body", requestBody);
httpResponse.StatusCode = 200; httpResponse.StatusCode = 200;

View File

@ -14,7 +14,7 @@
<layout type="log4net.Layout.PatternLayout"> <layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{HH:mm:ss} - %message" /> <conversionPattern value="%date{HH:mm:ss} - %message" />
<!-- console log with milliseconds. Useful for debugging --> <!-- console log with milliseconds. Useful for debugging -->
<!-- <conversionPattern value="%date{HH:mm:ss.fff} - %message" /> --> <!-- <conversionPattern value="%date{HH:mm:ss.fff} - %message" /> -->
</layout> </layout>
</appender> </appender>