re-added updateInventory fixes that got lost in the merge, also added a check for null creatorid on inventorycreate event

--- OpenSim/Grid/AgentDomain.Modules/UserLoginService.cs
+++ OpenSim/Grid/AgentDomain.Modules/UserLoginService.cs
@@ -1398,12 +1398,16 @@
                 return responseMap;
             }

-            InventoryItemBase resolvedItem = OSDToInventoryItemBase(requestMap);
+            InventoryItemBase resolvedItem = OSDToInventoryItemBase(requestMap);
+
+            if(String.IsNullOrEmpty(resolvedItem.CreatorId) || resolvedItem.CreatorId.Equals(UUID.Zero.ToString())  )
+            {
+            	resolvedItem.CreatorId = agentUUID.ToString();
+            	m_log.Info("[AGENT DOMAIN]: createInventory, CreatorId not set setting to " + agentUUID.ToString());
+            }

 			// call the inventory service to add it
-			bool success = m_inventoryService.AddItem( resolvedItem);
-            //            bool success = false; // DWL hack
-
+			bool success = m_inventoryService.AddItem( resolvedItem);

             responseMap["success"] = OSD.FromBoolean(success);
             return responseMap;
@@ -1413,87 +1417,124 @@

-        public OSD updateInventory(string path, OSD request, string endpoint)
-        {
-            m_log.Info("[AGENT DOMAIN]: updateInventory cap called");
-
-            OSDMap responseMap = new OSDMap();
-            OSDMap requestMap = (OSDMap)request;
-
-            // check that this cap is valid
-            string[] pathSegments = path.Split('/');
-            int i;
-
-            if (pathSegments.Length < 2)
-             {
-                m_log.WarnFormat("[Agent Domain]: updateInventory Badly formed seed cap fetch path {0} from endpoint {1}",path,endpoint);
-                responseMap["connect"] = OSD.FromBoolean(true);
-                return responseMap;
-            }
-
-            UUID agentUUID = m_uuid_table.getAgentUUIDforCap(pathSegments[3]);
-            m_log.InfoFormat("[AGENT DOMAIN]: updateInventory  found agent UUID of {0}",agentUUID.ToString());
-            if (agentUUID == UUID.Zero)
-             {
-                m_log.Warn("[AGENT DOMAIN]: Invalid cap");
-                return responseMap;
-            }
-
-            InventoryItemBase resolvedItem = OSDToInventoryItemBase(requestMap);
-
-			// call the inventory service to add it
-			bool success = m_inventoryService.UpdateItem( resolvedItem);
-                       // bool success = false; // DWL HACK
-
-
-            responseMap["success"] = OSD.FromBoolean(success);
-            return responseMap;
-
-        }
-
-        public OSD updateWearables(string path, OSD request, string endpoint)
-        {
-        	m_log.Info("[AGENT DOMAIN]: updateWearables cap called");
-
-        	 OSDMap responseMap = new OSDMap();
-            OSDMap requestMap = (OSDMap)request;
-
-            // check that this cap is valid
-            string[] pathSegments = path.Split('/');
-            int i;
-
-            if (pathSegments.Length < 2)
-             {
-                m_log.WarnFormat("[Agent Domain]: updateInventory Badly formed seed cap fetch path {0} from endpoint {1}",path,endpoint);
-                responseMap["connect"] = OSD.FromBoolean(true);
-                return responseMap;
-            }
-
-            UUID agentUUID = m_uuid_table.getAgentUUIDforCap(pathSegments[4]);
-            m_log.InfoFormat("[AGENT DOMAIN]: updateInventory  found agent UUID of {0}",agentUUID.ToString());
-            if (agentUUID == UUID.Zero)
-             {
-                m_log.Warn("[AGENT DOMAIN]: Invalid cap");
-                return responseMap;
-            }
-
-            OSDArray wearables = (OSDArray)requestMap["avatar_wearables"];
-	        AvatarWearable[] wearableArray = new AvatarWearable[13];
-            int count =0;
-            foreach (OSDMap wble in wearables)
-            {
-                 AvatarWearable aWearable = new AvatarWearable(wble["ItemID"].AsUUID(), wble["AssetID"].AsUUID());
-                 wearableArray[count] = aWearable;
-                 count++;
-            }
-
-            AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(agentUUID);
-            appearance.Wearables = wearableArray;
-            m_userDataBaseService.UpdateUserAppearance(agentUUID,appearance);
-
-            responseMap["success"] = OSD.FromBoolean(true);
-            return responseMap;
-
+        public OSD updateInventory(string path, OSD request, string endpoint)
+        {
+            m_log.Info("[AGENT DOMAIN]: updateInventory cap called");
+
+            OSDMap responseMap = new OSDMap();
+            OSDMap requestMap = (OSDMap)request;
+
+            // check that this cap is valid
+            string[] pathSegments = path.Split('/');
+            int i;
+
+            if (pathSegments.Length < 2)
+             {
+                m_log.WarnFormat("[Agent Domain]: updateInventory Badly formed seed cap fetch path {0} from endpoint {1}",path,endpoint);
+                responseMap["connect"] = OSD.FromBoolean(true);
+                return responseMap;
+            }
+
+            UUID agentUUID = m_uuid_table.getAgentUUIDforCap(pathSegments[3]);
+            m_log.InfoFormat("[AGENT DOMAIN]: updateInventory  found agent UUID of {0}",agentUUID.ToString());
+            if (agentUUID == UUID.Zero)
+             {
+                m_log.Warn("[AGENT DOMAIN]: Invalid cap");
+                return responseMap;
+            }
+
+            InventoryItemBase itemUpd = OSDToInventoryItemBase(requestMap);
+
+            // we need to get the item from inventory as the full item details do not get passed to us in the cap
+            InventoryItemBase item = m_inventoryService.GetInventoryItem(itemUpd.ID);
+            if (item != null)
+            {
+            	item.Name = itemUpd.Name;
+                item.Description = itemUpd.Description;
+                item.NextPermissions = itemUpd.NextPermissions;
+                item.CurrentPermissions |= 8; // Slam!
+                item.EveryOnePermissions = itemUpd.EveryOnePermissions;
+                item.GroupPermissions = itemUpd.GroupPermissions;
+
+                item.GroupID = itemUpd.GroupID;
+                item.GroupOwned = itemUpd.GroupOwned;
+                item.CreationDate = itemUpd.CreationDate;
+                // The client sends zero if its newly created?
+
+                if (itemUpd.CreationDate == 0)
+                    item.CreationDate = Util.UnixTimeSinceEpoch();
+                else
+                    item.CreationDate = itemUpd.CreationDate;
+
+                item.InvType = itemUpd.InvType;
+                item.SalePrice = itemUpd.SalePrice;
+            	item.SaleType = itemUpd.SaleType;
+                item.Flags = itemUpd.Flags;
+            }
+
+			// call the inventory service to add it
+			bool success = m_inventoryService.UpdateItem( item);
+
+
+            responseMap["success"] = OSD.FromBoolean(success);
+            return responseMap;
+
+        }
+
+        public OSD updateWearables(string path, OSD request, string endpoint)
+        {
+        	m_log.Info("[AGENT DOMAIN]: updateWearables cap called");
+
+        	 OSDMap responseMap = new OSDMap();
+            OSDMap requestMap = (OSDMap)request;
+
+            // check that this cap is valid
+            string[] pathSegments = path.Split('/');
+            int i;
+
+            if (pathSegments.Length < 2)
+             {
+                m_log.WarnFormat("[Agent Domain]: updateInventory Badly formed seed cap fetch path {0} from endpoint {1}",path,endpoint);
+                responseMap["connect"] = OSD.FromBoolean(true);
+                return responseMap;
+            }
+
+            UUID agentUUID = m_uuid_table.getAgentUUIDforCap(pathSegments[4]);
+            m_log.InfoFormat("[AGENT DOMAIN]: updateWearables  found agent UUID of {0}",agentUUID.ToString());
+            if (agentUUID == UUID.Zero)
+             {
+                m_log.Warn("[AGENT DOMAIN]: Invalid cap");
+                return responseMap;
+            }
+
+            OSDArray wearables = (OSDArray)requestMap["avatar_wearables"];
+	        AvatarWearable[] wearableArray = new AvatarWearable[13];
+            int count =0;
+            InventoryItemBase item;
+            foreach (OSDMap wble in wearables)
+            {
+            	 item = m_inventoryService.GetInventoryItem(wble["ItemID"].AsUUID());
+            	 AvatarWearable aWearable;
+            	 if(item!=null)
+            	 {
+                 	aWearable = new AvatarWearable(wble["ItemID"].AsUUID(), item.AssetID);
+            	 }
+                 else
+                 {
+                 	AvatarAppearance def = new AvatarAppearance();
+                 	aWearable = new AvatarWearable(wble["ItemID"].AsUUID(), def.Wearables[count].AssetID);
+                 }
+                 wearableArray[count] = aWearable;
+                 count++;
+            }
+
+            AvatarAppearance appearance = m_userDataBaseService.GetUserAppearance(agentUUID);
+            appearance.Wearables = wearableArray;
+            m_userDataBaseService.UpdateUserAppearance(agentUUID,appearance);
+
+            responseMap["success"] = OSD.FromBoolean(true);
+            return responseMap;
+
         }

 	public OSD adGetSkeleton(string path, OSD request, string endpoint)


Issue: painfully slow terrain loading. The cause is commit d9d995914c5fba00d4ccaf66b899384c8ea3d5eb (r/23185) -- the WaitOne on the UDPServer. Putting it back to how it was done solves the issue. But this may impact CPU usage, so I'm pushing it to test if it does.

--- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -246,7 +246,7 @@
         /// This allows the outbound loop to only operate when there is data to send rather than continuously polling.
         /// Some data is sent immediately and not queued.  That data would not trigger this event.
         /// </remarks>
-        private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);
+        //private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false);

         private Pool<IncomingPacket> m_incomingPacketPool;

@@ -907,7 +907,7 @@

             PacketPool.Instance.ReturnPacket(packet);

-            m_dataPresentEvent.Set();
+            //m_dataPresentEvent.Set();
         }

         /// <summary>
@@ -1919,12 +1919,12 @@

                     // If nothing was sent, sleep for the minimum amount of time before a
                     // token bucket could get more tokens
-                    //if (!m_packetSent)
-                    //    Thread.Sleep((int)TickCountResolution);
+                    if (!m_packetSent)
+                        Thread.Sleep((int)TickCountResolution);
                     //
                     // Instead, now wait for data present to be explicitly signalled.  Evidence so far is that with
                     // modern mono it reduces CPU base load since there is no more continuous polling.
-                    m_dataPresentEvent.WaitOne(100);
+                    //m_dataPresentEvent.WaitOne(100);

                     Watchdog.UpdateThread();
                 }


objectId in AvatarAnimation packet should be UUID.Zero for non-overridden animations

--- OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -3466,8 +3466,6 @@

                 ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
                 ani.AnimationSourceList[i].ObjectID = objectIDs[i];
-                if (objectIDs[i] == UUID.Zero)
-                    ani.AnimationSourceList[i].ObjectID = sourceAgentId;
             }
             ani.Header.Reliable = false;
             OutPacket(ani, ThrottleOutPacketType.Task);